Is there any good ways to improve the parser's performance generated using antlr4?

旧时模样 提交于 2019-12-11 16:28:00

问题


I have tried a few days to fix my grammar file(uniformSQL.g4) in order to improve the parser performance but still failed. The parser cost 4000+ ms to parser through the SQL case. And I also tried to use SLL(*) strategy, it is fast but come out a lot of mismatch cases.

So I wonder how to get the best performance when designing the grammar.

I also tried to lower the parse tree'height when designing grammar, but the speed turned out to be slower.

Looking forward to your suggestion,thanks.

This is my uniformSQL.g4 grammar file: https://github.com/ihainan/GBase-8a-MPP-Cluster-SQL-Parser/blob/master/src/main/java/cn/edu/bit/linc/sqlparser/antlr/uniformSQL.g4

And this is my SQL test case(280+ lines): https://github.com/ihainan/GBase-8a-MPP-Cluster-SQL-Parser/blob/master/test.sql

来源:https://stackoverflow.com/questions/32645754/is-there-any-good-ways-to-improve-the-parsers-performance-generated-using-antlr

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