Consolidate the parsetree printers
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- リファクタリング
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- ocaml
- 領域
- compilers
調査の方向性
Start with compiler/ml/printast.ml, compiler/syntax/src/res_ast_debugger.ml, compiler/ml/pprintast.ml, and the roundtrip test in scripts/test_syntax.sh. Trace the printer call sites and parser fixture snapshots named in the issue, then check how bsc -dsource handles PPX and builtin rewrites. Done means removing the redundant printers and comparisons while keeping the listed print modes, fixtures, and tests working.
索引モデルが issue の本文から書いたものです。
説明
The compiler has three printers for the parsetree, and each one matches over every node. Every new node (recently Pexp_dict, Ppat_dict, Pexp_ternary, Pmod_await, Ppat_variant_spread) has to be added to all three, on top of the parsetree, the v0 mappers and the formatter.
| Printer | Size | Output | Used by |
|---|---|---|---|
compiler/ml/printast.ml |
827 lines | tree with source locations | bsc -dparsetree, res_parser -print ast, the playground's parsetree view, ounit_parser_recovery_tests |
Sexp_ast in compiler/syntax/src/res_ast_debugger.ml |
~1,040 lines | S-expression without locations, except the offsets of explicit braces (see below) | res_parser -print sexp, used by the formatter roundtrip test |
compiler/ml/pprintast.ml |
1,471 lines | OCaml syntax | res_parser -print ml (expected output for the parser fixtures in tests/syntax_tests/data/parsing), bsc -dsource, a few ounit tests |
Sexp_ast is redundant. The roundtrip test in scripts/test_syntax.sh formats a file twice and checks two things:
- the two formatted texts are equal;
- the ASTs parsed from them are equal (as sexp).
The parser is deterministic, so the AST check holds whenever the text check does. The original file's AST can't usefully be compared with the formatted one, because the formatter changes the AST on purpose, e.g. it removes braces in switch cases.
Sexp_ast prints no locations, with one exception: since #8678 it prints the character offsets of explicit braces (braces_loc of Pexp_braces). That was not intended and nothing depends on it. It should not be carried into any other printer or test.
Pprintast is a leftover from OCaml. ReScript has no other use for printing its AST as OCaml code.
Proposal
- Remove
Sexp_ast,-print sexpand the redundant AST comparison from the roundtrip test. - Snapshot the parser fixtures with
Printastinstead of-print ml. - Make
bsc -dsourceprint the parsetree after PPX and builtin rewrites with the ReScript printer instead of OCaml syntax. - Move
Pprintast.string_of_int_as_char(used byprintlambda.mlandparmatch.ml), then removePprintastandres_driver_ml_printer.ml.
That removes about 2,500 lines, and new parsetree nodes need one printer case instead of three. -print comments and -print doc in res_ast_debugger.ml, Printtyped and Printlambda are not affected.
Compatibility: res_parser isn't shipped in the npm packages, so -print sexp and -print ml are internal. bsc -dsource is a debugging flag. Its output switches from OCaml-like to ReScript syntax.
- 主要言語
- OCaml
- スター
- 7.5k
- フォーク
- 484
- 平均マージ
- 19時間 20分
- マージ済み PR(30日)
- 96
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rescript-lang/rescript のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
rescript-lang/rescript#8806 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 半日 初心者へのやさしさ 58/100
rescript-lang/rescript#8757 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 40/100
rescript-lang/rescript#8753 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 22/100
rescript-lang/rescript#8733 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
rescript-lang/rescript#8727 ·
メンテナーはふだん 1 日以内に返信
rescript-lang/rescript の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
flang:semantics
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
llvm/llvm-project#231051 ·
メンテナーはふだん 1 日以内に返信
-
bug derived types format I/O medium priority semantics
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
webgpu-tools/wesl-rs#329 ·
メンテナーはふだん 1 日以内に返信