Parser - Reader - ..

Hi everyone,

I'm developing a bacth application.

This application has to read a file in which each line represents a Business Object.

To parse this file i've done a static method which, from a line of this file give me an Object.

that's ok !.

But, i've also done a Reader (suchn as java.io.BufferedReader) which is like a decorator around any java.io.Reader and has a method which allow me to read directly my BusinessObject.

(this method, of course, uses my previously defined parser).

My question is :

Do you think is good to create such a reader for this kind of parsing ?

To parse a spacific file format ?

Regards,

Sebastien Degardin.

[717 byte] By [sdegardina] at [2007-10-2 10:20:05]
# 1

Compiler/interpreters are very well studied part of computer science. If it was me I would follow the standard break down. As I recall the normal break down requires a lexer then a parser.

Rather than reinventing the wheel you might want to look at the book "Compiler Design" (or something like that) which was written by Aho and is often referred to as the dragon book.

There are also compiler generators out there - one being JavaCC.

As to whether any of that is a good idea it depends on details of what you are doing.

jschella at 2007-7-13 1:49:32 > top of Java-index,Other Topics,Patterns & OO Design...