Petitparser Prototype (DO NOT MERGE)#50
Draft
cesarParra wants to merge 9 commits into
Draft
Conversation
All 279 tests pass. New parser extracts declaration structure (types, members, modifiers, annotations, doc comments, signatures, type refs) and skips method/constructor/trigger bodies as balanced blocks. Model objects built directly via plain constructors, so the ANTLR-coupled TypeRefContext factory and fromAnnotationContext (and the tests covering them) are untouched. Known prototype gaps (not exercised by the repointed entry points): group comments (@START-Group / // @START-Group), interface method coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fixes: preserve whitespace inside annotation string-literal values (ANTLR concatenates tokens, strings are atomic); reproduce ANTLR array rawDeclaration quirk. tool/diff/diff.dart runs a 49-case corpus through both parsers and diffs the JSON output. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
petitparser composes the Apex and Apexdoc grammars over one character stream, so each doc comment is now parsed eagerly during the Apex parse and attached directly to the model — no lazy re-parse. Parsing runs in the per-declaration builders (once, on the winning alternative), not in the backtracking _prefix rule. A malformed doc is isolated into an error DocComment and never fails the Apex parse. Output byte-identical: 279/279 tests, 49/49 differential parity. Laziness dropped intentionally: JSON output serialises every docComment, so all docs are parsed regardless. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Apexdoc doc-comment parser is now a composable Parser<DocComment> (ApexdocPpParser.wrapped) that matches the /** ... */ wrapper in-grammar and is embedded directly in the Apex grammar's _prefix rule. Doc comments are parsed from the source stream in the same parse as the declarations — the Apex parser makes zero calls to a standalone doc parser. To keep the composed doc parser running once per declaration, _prefix was factored out of the member/type backtracking alternations and made isMember-agnostic (raw modifier keywords, classified later), so one parsed prefix serves both members and inner types. A cheap O(1) _docStart discriminator replaces the full-scan block-comment guard. Malformed docs are isolated into an error DocComment inside _content. Byte-identical output: 279/279 tests, 49/49 differential parity with ANTLR. Before this change: 6fa019c. See PETITPARSER_MIGRATION_LOG.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
tool/benchmark/benchmark.dart compares both full pipelines (source to JSON) over a real corpus (--dir). The ANTLR baseline is faithful: original ANTLR Apex parser + original two-stage ANTLR Apexdoc parser (both still on this branch). On a 2975-file Salesforce project: ~1.45x faster end to end, ~99.5% byte- identical JSON, 1/2975 parse failures. Fixes surfaced by running against real code (unit tests + 49-case differential still green): - inner virtual/abstract class modifier (isMember classification per site) - generic collection literals in field initializers (~99 of 100 failures) - space before type args in a type name - unquoted annotation element values - dotted generic type refs - apexdoc: throws/param name split at NAME token, keyword prefix matching See PETITPARSER_MIGRATION_LOG.md and tool/benchmark/README.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Orients a new agent: what the POC proved, benchmark + correctness results, tradeoffs (win/lose), test-coverage gaps to fill in the real work, the path to delete ANTLR, commit map, and reproduction commands. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.