Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/antlr-runtime-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ env:
jobs:
runtime-testsuite:
name: Runtime Testsuite
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm
timeout-minutes: 90
concurrency:
group: runtime-testsuite-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
uses: actions/checkout@v6
with:
persist-credentials: false

Expand All @@ -34,9 +37,9 @@ jobs:
rustup default stable

- name: Install Java
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
uses: actions/setup-java@v5
with:
distribution: temurin
distribution: graalvm
java-version: "21"

- name: Prepare ANTLR runtime testsuite
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
uses: actions/checkout@v6
with:
persist-credentials: false

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cpd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:
cancel-in-progress: true

env:
PMD_VERSION: 7.20.0
PMD_VERSION: 7.24.0
CPD_TOKENS: "100"
COMMENT_MARKER: <!-- cpd-report -->

Expand All @@ -29,7 +29,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
Expand All @@ -52,7 +52,7 @@ jobs:

- name: Setup Java
if: steps.changed.outputs.count != '0'
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/kotlin-parity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
uses: actions/checkout@v6
with:
persist-credentials: false

Expand All @@ -39,13 +39,13 @@ jobs:
rustup default stable

- name: Install Java
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "21"

- name: Setup Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
uses: actions/setup-python@v6
with:
python-version: "3.12"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
uses: actions/checkout@v6
with:
persist-credentials: false

Expand All @@ -34,7 +34,7 @@ jobs:

- name: Authenticate with crates.io
id: auth
uses: rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec # v1
uses: rust-lang/crates-io-auth-action@v1.0.4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pin publish workflow actions to immutable SHAs

This change replaces a previously SHA-pinned action with a mutable tag in the publish pipeline, which runs with crates.io publishing privileges. In .github/workflows/publish.yml, using @v1.0.4 (and similarly @v6 elsewhere in this commit) allows upstream retags or compromised releases to change executed code without any change in this repository, undermining reproducibility and increasing supply-chain risk for releases. Keep these uses: entries pinned to full commit SHAs (with version comments) as before.

Useful? React with 👍 / 👎.


- name: Publish to crates.io
run: cargo publish --locked
Expand Down
86 changes: 86 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Development notes

## Kotlin parser parity perf benchmark

Reproduces the timings tracked in GitHub issue #4 against the Kotlin grammar from `antlr/grammars-v4`.

### One-time setup (fresh checkout)

```bash
# 1. ANTLR jar (any path; pin v4.13.2)
mkdir -p /tmp/antlr-cleanroom/tools
curl -fLo /tmp/antlr-cleanroom/tools/antlr-4.13.2-complete.jar \
https://www.antlr.org/download/antlr-4.13.2-complete.jar

# 2. grammars-v4 checkout (sparse, just the kotlin grammar)
mkdir -p /tmp/antlr-cleanroom/grammars-v4
git -C /tmp/antlr-cleanroom/grammars-v4 init -q
git -C /tmp/antlr-cleanroom/grammars-v4 remote add origin https://github.com/antlr/grammars-v4.git
git -C /tmp/antlr-cleanroom/grammars-v4 sparse-checkout init --cone
git -C /tmp/antlr-cleanroom/grammars-v4 sparse-checkout set kotlin/kotlin
git -C /tmp/antlr-cleanroom/grammars-v4 fetch --depth 1 origin 284602b3f23ca54dc30778204ab7ae9e969145e9
git -C /tmp/antlr-cleanroom/grammars-v4 checkout FETCH_HEAD
```

### Run the parity smoke + dumper build

```bash
tests/kotlin-parity/run.sh \
--antlr-jar /tmp/antlr-cleanroom/tools/antlr-4.13.2-complete.jar \
--grammars-v4 /tmp/antlr-cleanroom/grammars-v4
```

That regenerates the Rust parser from the Kotlin grammar `.interp`, builds `tests/kotlin-parity/dumper`, and asserts the parse trees match `antlr4-python3-runtime` byte-for-byte.

### Measure parse-only timings

The dumper has a built-in parse-only stopwatch so process startup (~10 ms) is excluded:

```bash
DUMPER=tests/kotlin-parity/dumper/target/release/kotlin-parity-dumper
for snippet in tests/kotlin-parity/snippets/*.kt; do
echo "=== $(basename "$snippet") ==="
"$DUMPER" --input "$snippet" --output /tmp/dump.txt --iters 5 --time
done
```

`--iters N` repeats parse N times within one process; `--time` prints `min`/`avg` to stderr. CI baseline numbers from issue #4: Python `antlr4-python3-runtime` parse-only ≈ 0.9–14.9 ms (`01-nested-types.kt`) and 226–317 ms (`02-dataframe.kt`).

## ANTLR runtime testsuite (357 cases)

Validates the Rust runtime against ANTLR's upstream conformance descriptors.

### One-time setup

```bash
git clone --depth 1 https://github.com/antlr/antlr4 /tmp/antlr-cleanroom/antlr4-upstream
```

The harness reads `antlr4-upstream/runtime-testsuite` and the same ANTLR jar fetched above.

### Run the full sweep

```bash
cargo run --release --quiet --bin antlr4-runtime-testsuite
```

Defaults to `ANTLR4_JAR=/tmp/antlr-cleanroom/tools/antlr-4.13.2-complete.jar` and `ANTLR4_RUNTIME_TESTSUITE=/tmp/antlr-cleanroom/antlr4-upstream/runtime-testsuite`. Override with `--antlr-jar`/`--descriptors` or env vars. Expected outcome: `summary: 357 passed, 0 failed, 0 skipped, 357 run`. Wall-clock ≈ 10–15 minutes on Apple Silicon, ≈ 30 minutes on the GitHub Linux runner.

### Run a subset while iterating

```bash
# One descriptor:
cargo run --release --quiet --bin antlr4-runtime-testsuite -- --case LexerExec/KeywordID

# One group (e.g. while debugging left-recursion):
cargo run --release --quiet --bin antlr4-runtime-testsuite -- --group LeftRecursion --limit 20

# Keep the per-case temp crates for inspection:
cargo run --release --quiet --bin antlr4-runtime-testsuite -- --case ParserErrors/SingleSetInsertion --keep
```

Per-case scratch crates land under `target/antlr-runtime-testsuite/<case>/`. Stale dirs from a killed run can fail a re-run with `Os { code: 66, ... DirectoryNotEmpty }` — `rm -rf target/antlr-runtime-testsuite/*` to recover.

## CI parity

CI runs `cargo clippy --locked --all-targets --all-features -- -D warnings`, so reproduce locally with the same flags before pushing — `clippy::excessive-nesting`, `clippy::disallowed_types`, and similar nursery/pedantic lints all promote to errors there.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
[package]
name = "antlr-rust-runtime"
version = "0.2.0"
version = "0.3.0"
edition = "2024"
rust-version = "1.95"
description = "Clean-room Rust runtime and target support for ANTLR v4 generated parsers"
description = "High performance Rust runtime and target support for ANTLR v4 generated parsers"
repository = "https://github.com/ophidiarium/antlr-rust-runtime"
homepage = "https://github.com/ophidiarium/antlr-rust-runtime"
documentation = "https://docs.rs/antlr-rust-runtime"
readme = "README.md"
license = "BSD-3-Clause"
keywords = ["antlr", "antlr4", "parser", "lexer", "runtime"]
categories = ["parser-implementations", "development-tools"]
keywords = [

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reduce package keywords to crates.io maximum of five

This manifest now declares 9 package.keywords, but crates.io accepts at most 5 keywords per crate, so cargo publish/the publish workflow will fail during metadata validation before release. Because this commit also bumps the version to 0.3.0 and updates publishing automation, leaving the keyword count above the limit blocks shipping that release.

Useful? React with 👍 / 👎.

"antlr",
"antlr4",
"parser",
"lexer",
"runtime",
"antlr4-runtime",
"parser-generator",
"parser-combinator",
"antlr4rust",
]
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
categories = ["parser-implementations", "development-tools", "parsing"]

[lib]
name = "antlr4_runtime"
Expand Down
Loading