On Sat, May 17, 2008 at 2:56 PM, Johannes Luber <[EMAIL PROTECTED]> wrote:
>> I guess you mean something like that:
>> ---
>> grammar T;
>> options { language=Python; }
>> a: 'a' { foo = 1 // 2 };
>> ---
>> ANTLR Parser Generator  Version 3.1b1 (??)  1989-2007
>> error(10):  internal error: Exception /tmp/T.g:4:1: expecting '}',
>> found '<EOF>'@org.antlr.tool.ANTLRLexer.nextToken(ANTLRLexer.java:333):
>> unexpected stream error from parsing /tmp/T.g
>>
>> error(150):  grammar file /tmp/T.g has no rules
>> error(100): /tmp/T.g:0:0: syntax error: assign.types: <AST>:0:0:
>> unexpected end of subtree
>> error(100): /tmp/T.g:0:0: syntax error: define: <AST>:0:0: unexpected
>> end of subtree
>>
>> Ter: that looks like a bug to me...
>
> It's not a bug in the way you believe. The deeper problem is that ANTLR 
> recognizes // and % as comments in actions, treating the } as part of the 
> comment - and as no other languages treat // as valid operator this was so 
> far ignorable. The real fix would be that choosing a target allows ANTLR to 
> switch the comment markers to the one of the target language.

Yes, you're right. My brain stopped thinking half way through...

I think on the long run we need some kind of target specific
customization of the parser. E.g. another thing that's rather annoying
for Python, is the requirement to terminate assignments to $foos with
semicolons - in most cases works w/o one, but may result in strange
bugs.
Mmm.. now that we have grammar inheritance, we might exploit that once
ANTLR has been ported to V3.

-Ben
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org:8080/mailman/listinfo/antlr-dev

Reply via email to