Hi,
I'm having a little trouble with JavaCC, a parser generator, and its
tree-creating tool jjtree.
I am trying to create a parser (and engine) for a language similar to SQL
and the first step is to get a parse tree. I have made some tests with
jjtree, but I have a problem. Getting the abstract syntax is already working
fine. For instance the output of a test statement with the dump()-method in
SimpleNode is:
Query
SelectClause
SelectList
Identifier
FromClause
TableReference
Identifier
But is there a way to also get the information about the actual toke itself?
For example the name (value) of the Identifier. Or if I have an
"AdditiveExpression()" I need to know if it's "+" or "-". There must be a
way to store this information in the tree and to read it out later, when you
execute the commands?
Thanks for helping me.
Markus
Roedy Green - 02 May 2004 13:48 GMT
>I'm having a little trouble with JavaCC, a parser generator, and its
>tree-creating tool jjtree.
I needed a crude parser for Java and had a look at a Java 1.5 Parser.
It is enormous. I decided to write my own state machine. It will
probably be only a few pages of code, with a tiny class for each
state. I am about 90% there.
All I am trying to do is classify tokens for colourising in a Java
code display. I don't need full tree. Just thinking you may have
similar modest interest.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.