Separate parser token inspection from consumption - #8633
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fb9db09a7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -1,5 +1,5 @@ | |||
| @val | |||
| external defaults: {x: int} = "defaults" | |||
| external defaults: {"x": int} = "defaults" | |||
There was a problem hiding this comment.
These fixtures previously passed because speculative lookahead left error reporting disabled. Quoting the fields makes these non-function external types valid while preserving the object-type AST the old parser produced.
|
|
||
|
|
||
| Syntax error! | ||
| syntax_tests/data/parsing/errors/typexpr/typeConstructorArgs.res:9:16 |
There was a problem hiding this comment.
Line 9 was already invalid, but this diagnostic was previously missing. The parser now reports the invalid opening parenthesis separately from the preceding line's error and suggests option<node<int>>.
| type nonrec 'a t = private 'a Belt.Map.t | ||
| type nonrec t = option | ||
| ;;node < (int >> ([%rescript.exprhole ])) | ||
| type nonrec t = int node option |
There was a problem hiding this comment.
The extra < is still reported as an error. Previously, << was read as a shift operator, so recovery split the type declaration into option and a malformed expression. Recovery now preserves the type structure as option<node<int>>.
…-parser-token-cursor Signed-off-by: mununki <woonki.moon@gmail.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #8633 +/- ##
==========================================
+ Coverage 77.58% 77.91% +0.33%
==========================================
Files 475 477 +2
Lines 64051 64609 +558
==========================================
+ Hits 49693 50343 +650
+ Misses 14358 14266 -92
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-8633 |
|
/codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
rescript/tests/syntax_benchmarks/benchmark.ml
Lines 276 to 278 in 6b03ec6
When --parse-manifest contains an empty JSON object, benchmarks and the flattened sequence are empty, so this callback never runs and the unconditional closing bracket produces only \n]. That is invalid JSON and breaks automation consuming the benchmark output; print [ independently of the first result or serialize the completed result list.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Resolves: #8629
This PR separates token inspection from consumption, simplifying parser state management and allowing Diamond mode and the separate
prev_end_posfield to be removed.Correct rollback also uncovered invalid fixtures that previously passed because diagnostics were suppressed. Local benchmarks show roughly 5% lower parsing time and 2.9% less memory allocated.
Previously,
makescanned the first token immediately, andnextscanned its successor. Inspecting the following token required temporarily advancing the parser throughlookahead:Now,
makedoes not scan tokens.peekandpeek2read and cache tokens without advancing the consumed position.nextconsumes the current token without scanning its successor:Main changes:
Parser.position.Parsing time change compared with pre-refactor
master(5357fe4ac), where negative means faster:Measured locally with 500 paired runs per input and mode. Memory allocated for the combined real sources decreased by 2.92% in both modes. Measurements cover parsing only, excluding type checking, code generation, and formatted output.
Validation:
make test,make test-syntax-roundtrip, and added cursor/recovery regression coverage.