Hi Indhu,

I get "Mismatched token exception".  If remove the ESC_SEQ tokens/rules and
make it look as below, it works okay.  If I add the ESC_SEQ (see below)
stuff back in, it will work IF I place an escape sequence as the first
character.  Seems to work okay in the debugger (I'm very new to ANTLR),
though.  I don't see why this wouldn't work in the interpreter, but then
again I don't know much yet.  I have no predicates or anything, just
experimenting with ANTLRWorks wizard generated parser...

Thanks!

STRING
    :    '"' ( ESC_SEQ | ~('\\'|'"') )* '"';

fragment
ESC_SEQ
    :'\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
    | OCTAL_ESC
    | UNICODE_ESC


fragment
OCTAL_ESC
    :   '\\' ('0'..'3') ('0'..'7') ('0'..'7')
    |   '\\' ('0'..'7') ('0'..'7')
    |   '\\' ('0'..'7')
    ;

fragment
UNICODE_ESC
    :   '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
    ;

On Tue, Oct 13, 2009 at 2:10 PM, Indhu Bharathi <[email protected]>wrote:

>  Prefer using debugger instead of interpreter. Interpreter doesn’t work as
> expected sometimes (when you are using semantic predicates).
>
>
>
> That said, for this particular case it seems to works fine.
>
>
>
> r              :               STRING
>
>                 ;
>
>
>
> STRING
>
>     :  '"' ( ~('\\'|'"') )* '"'
>
>     ;
>
>
>
> Are you using semantic predicates somewhere else that causes the
> interpreter to fail?
>
>
>
> BTW, what is the error message you get?
>
>
>
> Cheers, Indhu
>
>
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Mark Wilson
> *Sent:* Tuesday, October 13, 2009 11:34 PM
> *To:* [email protected]
> *Subject:* [antlr-interest] ANTLRWorks question
>
>
>
> I used the ANTLRWorks wizard to start my grammar.  There appears to be
> something wrong with the STRING token, basically something like "Joe" does
> not parse correctly in the interpreter.  This is what the rule looks like:
>
> STRING
>     :  '"' ( ESC_SEQ | ~('\\'|'"') )* '"'
>     ;
>
> What is this supposed to do?
>
> Thanks,
> Mark Wilson
>
> --
> Mark Wilson
>



-- 
Mark Wilson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to