Consolidate the parsetree printers
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Refactoring
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- ocaml
- Ambito
- compilers
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- OCaml
- Stelle
- 7.5k
- Fork
- 484
- Merge medio
- 20h 27m
- PR unite (30g)
- 120
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rescript-lang/rescript
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
rescript-lang/rescript#8833 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
rewatch watch on Linux stops watching a source folder when an overlapping recursive source folder is removed from rescript.jsonForse già presa @cknitt l’ha presa 1 giorno fa. Aperta
Difficoltà 4/5 1-2 giorni Idoneità per principianti 35/100
rescript-lang/rescript#8825 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
rescript-lang/rescript#8806 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 Mezza giornata Idoneità per principianti 58/100
rescript-lang/rescript#8757 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 40/100
rescript-lang/rescript#8753 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rescript-lang/rescript
Issue simili
-
llvm.memcpy with destination align but no source align asserts "Missed Source alignment!"Forse già presa @pvelesko l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
KhronosGroup/SPIRV-LLVM-Translator#4093 ·
I maintainer di solito rispondono entro 2 giorni
-
UB: (int) cast of a user double outside int range in dispatch / vm_index_is_int / flat_index_atApertaarea:runtime-vm
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
InauguralSystems/EigenScript#1748 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
leanprover/lean4#15677 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno