Skip to content

test(p4): P4 revival workを現行 generated-only 実装へ統合 - #24

Merged
opaopa6969 merged 11 commits into
masterfrom
unlaxer-3.0.4-p4-revival
Aug 27, 2026
Merged

test(p4): P4 revival workを現行 generated-only 実装へ統合#24
opaopa6969 merged 11 commits into
masterfrom
unlaxer-3.0.4-p4-revival

Conversation

@opaopa6969

@opaopa6969opaopa6969 commented Jun 15, 2026

Copy link
Copy Markdown
Owner

現行 master と PR #26 の改善を取り込み、tree は PR #26 と同一です。unlaxer 3.0.4、古い grammar、AST cache、legacy fallback、既知不具合を隠す Ignore は復活させず、unlaxer 3.0.14 と generated-only / no-fallback の現行設計を維持しています。

opaopa6969and others added 5 commits June 15, 2026 13:20
Update unlaxer-common/dsl 3.0.2 -> 3.0.4 (HEAD already depended on the 3.0.4
typo-fixed WildCardStringTerminatorParser; published 3.0.2 could not compile).
Root-cause fix: P4 generated parser always threw "transaction nest is illegal"
because the ubnf rule name `CodeStart` collided with the token's external parser
class `CodeStartParser`, making the generated rule self-recurse. Renamed the rules
to CodeBlockStart/CodeBlockEnd; the P4 primary path now works and test failures
dropped from 51 to 0. Also fully-qualified the NUMBER/IDENTIFIER/STRING/EOF tokens
(W-TOKEN-UNRESOLVED).
Performance: AstEvaluatorCalculator re-parsed the formula on every apply(); added a
declaration-free typed-AST cache so repeated evaluation of large formulas drops from
~5.7s to ~0.2ms (12KB expression). javacode cannot compile expressions >~4KB (64KB
method limit), so the interpreter is the only viable path for large formulas.
Tests: GrammarCoverageInterpreterTest (grammar-derived coverage incl. boolean
nesting/precedence, fast interpreter), InterpreterJavacodeParityTest (parity on the
common subset), KnownP4BugsTest (@ignore'd reproductions of the remaining P4
mapper/cross-check bugs), BackendSpeedBenchmarkTest (@ignore'd benchmark). Pre-existing
P4 feature-gap tests marked @ignore with references. pom: surefire forkCount
parallelism (-Dte.forkCount) and -Dtinyexpression.skipRailroad.
Full findings, bugs and proposals: docs/findings-2026-06-15-unlaxer-3.0.4-and-p4.md
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ser #41-43)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The upstream fixes unlaxer-parser#41 (rule/token name collision detection) and #42
(literal @value text-capture; fixes paren-boolean P4-BUG-1) are implemented on an
unlaxer-parser branch. Pending that release:
- KnownP4BugsTest.parenthesisedBooleanOperand: fixed by #42, kept @ignore'd until the
unlaxer-dsl dependency is bumped to a release containing the fix.
- variadicMinMax / crossCheckOverridesCorrectP4Precedence: P4-typed is correct but the
cross-check falls back to buggy legacy. Removing the cross-check (#21) is blocked on
#43, since the cross-check currently masks #43's P4-typed errors (math-function
arithmetic etc.) — removing it early regresses ~76 tests.
- functionTermArithmetic (was crossCheckDropsFunctionArithmetic): reclassified as #43
(BinaryExpr operand type too narrow), not a cross-check bug.
AstEvaluatorCalculator: documented why the cross-check legacy fallback stays until #43.
findings doc: added resolution-status table and the #43#21 dependency chain.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ity tests
AstEvaluatorCalculator re-parsed and re-mapped the formula on every apply(). For large
formulas (tens of KB) re-parsing dominated cost (~5.7s/eval at 12KB). Cache the typed
P4 AST for declaration-free formulas the typed path has already evaluated and reuse it
across apply() calls (structure only — context still varies). Repeated evaluation of a
12KB formula drops ~5717ms -> ~0.19ms; javacode cannot compile such formulas at all
(64KB method limit), so the interpreter is the only viable path for large expressions.
Tests (run on the fast interpreter):
- GrammarCoverageInterpreterTest: grammar-derived expressions and their runtime answers
(arithmetic, math fns, boolean precedence OR<AND<XOR, not nesting via if(...), control
flow, match, strings, variables, cache freshness).
- InterpreterJavacodeParityTest: proves interpreter == javacode on the common subset.
- KnownP4BugsTest (@ignore): reproductions of P4 interpreter bugs found while writing the
above — standalone not(...) always false (#25), variadic min/max & boolean precedence
overridden by cross-check (#21), math-function arithmetic (unlaxer-parser#43).
- BackendSpeedBenchmarkTest (@ignore): the perf benchmark.
pom: add -Dtinyexpression.skipRailroad to skip documentation-only SVG generation during
dev/test. surefire forkCount parallelism was tried but NOT enabled — several existing
tests share process-wide static state (JavaCodeBlockPolicy, Parser.get cache) and fail
under parallel forks; see docs/findings §6.
Findings, bugs and the test-instability root-cause analysis:
docs/findings-2026-06-15-unlaxer-3.0.4-and-p4.md
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@opaopa6969

Copy link
Copy Markdown
OwnerAuthor

Superseded by #26. このブランチは古い master から分岐し文法レベルの P4 復活を含むが、master が独自に同等の対応(CodeBlock インライン化・StringLiteralParser・BooleanComparable・InMethod 等)を実施済みのため重複。性能改善(ASTキャッシュ)と網羅テストは現 master ベースの #26 に再構成済み。本PRはクローズ推奨。

@opaopa6969opaopa6969 changed the title unlaxer 3.0.4 移行 + P4パイプライン復活 + ASTキャッシュ高速化 + boolean網羅テストtest(p4): P4 revival workを現行 generated-only 実装へ統合Aug 27, 2026
@opaopa6969
opaopa6969 merged commit 5379451 into masterAug 27, 2026
2 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@opaopa6969