[antlr-interest] VB If elseif end if?
ronald.petty at milliman.com
ronald.petty at milliman.com
Tue Apr 27 10:45:09 PDT 2004
I have in my Parser the rule
//don't forget s1:s2:s3 etc for "If x Then s1:s2..." and for general use
statement
: {System.out.println("Entered Statement:Declaration");}
(declaration)=>declaration
{System.out.println("Leaving Statement:Declaration");}
| {System.out.println("Entered Statement:Expr");}
expr
{System.out.println("Leaving Statement:Expr");}
| {System.out.println("Entered Statement:IF");}
IF expr THEN (statement)* (ELSEIF expr THEN (statement)*)*
(ELSE (statement)*)? (END IF)?
{System.out.println("Leaving Statement:IF");}
;
And for newlines in the lexer
NL
:
( ("\r\n") => "\r\n"
| '\r'
| '\n'
)+
{ newline(); _ttype = Token.SKIP; }
;
If I have the input
if x then y
if x then y
The result is valid according to my grammar. However instead of two "if
then" statements I have one "if" with another shoved in the tail end of
the statement.
(hope this is good syntax)
statement
if (start of statement input)
x = expr (for now just an identifier)
then (next part of the expression
y = statement (which is an expr, just an identifier)
now sense we are looping in the statement (statement)*
the next if x then y is starting there instead of a top level statement.
This is because in VB the newline after y means your done. However I eat
all newlines in the lexer. What are the possible ways around this?
Thanks for the pointers.
Ron
**************************************************************************************
This communication is intended solely for the addressee and is
confidential. If you are not the intended recipient, any disclosure,
copying, distribution or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. Unless indicated
to the contrary: it does not constitute professional advice or
opinions upon which reliance may be made by the addressee or any
other party, and it should be considered to be a work in progress.
**************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20040427/0b05d73e/attachment.html
More information about the antlr-interest
mailing list