mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Replace ANTLR with new parser #265
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bioball on GitHub (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:basein 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.
@sgammon commented on GitHub (Jan 28, 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
jpackageandjlinktargets@bioball commented on GitHub (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 commented on GitHub (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.