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

Replace ANTLR with new parser #906

Open
bioball opened this issue Jan 24, 2025 · 2 comments
Open

Replace ANTLR with new parser #906

bioball opened this issue Jan 24, 2025 · 2 comments
Milestone

Comments

@bioball
Copy link
Contributor

bioball commented Jan 24, 2025

The current parser is quite slow. On my machine (macOS on M1 Max), it takes almost half a second to parse pkl:base in Java.

In some large projects, about 40% of the wall clock time is taken by ANTLR parsing.

It's time to replace it with a hand-rolled parser.

@bioball bioball added this to the Pkl 0.28 milestone Jan 24, 2025
@sgammon
Copy link
Contributor

sgammon commented Jan 27, 2025

This will be big for a few other reasons too:

Sometimes ANTLR is shaded with Truffle builds. The version of ANTLR they provide conflicts with the fork Pkl prefers; in particular, the fork uses ANTLR's gencode v3, and GVM ships a version using v4. In particular, Sulong (GraalVM's LLVM interpreter) depends on the shaded copy.

Additionally, this is one non-modular dependency eliminated on the way toward true JPMS support, which would enable shipping a Pkl jmod and usage in jpackage and jlink targets

@bioball
Copy link
Contributor Author

bioball commented Jan 28, 2025

ANTLR also generates grammars that can only be used with that version of ANTLR (unless this has changed recently).

If the runtime library differs from the version used to generate your grammar, you have a conflict. That's partially why ANTLR gets shaded so often.

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