[antlr-interest] Re: Building hierarchical grammars
Mark
markl at glyphic.com
Sun Mar 28 08:45:45 PST 2004
> LITERAL: INTEGER_LITERAL | FLOATING_POINT_LITERAL | CHARACTER_LITERAL |
STRING_LITERAL;
These things should be parser rules, not lexer rules.
literal: INTEGER_LITERAL | FLOATING_POINT_LITERAL | CHARACTER_LITERAL |
STRING_LITERAL;
In general, Lexers are not 'hierarchical', Parsers are. Different parser rules can match
similar things because they are called from other rules:
array-assignment: ID "[" index "]" "=" value ";' ;
index: INTEGER_LITERAL ;
value: INTEGER_LITERAL | FLOATING_POINT_LITERAL ;
Lexers, on the other hand, have to pick from among ALL the Lexer rules each and every
time they are asked for the next token. They don't 'know' where they are called from in
the parser, and so can't restrict the set of token parses for a particular case.
- 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