[antlr-interest] How to debug grammars on Vista (was: How to debug tree grammar??)

David-Sarah Hopwood david-sarah at jacaranda.org
Mon Jul 20 11:48:52 PDT 2009


sunao furukawa wrote:
[...]
> 4.I started ANTLRWorks debug remote in localhost port 49153.
> 5.I executed [java TestE],and standard input [a=1 (CRLF) a+2*3 (CRLF) 
> (Ctrl-C)].
> 
> But I could not debug T1.g and below, error occur.
> (ASSIGN a 1)
> line 0:-1 mismatched input '<EOF>' expecting NEWLINE
> <mismatched token: [@-1,0:0='<no text>',<-1>,0:-1], resync=a+2*3>
> java.net.BindException: Address already in use: JVM_Bind
[...]
> I use Windows Vista Home Basic sp1.IP adress is private(dhcp).

I found that the default port 49153 could not be used on Vista. You
need to override it:

 - in the ANTLRWorks preferences (File menu | Preferences | Debugger tab),
   set 'Default local port' to an unused port number. I used 48000.

   If you need to use remote debugging (where the debugged process is
   launched separately from ANTLRWorks), also add -debug to the ANTLR
   options in the General tab.

 - pass this port number into the E3Parser, e.g.:

> public class TestE {
      private static final int DEBUGGER_PORT = 48000;

>     public static void main(String[] args) throws Exception {
>         ANTLRInputStream input = new ANTLRInputStream(System.in);
>         E3Lexer lexer = new E3Lexer(input);
>         CommonTokenStream tokens = new CommonTokenStream(lexer);

          E3Parser parser = new E3Parser(tokens, DEBUGGER_PORT,
                                         new RecognizerSharedState());

>         E3Parser.prog_return r = parser.prog();
> 
>         CommonTree t = (CommonTree)r.getTree();
>         CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
>         T1 walker = new T1(nodes);
>         walker.prog();
>     }
> }

This is not dependent on the grammar being a tree grammar.

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com



More information about the antlr-interest mailing list