[antlr-interest] accepting nested code blocks

Graham Wideman gwlist at grahamwideman.com
Tue Oct 13 12:48:07 PDT 2009


Miklos:

Seems like a bug in AW interpreter.

At 10/13/2009 09:16 PM, Espák MiklósbPNz wrote:
>This is exactly what I want, but it does not work for me. Incredible!
>Do you use 3.2, too?

I'm using 3.2 and AW 1.3.  For me this grammar fails in AW interpreter, but
works if i compile it.

------------------------------
grammar Test03;

file
        :        (b=Block {System.out.println("Block:" + $b.text); })+ EOF
        ;

Block: '{' ( Block | ~('{'|'}') )* '}';
------------------------------

Test input:
{abc}{def}{{xyz}}

Output from compiled program:
Block:{abc}
Block:{def}
Block:{{xyz}}

Errors from AW (in console):
[12:39:19] Interpreting...
[12:39:19] problem matching token at 1:2 MismatchedTokenException(97!=125)
[12:39:19] problem matching token at 1:3 MismatchedTokenException(98!=123)
[12:39:19] problem matching token at 1:4 MismatchedTokenException(99!=123)
[12:39:19] problem matching token at 1:5 MismatchedTokenException(125!=123)
[12:39:19] problem matching token at 1:7 MismatchedTokenException(100!=125)
[12:39:19] problem matching token at 1:8 MismatchedTokenException(101!=123)
[12:39:19] problem matching token at 1:9 MismatchedTokenException(102!=123)
[12:39:19] problem matching token at 1:10 MismatchedTokenException(125!=123)

So this seems like a bug in AW interpreter.

-- Graham


More information about the antlr-interest mailing list