[antlr-interest] Problem with ANTLRWorks debugger?

Stuart Dootson stuart.dootson at gmail.com
Thu Sep 7 11:17:36 PDT 2006


I've downloaded ANTLRworks 1.0ea11, beta 1 and beta 2 and, while the
overall experience has been extremely favourable (I wish I'd had it
when I was starting with Antlr 2!), I've had the same problem in each
- either I'm misunderstanding how I should be using the ANTLRworks
debugger, or there's a problem with it.

Anyway - my problem. I have a simple grammar (shown below) that I've
been using to investigate ANTLR 3 and the tree rewriting rules (which
is where ANTLRWorks 1.0b2 debugger's AST display would be handy!).
When I feed it the sample text (also shown below) using the
interpreter, everything's tickety-boo and I get the output I expect.
However, feeding it the same text through the debugger leads to
whitespace raising a MismatchedTokenException. It strikes me that
there's no way of telling the debugger which tokens (i.e. WS!) to
ignore?

BTW - tested on Windows 2000 and OS X. Also BTW, on OS X, the
File->Save As... doesn't appear to work - no panel pops up, anyway.

And a feature request - will there be any way of displaying an output
AST with ANTLRworks that doesn't use the debugger. If not, could you
make it so, please :-)

Stuart Dootson

-------------------- Cut here - grammar --------------------
grammar Classes;

options {output=AST;}

tokens { CLASS; VARS; METHS; }

classes
       : (classDecl ';')+
       ;

classDecl
       : 'class' name=ID 'is'
            ((v+=varDecl | m+=methodDecl) ';')*
         'end' ID?
         -> ^(CLASS $name ^(VARS $v) ^(METHS $m) )
       ;

varDecl
       : ID ':' modifiers? ID
       ;

methodDecl
       : ID '(' (argDecl (';' argDecl)* )? ')'('returns' ID)?
       ;

argDecl
       : ID ':' ('in' | 'out' | 'in' 'out') ID
       ;

modifiers
       : 'const'
       | 'volatile'
       ;

ID      : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
       ;

WS
       : ( ' ' | '\t' | '\f' ) +
       | ( '\r' '\n' | '\n' )
       { channel=99; }
       ;
-------------------- Cut here - grammar --------------------


----------------- Cut here - sample input ------------------
class Pooh is
  a : x;
  y : b;
  b() returns fff;
  b(a : in x;b : out y;c : in out z) returns df;
end Pooh;
----------------- Cut here - sample input ------------------


More information about the antlr-interest mailing list