Stop listener if found e.g. 100 errors

26 views
Skip to first unread message

André de Mattos Ferraz

unread,
May 11, 2015, 3:54:43 PM5/11/15
to antlr-di...@googlegroups.com
I have a listener and he has a list that store all errors that occurs. I want to stop listener if the I found 100 errors. Its possible? How?

Thx in advance.

Terence Parr

unread,
May 11, 2015, 4:03:27 PM5/11/15
to antlr-di...@googlegroups.com
um. put an IF in the listener?
On May 11, 2015, at 12:54 PM, André de Mattos Ferraz <fan...@gmail.com> wrote:

> I have a listener and he has a list that store all errors that occurs. I want to stop listener if the I found 100 errors. Its possible? How?
>
> Thx in advance.
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

Terence Parr

unread,
May 11, 2015, 4:11:23 PM5/11/15
to antlr-di...@googlegroups.com
to be more precise,

count++;
if (count>100) deregister your listener

T
On May 11, 2015, at 12:54 PM, André de Mattos Ferraz <fan...@gmail.com> wrote:

> I have a listener and he has a list that store all errors that occurs. I want to stop listener if the I found 100 errors. Its possible? How?
>
> Thx in advance.
>

André de Mattos Ferraz

unread,
May 12, 2015, 8:15:50 AM5/12/15
to antlr-di...@googlegroups.com
How I deregister Listener INSIDE the listener? My errors list its in the listener.

Bence Erős

unread,
May 12, 2015, 9:43:01 AM5/12/15
to antlr-di...@googlegroups.com
something similar to the following:
in your custom error listener implementation:

@Override
public void syntaxError( Recognizer<?, ?> recognizer, Object offendingSymbol, int line,  int charPositionInLine, String msg,  RecognitionException e) {
if (++count > 100) {
   recognizer.removeErrorListener(this);
}
}



--
Bence Erős
CyclonePHP
core developer
Reply all
Reply to author
Forward
0 new messages