On Thu, 13 May 2010, Tech Id wrote:
> I need to read a configuration file and create an Object Model in
> memory. The configuration file uses around 7-8 keywords and symbols like
> '(', '[', ']' and ')' and quoted strings.
>
> My question is: Should I use a simple tokenizer to parse the above file
> or use some kind of parser?
Impossible to say without knowing more about the language. Can you give us
an example?
> If parser is recommended, which one should be best? ANTLR? Flex/Bison?
I like JavaCC:
https://javacc.dev.java.net/
Partly because i prefer LL(k) to LALR, but that's a matter of taste.
JavaCC certainly makes it very easy to write grammars, and very easy to
hang your custom code off those grammars. It has a facility for building
parse trees (generating code for building them, i think), but i never used
it - i found it easier in the long run to put my code right in the action
blocks. I used something that looks a bit like a Visitor or Builder
pattern as a facade that the parser could talk to.
tom
--
The art of medicine consists in amusing the patient while nature cures
the disease. -- Voltaire