What are the ways to speed up parsing in Antlr4?

安稳与你 提交于 2020-08-19 05:34:08

问题


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)

来源:https://stackoverflow.com/questions/53653323/what-are-the-ways-to-speed-up-parsing-in-antlr4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!