No Performance gain from Parser Predicates

37 views
Skip to first unread message

HmSebastianH

unread,
Nov 27, 2018, 8:03:29 AM11/27/18
to antlr-discussion
I am currently in the proccess of writing a rather large Grammar. Currently I am getting rather poor performance results because of a ambiguity.

In theory the ambiguity is easly solved by a predicate, but the predicate does not seem to be evaluated until after the decession is done.
Is this the expected behaviour or is there any dokumentation on when predicates are evaluated?

To test this I took affected rule and gave it a {false}? predicate, the performance  and the SLL_MaxLook where unaffected by this change, even thought the predicate never evaluates to true.
Removing the rule (by commenting it out) did lead to the expected performance improvement.

statement
 
: ifStatement
 
| {false}? functionStatement
 
| ...


Is there anyway I can get my desired performance improvement through a predicate? What would a possible alternative be?

Greetings,
Basti

Ivan Kochurkin

unread,
Nov 29, 2018, 10:44:38 AM11/29/18
to antlr-discussion
Try to move this predicate to the end of the rule:

statement
   : ifStatement
   | fundctionStatement {false}?
   | ...
Reply all
Reply to author
Forward
0 new messages