[antlr-interest] lexer problem
Robert Soule
robert.soule at gmail.com
Mon Nov 3 14:17:51 PST 2008
Thank you! My problem was that I was testing the solution with the
interpreter.
thanks again for your help,
Robert
On Mon, Nov 3, 2008 at 3:00 PM, Gavin Lambert <antlr at mirality.co.nz> wrote:
> At 04:59 4/11/2008, Robert Soule wrote:
>>start
>> : LSQUARE AB RSQUARE
>> | A
>> ;
>>AB : ('a'|'b')+;
>>
>>fragment A: '[a]';
>>LSQUARE
>> : (A) => A { $type = A; }
>> | '['
>> ;
>>
>>RSQUARE : ']';
>>
>>
>>When I test with inputs "[ba]" I pass, but "[ab]" fails.
>
> It works for me (ANTLR 3.0.1). You are using a real compiled parser,
> though, right (or ANTLRworks' debugger)? Not the interpreter? Because the
> interpreter doesn't execute predicates (so it almost never works properly).
>
> If I change the start rule given above to this:
>
> start : (LSQUARE AB RSQUARE | A)+ ;
>
> then it'll successfully match the input "[ba][a][ab]".
>
>
More information about the antlr-interest
mailing list