[antlr-interest] I got the parsing, now how do I do something useful ?

Tiller, Michael (M.M.) mtiller at ford.com
Thu Feb 27 10:59:54 PST 2003


I am in a similar boat.  I've built a lexer and a parser.  Furthermore, I have used the AST generation directives to create an AST that has the information I need in it.  Finally, I have a treewalker that I have used to walk the resulting ASTs (for complex test cases).

In summary, I have everything I need to get to the complete AST.  Now what?

In some sense, I know what I need to do to get to my final goal (which is an elaborated version of my initial tree), but I have these nagging questions:

1) Are there any tools (beyond the tree walker) that I can use for elaboration of my AST.

2) I expect to have to make many passes over my tree (which I can do with a tree walker), to do semantic checking before I finally elaborate the tree.  How do I store the data that I collect on these passes?  Should I store it on each AST node somehow (with some auxiliary "collection" objects) or should I somehow collect it at a global level using the AST node as a form of key?

Actually, those are the only questions I can think of off the top of my head.  Once I have some time to move beyond the tree construction phase, I'm sure I'll have more.

--
Mike

> -----Original Message-----
> From: uiorean <uiorean at cluj.astral.ro> [mailto:uiorean at cluj.astral.ro]
> Sent: Thursday, February 27, 2003 1:16 PM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] I got the parseing, now how do I do 
> something
> useful ?
> 
> 
> I wrote a lexer and a parser. Now my problem is how do I get the
> parsed tokens stored (for further processing) ? 
> My parser looks like:
> 
> entry:	(
> 		(insrd dest COMA source)
> 		|(insdest dest)	
> 		)*;
> 
> where I have
> 
> protected insrd:	 ADD_ 
> 		|ADC_
> 		|SUB_ 
>                 ;
> protected source:	 REG
> 			|DOP
> 			|PORT
> 			|LDB
> 			|DST
> 			;
> protected dest:		REG;
> 
> and so on...
> 
> i would like to do something like: 
> 
> 
> entry:	(
> 		(i:insrd d:dest COMA s:source 
> {somefunction(i.getText(), i.getType(), d.getText(), d.getType());})
> 		|(i1:insdest d1:dest
> {somefunction(i.getText(), i1.getType(), d1.getText(), 
> d1.getType());})	
> 		)*;
> 
> but this does not work.  I don't think I really need to build a tree
> for this, there must be an easyer way.
> 
> I am new to this mather so any suggestion is appreciated.
> 
> L. Uiorean
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list