Lack of removeErrorListeners() in python parser

63 views
Skip to first unread message

Zack Payton

unread,
Jun 30, 2015, 9:45:43 PM6/30/15
to antlr-di...@googlegroups.com
Hi there,

I've written a parser for data streams and I'm trying to make it production ready.
Part of this includes gracefully handling errors.  Currently the default error handler prints to stdout which is not what I want.
I'd ideally like to generate a python exception that I can catch on syntax error and send that to my central logging infrastructure.

I created a subclass of antlr4.DiagnosticErrorListener over rid the syntaxError() method.
Then I go to removeErrorListeners and notice that the python parser class I generated doesn't have that method or anything that resembles it.
It does however have the addErrorListener() method.  So now, I'm getting my exception and all is good but I'm still spitting failures to STDOUT which I want to prevent.

Anyone know how to removeErrorListeners() on a generated python parser?

Thanks,
Z

Eric Vergnaud

unread,
Jul 1, 2015, 9:05:32 PM7/1/15
to antlr-di...@googlegroups.com
Hi,

this is already fixed in the upcoming version.
Check the code in Recognizer.py.

Eric

Zack Payton

unread,
Jul 1, 2015, 10:38:24 PM7/1/15
to antlr-di...@googlegroups.com
I scrapped using python because of performance differences.
I noticed that the generated python parser was orders of magnitude slower compared to the generated Java parser.
Java can parse some complex statements in ~3 seconds wheras python would take around 3 minutes and would sometimes syntax error on statements that the generated java parser could handle just fine.

Any idea if newer version might fix that as well before I totally ditch python?

--
You received this message because you are subscribed to a topic in the Google Groups "antlr-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/antlr-discussion/mOFcnUKxUcw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Terence Parr

unread,
Jul 2, 2015, 2:03:10 PM7/2/15
to antlr-di...@googlegroups.com
Can you send a simple example that demonstrates? I can try to profile it. not sure what python has in this regard.
T
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.

Eric Vergnaud

unread,
Jul 3, 2015, 10:29:53 AM7/3/15
to antlr-di...@googlegroups.com
Hi,

we can't fix issues with "syntax error on statements that the generated java parser could handle just fine" if we're not aware of them.
Right now we have 300+ tests which demonstrate rigorously same behavior across targets.
Please report a bug on GitHub if you can reproduce.
As per the performance, antlr for python can't reduce the gap between python and java i.e. 30 times slower.
Many native python libraries are written in C++, which gives the impression that python could compete. It can't.
We'd be interested in working examples where this gap increases dramatically. We could then probably improve the performance.
Please remember that the java version has accumulated 25 years of tuning, while the python one is only a year old.
And we all work for free.

Eric

Zack Payton

unread,
Jul 7, 2015, 8:25:37 PM7/7/15
to antlr-di...@googlegroups.com
Hi team,

I'm working on getting a simplified test case but the grammar is fairly extensive so it's taking a while.
I will send an update when that happens.

Thank you for your patience,
Z
Reply all
Reply to author
Forward
0 new messages