[antlr-interest] Antlrworks cant two instances of parser
chintanraoh at gmail.com
Mon Jul 2 00:22:49 PDT 2007
Thanks for all your time.
On 7/2/07, Thomas Brandon <tbrandonau at gmail.com> wrote:
> ANTLRWorks debug parsers listen on a socket to connect to the
> ANTLRWorks debugger. As your main parser is already using this socket
> the sub-parser cannot also use it. If your inner parser is different
> to your outer parser then you could use a non-debug version of the
> inner parser. Or if they are the same, you could, while debugging
> create a second copy of your parser with a new name and generate this
> without debugging enabled and then use that for your inner parser, or
> just generate to a different package and use a fully qualified name
> for it.
Hmm.. This seems to a sort of solution. Tedious but okay .
> Alternately there is a constructor that takes a port to debug on, so
> if you used this constructor with a different port then they should
> not clash. However then your inner parser will wait for socket
> connections from ANTLRWorks to start parsing, maybe you could have two
> copies of ANTLRWorks open (if it allows this) and connect the second
> copy to the inner parser, though you would have to connect ANTLRWorks
> after the constructor for you inner parser was called so if the inner
> parser is constructed as needed then you would have to re-connect
> ANTLRWorks everytime one was started. So unless you reuse a single
> parser instance this is somewhat tricky.
I did new nameParser(token,port no) and made another copy of antlrworks
work on the port but it did not work :(. It was waiting for ever for
> There is a constructor for DebugParser which accepts a debug listener
> but ANTLRWorks does not add an override for this constructor to it's
> debug parsers, if you added an override for this constructor then you
> could have your inner parser not wait for ANTLRWorks by providing an
> alternate debug listener. You can add this constructor to your
> @members section but then you need to remove it when not compiling
> with debugging.
I added the required constructor and called it with
new nameParser( token,getDebugListener () ) . This also did not work :(
> I requested that ANTLRWorks template be changed to also override this
> constructor. In the meantime it would be a fairly trivial patch to the
> ANTLRWorks templates to allow this.
Also another point is that i could have variable no of recursive calls
to the parser . So these
solutions may not work well.A good feature in the ide will be to make
both inner and outer parsers work on the same instance of the debugger
ie let debugger make connections to any no of parsers. I don't know
how hard or easy this is it but I do understand that this can be very
Another good feature would be to add a method setDebug(bool) to the DebugParser
Currently i am working without the antlrworks IDE when i make
recursive calls to the same parser.
More information about the antlr-interest