Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANTLR hangs in this deep parse tree #377

Open
masonwheeler opened this issue Jul 25, 2022 · 2 comments
Open

ANTLR hangs in this deep parse tree #377

masonwheeler opened this issue Jul 25, 2022 · 2 comments

Comments

@masonwheeler
Copy link

Grammar file: https://github.com/uwol/proleap-vb6-parser/blob/master/src/main/antlr4/io/proleap/vb6/VisualBasic6.g4
Source file: https://github.com/smbx/smbx-legacy-source/blob/master/modNPC.bas

Attempting to parse this file with a C# parser generated off this grammar causes ANTLR to hang in what appears to be an infinite loop. The debugger says there's some very deep recursion going on deep within the bowels of ParserATNSimulator.AdaptivePredict. Memory usage remains constant during the hang.

It looks like the source file includes some extremely deep parse trees, such as the code following line 2400. This might be part of what's giving the parser trouble. Are there any known workaround for dealing with such issues?

@masonwheeler
Copy link
Author

After further investigation, this isn't an infinite loop afterall; it completed parsing the file in question after approximately four and a half minutes. (Where similar-sized files are usually finished in a matter of seconds.)

Any idea what's causing the parser's performance to degenerate so severely on this file?

@paulirwin
Copy link

I had a similar issue with the PostgreSQL parser from the official grammars repo: https://github.com/antlr/grammars-v4/tree/master/sql/postgresql

I left this building for over a day on my M1 Pro MacBook Pro and it never finished. I plan on attempting to use the original C# target soon to see if it finishes in a reasonable amount of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants