[antlr-interest] Re: Whatever Until EOL
codeteacher
codeteacher at toughguy.net
Tue Oct 12 14:39:49 PDT 2004
Bryan,
I think that the CONTENT_LEADER wouldn't work since that would imply
that the entry would start with LPAREN, while it isn't in reality.
Maybe I just don't understand your grammar, but I believe the one you
gave wouldn't parse:
[content]
this is content*key ( 77^q,8&1nn) AABBN@!(!)))0000
content2 (2177, LLS) pppp1782m
Also, pardon me for my ignorance since I'm just acquainted with Antlr:
How can I set ignore option in the lexer?
Thanks.
-- Rob
--- In antlr-interest at yahoogroups.com, "Bryan Ewbank" <ewbank at s...> wrote:
> content:
> "[" "content" "]"
> ((WS|NL)* WHATEVERTILLLPAREN "(" WHATEVERTILLCOMMA ","
> WHATEVERTILLRPAREN ")" WHATEVERTILLEOL)+
>
> Change this by moving stuff to the lexer:
> protected CONTENT: "[content]";
> protected RP: ')';
> protected COMMA: ',';
> protected LP: '('
>
> CONTENT_LEADER : CONTENT! (~',')* ;
> FIRSTARG : LP! ( ~COMMA )* ;
> OTHERARGS : COMMA! (~RP)* ;
> TRAILING : RP! (~EOL)* ;
> The ambiguity is gone because '(' guarantees a FIRSTARG; ',' guarantees
> OTHERARGS, etc.
>
> Now the parser looks like this
> content: CONTENT_LEADER ( FIRSTARG OTHERARGS TRAILING )+ ;
>
> For dealing with the WS|NL stuff, I think that the ignore option to the
> lexer will meet your needs.
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