[antlr-interest] Antlrworks cant two instances of parser

Thomas Brandon tbrandonau at gmail.com
Sun Jul 1 21:41:42 PDT 2007


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.
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.
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 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.

Tom.
On 7/2/07, chintan rao <chintanraoh at gmail.com> wrote:
> Hi,
> I tried to create an instance of parser inside the parser and made a
> call to a member function
> in the parser (as parser recursively calling itself). I wanted to lex
> and parser string which i find in the parser. Antlrworks gives
> "Address already in use" while debugging .
> I hope i am understood ,
> Sorry for being short,
> Chintan Rao H
>


More information about the antlr-interest mailing list