JJTree Nodes

View: New views
1 Messages — Rating Filter:   Alert me  

JJTree Nodes

by rahim1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have been researching online, going through examples and working at this for the last couple of weeks but not been very successful at finishing the last part of my requirements!
 
I have created a parser which takes inputs that simple imperative programs (so it will accept assignments, if statements and while statements if the syntax is correct).
I have got the JJT file sorted so that it dumps out the nodes and the tokens inputted. I did this by editing the SimpleNode class to store an image (I didn't used the MULTI option).
I need to be able to refer to the input tokens as objects from the tree's data structure instead of just dumping them out. So I need to be able to know what the LHS and RHS elements are.
 
So if the user types in:
a = b + 1
I need to know that "a" is on the LHS from the root node, and "b + 1" is on the RHS. And then "b + 1" can be broken up again to a LHS and RHS.
 
To do this I have added the VISITOR option and tried to work on "jjtAccept" (not sure if I needed to to do what I need). I believe I have to change the methods in SimpleNode but not sure which ones I need to work on? I've tried using the "jjtGetChild" methods but not been successful.
 
I can attached my JJT and SimpleNode file if needed?
Getting quite worried now as I need to get this done fairly soon - would greatly appreciate any help to get started on this.
 
 
 
Many Thanks,
 
 
Rahim.