[antlr-interest] Solution to " How to have strings enclosed in " and/or ""
Terence Parr
parrt at cs.usfca.edu
Tue Dec 14 11:30:52 PST 2004
On Dec 13, 2004, at 11:42 PM, matthew ford wrote:
> Hi Ter,
> Still no go,
>
> Tried upping k to 7 and got
> // nongreedy exit test
> if ((LA(1)=='"'||LA(1)=='&') && (true) && (true) && (true) &&
> (true) &&
> (true) && (true)) break _loop11;
Crap. You are right. Hmm...Oh, yeah, it seems the analysis algorithm
simply removed double quote and & from the lookahead of the loop and
then decided a single char is enough. Ugh. Ok, the analysis is hosed.
Your solution seems the only one. Put a predicate in the loop:
( {pred}? (alt1|alt2) ) *
and it will work.
Note that ('&' 'q' 'u' 'o' 't' ';') is weird. May I suggest """?
Ter
>
> test actionLexer.g is attached
> matthew
> ----- Original Message -----
> From: "Terence Parr" <parrt at cs.usfca.edu>
> To: <antlr-interest at yahoogroups.com>
> Sent: Monday, December 13, 2004 7:27 AM
> Subject: Re: [antlr-interest] Solution to " How to have strings
> enclosed in
> " and/or ""
>
>
>>
>> On Dec 12, 2004, at 12:34 AM, matthew ford wrote:
>>
>>> No greedy=false did no do it
>>>
>>> It generated the test
>>>
>>> // nongreedy exit test
>>> if ((LA(1)=='"'||LA(1)=='&') && (true)) break _loop11;
>>> but I need to match '&' 'q' 'u' 'o' 't' ';' in order to exit not
>>> just
>>> &
>>
>> Is k=2 or k>=5?
>>
>> Ter
>> --
>> CS Professor & Grad Director, University of San Francisco
>> Creator, ANTLR Parser Generator, http://www.antlr.org
>> Cofounder, http://www.jguru.com
>> Cofounder, http://www.knowspam.net enjoy email again!
>>
>>
>>
>>
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
>>
>
>
>
> Yahoo! Groups Links
>
>
>
>
> <actionLexer.g>
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
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