[antlr-interest] Problem, with minimal problem-causing grammar

Terence Parr parrt at cs.usfca.edu
Mon Jun 11 16:49:01 PDT 2007


On Jun 10, 2007, at 6:19 PM, Phil Oliver wrote:

> Ter wrote:
>
>>  just increase the memory a little bit.
>
> I have a large amount of RAM specified in the java invocation for  
> the ANTLRWorks jar but I gather it's launching a separate JVM when  
> Debug is invoked to compile/debug the compiled code. How do I  
> change the memory parameters within ANTLRWorks, for debugging?
>
>> ANTLR does not seem to like tokens that can match no characters,
>> which you have a grammar:
>>
>> StrNoHash                       : CharNoHash*;
>> StrNoQuotAmp                    : CharNoQuotAmp*;
>>
>> These are meaningless because (...)* loops are optional. I think
>> antlr might be going crazy here for these tokens, but I believe I
>> have a bug report and already.
>
> Ok. I would not say they are meaningless however - how else can I  
> match the potentially empty contents of a delimited string, e.g. an  
> empty string with double quotes ("") or hash marks (##) ?  Or is it  
> that it should say:
>
> StrNoHash   : CharNoHash+;
>
> then I simply have StrNoHash* when referenced in parser rules?

Almost.  yep, tokens should not be empty.  Just use StrNoHash? in  
parser.

> I've read that some systems have a truly integrated lexer/parser,  
> where there is no artificial distinction made between tokens and  
> parser pattern matching rules - would it fundamentally break the  
> architecture of ANTLR for it to become that way someday?

It can do now if you purely use the lexer.  All rules but start rule  
must be fragment.  Weird, but it works!

Ter



More information about the antlr-interest mailing list