Skip to content

Move the compiler's parser driver out of the parser library - #9362

Merged
cknitt merged 1 commit into
ast-compiler-only-helpersfrom
parser-driver-to-common
Nov 21, 2026
Merged

cknitt merged 1 commit into
ast-compiler-only-helpersfrom
parser-driver-to-common

Conversation

@cknitt

@cknitt cknitt commented Nov 20, 2026

Copy link
Copy Markdown
Member

Stacked on #9360. The parser library (syntax) printed syntax errors through the compiler's error reporting and read files through the build's file store. This PR moves that compiler side into compiler/common, so the parser library only parses.

  • A new module, Syntax_driver, holds the compiler's entry points parse_implementation and parse_interface, Already_reported, the report printer print_report, and a parsing engine that reads through Ext_io (the build's file store).
  • Res_multi_printer moves to compiler/common as well.
  • Res_diagnostics.print_report becomes Syntax_driver.print_report. The messages, with their hints for [| and |>, stay in the parser as a pure Res_diagnostics.explain_in_source.
  • Res_driver.make_parsing_engine ~load_file builds a parsing engine with a given file reader. Res_driver.parsing_engine, used by editor analysis and rescript-tools, reads from disk. Its string_of_diagnostics field is gone; the only user was the syntax tests.
  • The res_parser CLI keeps its own default print engine, which writes to stdout.
  • rescript-tools and the res_parser CLI now depend on common.

Error output does not change: the syntax, super-errors and analysis snapshots are unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QchYQ7itFLVLUmZ368okjH

@cknitt
cknitt added this pull request to stack #9361 November 20, 2026 21:29
@cknitt cknitt added the changelog:skip No release notes needed label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Changelog

No changelog entry.

Semantic Diff

1 commit · Full page

Move the compiler's parser driver out of the parser library

0ecb8d7 · cknitt + Claude · Nov 20, 2026, 21:28 UTC

The parser library printed syntax errors through the compiler's error reporting and read files through the build's file store. That part now lives in a new compiler module, Syntax_driver in compiler/common: the compiler's parse_implementation and parse_interface, Already_reported, the report printer and a parsing engine that reads through Ext_io. Res_multi_printer moves there too, and the res_parser CLI keeps its own print engine.

The parser library keeps the parse results and a pure explain_in_source for the messages. Res_driver.make_parsing_engine takes the file reader, and Res_driver.parsing_engine reads from disk.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

✅ Compiler benchmarks

Allocated words

In total: 636,535,496 → 636,545,318 (±0.00%).

Generated projects: 629,007,679 → 629,006,949 (±0.00%).

None of the 265 benchmarks changed by 0.1% or more.

Instructions

In total: 9,222,840,900 → 9,222,439,116 (±0.00%).

None of the 33 benchmarks changed by 0.1% or more.

Output size

In total: 25,969,547 → 25,969,539 (±0.00%).

None of the 13 benchmarks changed by 0.1% or more.

Pull request 0ecb8d7 compared with base 8e8c22d in this run.

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.22642% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.19%. Comparing base (36af448) to head (0ecb8d7).

Files with missing lines Patch % Lines
compiler/common/res_multi_printer.ml 50.00% 2 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                     @@
##           ast-compiler-only-helpers    #9362   +/-   ##
==========================================================
  Coverage                      82.19%   82.19%           
==========================================================
  Files                            460      461    +1     
  Lines                          65744    65749    +5     
==========================================================
+ Hits                           54036    54043    +7     
+ Misses                         11708    11706    -2     
Files with missing lines Coverage Δ
compiler/bsc/rescript_compiler_driver.ml 80.91% <100.00%> (ø)
compiler/common/syntax_driver.ml 100.00% <100.00%> (ø)
compiler/syntax/cli/res_cli.ml 78.18% <100.00%> (+2.18%) ⬆️
compiler/syntax/src/res_diagnostics.ml 75.90% <100.00%> (-2.60%) ⬇️
compiler/syntax/src/res_driver.ml 97.56% <100.00%> (+4.57%) ⬆️
tests/ounit_tests/ounit_compiler_request_tests.ml 97.07% <ø> (ø)
tools/src/tools.ml 80.78% <100.00%> (ø)
compiler/common/res_multi_printer.ml 75.00% <50.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@9362

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@9362

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@9362

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@9362

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@9362

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@9362

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@9362

commit: 0ecb8d7

@cknitt

cknitt commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T07:55:31.650602Z 0ecb8d7 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 5c9eab7161

ℹ️ 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".

The parser library printed syntax errors through the compiler's error
reporting and read files through the build's file store. That part now lives
in a new compiler module, Syntax_driver in compiler/common: the compiler's
parse_implementation and parse_interface, Already_reported, the report
printer and a parsing engine that reads through Ext_io. Res_multi_printer
moves there too, and the res_parser CLI keeps its own print engine.

The parser library keeps the parse results and a pure explain_in_source for
the messages. Res_driver.make_parsing_engine takes the file reader, and
Res_driver.parsing_engine reads from disk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QchYQ7itFLVLUmZ368okjH
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the parser-driver-to-common branch from 5c9eab7 to 0ecb8d7 Compare November 21, 2026 07:26
@cknitt

cknitt commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 0ecb8d7079

ℹ️ 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".

@cknitt
cknitt marked this pull request as ready for review November 21, 2026 07:56
@cknitt
cknitt merged commit e2d909a into master Nov 21, 2026
22 checks passed
@cknitt
cknitt deleted the parser-driver-to-common branch November 21, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:skip No release notes needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants