[antlr-interest] Re: java15.g: Can't parse only conditionalExpression

Jens Theeß j.theess at tu-bs.de
Tue Nov 23 09:54:42 PST 2004


Terence Parr wrote:

>ANTLR only thinks top-level rules (unreferenced by other rules) can be 
>followed by "end of input" so it's a matter of doing a trick as Andy 
>suggests or just adding a rule like:
>
>conditionalExpressionTopLevel : conditionalExpression ;
>
Works great! Thanks.

Next thing is how to best switch lexers. Fortunately, I have control 
over the syntax of the language (I'm extending the sequence diagram 
syntax to allow for embedded java actions). Following example is what I 
would like to do:

a -> b.foo(5, String d:d.startsWith("ha"), 10);

This is a sequence diagram event meaning that obj. a calls b.foo with 
the parameters 5, a String that starts with "ha", and 10. To support 
this, I think I would have to switch lexers from the parser, which is a 
no-no. So I could modify the syntax to look like this:

a -> b.foo(5, String d:j{d.startsWith("ha")}, 10);

or something similar, where I would switch to Java lexer upon seeing 
"j{" and switch back upon "}". Or is there any easy way to support the 
first version?

Jens



 
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