What are the ways to speed up parsing in Antlr4?
Asked Answered
D

0

5

I have some doubts regarding the performance of Antlr4.

  1. I am currently using Python with Antlr4. It is terribly slow compared to Java (Verified using Antlr4 IntelliJ plugin). Since I need to work with bigger codes for parsing, I am planning to switch to a language which will be the fastest with Antlr (Eg: Java, C or Python). Any suggestions?
  2. Any tips on optimizing the Antlr grammar for faster parsing (I am trying some online resources)
  3. If I continue with Python itself, what are the best ways to speed up parsing? (Note: There is a suggestion in this link to use the antlr4 available in https://github.com/antlr/antlr4/pull/1010 for speed up). Has anybody tried it?

UPDATE

  1. Using Antlr 4.7.1 from the github repo helped me in speeding up the parsing process in Python. (The parsing which took more than 3 hours and still unfinished with Antlr 4.5 which came with Ubuntu 16.04 got completed in 25 min or so when I used Antlr 4.7.1 from github repo)
Dactylo answered 6/12, 2018 at 14:13 Comment(3)
Which ANTLR version? If ANTLR 3, do you use any predicates / backtracking, or just plain LL(*) grammar? The former may lead to exponential complexity if used in a bad place, the latter should have linear complexity.Gerhard
I am using Antlr4. I use +, ? etc. not only *. What does predicates and backtracking mean?Dactylo
I'm not too familiar with v4, hopefully someone else will chime in. I believe predicates are no longer used in v4, but there might be some pitfalls in how v4 resolves non-LL decisions.Gerhard

© 2022 - 2024 — McMap. All rights reserved.