mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
[PR #917] [MERGED] Replace ANTLR with hand-rolled parser #806
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?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/917
Author: @stackoverflow
Created: 1/29/2025
Status: ✅ Merged
Merged: 2/12/2025
Merged by: @stackoverflow
Base:
main← Head:new-parser📝 Commits (10+)
f37a904Start new parser724219aParserComparisonTestinherits fromParserComparisonTestInterface(#1)d1fc7b9Start parser visitorb1be0beSpotless apply and rebase main6f5520eAssert thatcomparedoesn't throw, and annotate the path withas(#3)05c147aCollect all test failures usingSoftAssertions(#4)e1fc451Fix bug in parser and lexer0afd454Fix bug in operator resolution95234f8Add support for legacy syntax4e02b30Change spans to be faster📊 Changes
197 files changed (+11714 additions, -3310 deletions)
View changed files
📝
.gitignore(+1 -0)📝
DEVELOPMENT.adoc(+2 -8)📝
THIRD-PARTY-NOTICES.txt(+21 -32)📝
bench/bench.gradle.kts(+1 -3)📝
bench/gradle.lockfile(+0 -1)📝
bench/src/jmh/java/org/pkl/core/parser/ParserBenchmark.java(+1 -1)📝
buildSrc/src/main/kotlin/pklFatJar.gradle.kts(+0 -1)📝
docs/modules/language-reference/pages/index.adoc(+0 -6)📝
docs/src/test/kotlin/DocSnippetTests.kt(+7 -8)📝
pkl-cli/gradle.lockfile(+0 -1)📝
pkl-cli/pkl-cli.gradle.kts(+0 -3)📝
pkl-cli/src/main/java/org/pkl/cli/svm/PolyglotContextImplTarget.java(+4 -4)📝
pkl-codegen-java/gradle.lockfile(+0 -1)📝
pkl-codegen-kotlin/gradle.lockfile(+0 -1)📝
pkl-commons-cli/gradle.lockfile(+0 -1)📝
pkl-config-java/gradle.lockfile(+0 -1)📝
pkl-config-kotlin/gradle.lockfile(+0 -1)📝
pkl-core/gradle.lockfile(+1 -1)📝
pkl-core/pkl-core.gradle.kts(+18 -19)📝
pkl-core/src/main/java/org/pkl/core/PcfRenderer.java(+1 -1)...and 80 more files
📄 Description
Fixes #906
Fixes #888
Fixes #927
Fixes #931
Fixes #932
Incompatible changes:
Reason: not requiring semicolons or newlines requires too much backtracking in the parser, degrading performance. Also both our IntelliJ plugin and the LSP don't allow this syntax and show an error.
Our current ANTLR parser is quite slow, and, depending on the codebase, can be the slowest part of running Pkl.
Some results from parsing all snippet tests in pkl-core showing ~100x performance improvement:
ANTLR elapsed: 7122ms (7.1s)
New parser elapsed: 78.73ms
This is still a draft, many tests are still failing and repl parsing is still using the old parser.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.