Antlr4 performance issue due to non greedy grammar

20 views
Skip to first unread message

tanuja dubal

unread,
Nov 18, 2016, 4:34:00 AM11/18/16
to antlr-discussion
Hi I have below grammar to match all character except '['.
any_Character:~'['+;  
printStatement:Any_Character+;
codeStatement:  '[' .+ END

This grammar to split the statement between printstatement and code statement, where code statement starts with '['. If I use this grammar then it will take more than 5 mins for parsing of 1000LOC.
Please suggest the solution to improve the performance.

Jim Idle

unread,
Nov 18, 2016, 5:24:13 AM11/18/16
to antlr-discussion
You need a Lexer rule nit a parser rule. Lexer rules start with UPPER case. However this rule will continue pretty much everything so you probably need lexer modes. 





--
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.
Reply all
Reply to author
Forward
0 new messages