[antlr-interest] Changing types and text in the parser ...

Mark Lentczner markl at glyphic.com
Fri May 21 08:00:37 PDT 2004


Here's a concrete example.  It avoids your worries about parenthesis 
and Ric's worry about when the tree is built by using extra rules.  I 
do this sort of thing in with types in my grammar for the same reason: 
I want the AST to be very regular.

On May 19, 2004, at 7:52 AM, Anthony Youngman wrote:
> gotost : (GOTO^ (INT { $setType( IDENT); } | IDENT) (COLON | {
> $append(":"); } ) )

gotost: GOTO^ gotodest ;

gotodest: (INT | IDENT) (COLON!)?
	{ ##.setType(IDENT); ##.setText(##.getText()+":"); }
	;

If you're generating C++, then the "##." will need to be "##->".

	- Mark



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list