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

Closed
bioball opened this issue Jan 24, 2025 · 3 comments · Fixed by #917
Closed

Replace ANTLR with new parser #906

bioball opened this issue Jan 24, 2025 · 3 comments · Fixed by #917
Milestone

Comments

@bioball
Copy link
Member

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
@bioball bioball moved this to In progress in Pkl Roadmap Jan 27, 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
Member 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.

@driverkt
Copy link

driverkt commented Feb 6, 2025

Just an observer, but would it be worth considering javacc? There isn't a list of requirements here, per se.

Update: Looks like work has already begun on a custom parser. You may disregard this suggestion.

@github-project-automation github-project-automation bot moved this from In progress to Done in Pkl Roadmap Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants