[antlr-interest] Re: Predicate question

Mark markl at glyphic.com
Mon May 3 14:23:24 PDT 2004


> The '}' has dual purposes: Terminate the last statement and close 
> the function. So is there a way to write a non-ugly grammar for an 
> ugly language?

Yes, treat newline as a separator not a terminator:

function := id "{" statement-list "}" ;
statement-list := statement ( newline statement )* ;
statement := ... | empty ;
newline := NL ;
empty := ;

Since I assume that blank lines are allowed, this grammar allows a statement to be empty.  
This also has the nice effect of allowing the statement-list to be empty, and for there to be 
an extra newline between the last non-empty statement and the closing curly brace.

- 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