-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Milestone
Description
I'm using ANTLR-4.4 with a grammar file modified from sqlite.g4,and find some complex expressions cost too much time to parse.And then I found issue#192 .
That grammar file works fast with the antlr version I'm using now.But when I add some rules I used in my grammar file,it get slow down.
To make the issue simple,the grammar I use is just like this:
grammar expr;
expr: ID
| 'not' expr
| expr 'and' expr
| expr 'or' expr
| expr 'between' expr 'and' expr
;
ID: [a-zA-Z_][a-zA-Z_0-9]*;
WS: [ \t\n\r\f]+ -> skip;
ERROR: .;
and the sample file is just same like
not X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or
X1 and not X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12 or
not X1 and X2 and not X3 and not X4 and not X5 and not X6 and not X7 and not X8 and not X9 and not X10 and not X11 and not X12
I tried this with the antlr plugin in IDEA,just 3 lines of the expressions will make the parsing time unacceptable.