--
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.
ws: (WS | NEW_LINE)*;
mandatory_ws: (WS | NEW_LINE)+;
Before trying the extraordinary, you may wish to optimize your grammar first. Much of your performance problem may be due to a too literal translation of the v3 grammar to v4.
Would probably be helpful to start by looking at the 'standard' v4 LESS grammar that is in the github repository. (https://github.com/antlr/grammars-v4/tree/master/less)
Couple of comments on your existing grammar: you have at least one parser rule -- the term rule -- that starts with a predicate. That can have a substantial performance impact on lookahead.
The two parser whitespace rules conflict - don't think the second will ever be reached.
ws: (WS | NEW_LINE)*;
mandatory_ws: (WS | NEW_LINE)+;
For LESS, whitespace should probably not be significant in the parser. If not significant, and dropped in the lexer, looks like you can reduce the number of tokens going to the parser by 10 to 25%
declaration: | |
property ( | ws PLUS ( | ws UNDERSCORE ) ) ws COLON (ws expression_full)? | |
; |
Finally, the individual letter fragments could be reduced to a simple range - given that random whitespace is not allowed in keywords. Also, it looks like you are missing a 'u' in the unicode forms. V4 handles unicode better/different from how V3 does.
On Monday, June 8, 2015 at 2:00:35 AM UTC-7, Mária Jurčovičová (Meri) wrote:Hi all,I ported antlr3 project into antlr4 and the result turned up too slow due to parser warm-up. Compiling the first file in unit tests can take over 2 seconds. Compiling second file still takes longer then in antlr3, but the performance loss is acceptable.Use case: My project will run either from command line or as part of build process and is unlikely to compile more files at the same time. I am fine with antlr4 version being slightly slower, but two seconds penalty for every run matters.What I did so far: I tried to persist `_sharedContextCache` into file and load it again before first start. It did not affected the speed. It is building of `_decisionToDFA` DFA array that takes all that time.Persisting DFA is more work, as it has more complicated object structure.My questions are:* Is there something else I can do to speed up parser warm-up?* If not, is DFA class structure stable? Does it make sense to spend time trying to persist/load that too?* Would there be interest in patch if I made DFA persistend/load and warm up would turned up faster?In case it is relevant, my grammars can be found here:With Regards,Maria Jurcovicova
On Mon, Jun 15, 2015 at 3:16 PM, Gerald Rosenberg <gbrose...@gmail.com> wrote:
The two parser whitespace rules conflict - don't think the second will ever be reached.Theses are parser rules, not lexer rules, so they will be called, or not called.
ws: (WS | NEW_LINE)*;
mandatory_ws: (WS | NEW_LINE)+;
--
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/8u0Hd0PqwlQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to antlr-discussi...@googlegroups.com.