Reversing a rules
1 posts in topic
Flat View  Flat View

Posted By:   James_Paul
Posted On:   Thursday, December 13, 2001 11:04 AM


i just want to know if we can reverse
a rule,

i have a rule in the lexer:

WS : "
" {_ttype = Token.SKIP;};

and in the parser, i have :

break_stat : BREAK | BREAK Identifier ;

And i want to do something like :

break_stat : BREAK | BREAK NOTWS Identifier;

I don't want there is a WS between the
two token !

Could you help me, thank you

Re: Reversing a rules

Posted By:   Terence_Parr  
Posted On:   Thursday, December 20, 2001 11:36 AM

Issues with whitespace should probably be resolved in the lexer. Make a rule that is BREAK immediately followed by a nonwhitespace then an Identifier.

Or, pass all whitespace to parser on a hidden token stream and then query it with a semantic predicate for the second alternative of break_stat. Something like that might work.

About | Sitemap | Contact