Replace the unmaintained OCaml Flow parser dependency
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Refatoração
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- ocaml
- Domínio
- compilers
Direção de pesquisa
Comece lendo a integração existente do parser Flow e as fontes previamente vendorizadas em compiler/js_parser. Defina a interface focada do parser em torno da validação de sintaxe, das localizações de erros, da validação de regexp, da aridade de funções, da classificação de literais e do tratamento de comentários; em seguida, adicione testes para os casos listados. O trabalho estará concluído quando ambas as implementações do parser puderem ser comparadas com o mesmo corpus e a dependência puder ser removida se a compatibilidade for suficiente.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Problem
ReScript depends on the unmaintained OCaml implementation of flow_parser to validate and classify JavaScript in %raw expressions.
Our fork supports ppxlib 0.36, which requires OCaml < 5.4. This blocks upgrades to OCaml 5.4 and 5.5. Updating the fork for each ppxlib release would only postpone the problem.
ReScript currently depends directly on Flow AST and parser types, although it only needs syntax validation, error locations, regexp validation, and classification of literals, functions and comment-only statements.
Possible solutions
1. Vendor the Flow parser
ReScript previously vendored these sources under compiler/js_parser.
We could restore the currently used parser sources and maintain them inside the repository. Ideally, we would commit the PPX-generated OCaml code so the parser no longer depends on ppxlib.
This is the lowest-risk solution and can preserve the existing direct Flow AST integration. However, it leaves ReScript responsible for roughly 33,000 lines of parser code whose JavaScript syntax support will no longer receive upstream updates.
2. Move to js_of_ocaml’s JavaScript parser
js_of_ocaml-compiler's Parse_js API provides maintained OCaml functions for parsing JavaScript expressions and programs.
For a safe migration, we should first introduce a small ReScript-owned parser interface backed by the existing Flow parser. This interface would expose only the operations ReScript needs and remove direct uses of Flow_ast, Parser_flow, Loc, and Parse_error from the rest of the compiler.
We should add focused tests for parsing, error locations, regexp validation, function arity, literal classification, leading comments and comment-only programs. The js_of_ocaml implementation could then be tested against the same corpus before switching.
js_of_ocaml maintains its parser to read JavaScript runtimes and user-provided stubs before linking and optimizing them with generated JavaScript. Its primary goal is therefore not to be a universal parser supporting every new TC39 feature immediately. Its syntax coverage, diagnostics, comment handling and classifications must be compared with the current Flow implementation.
A migration could be split into two independent changes:
- Introduce the internal parser abstraction backed by Flow Parser and strengthen test coverage.
- Implement the abstraction using js_of_ocaml, compare both implementations, and remove
flow_parserif compatibility is sufficient.
Decision
- Vendoring is the quickest and least disruptive solution, but makes ReScript the permanent owner of an unmaintained parser.
- Moving to js_of_ocaml requires more migration work, but offers a maintained long-term dependency with much less parser-specific coupling.
- Linguagem predominante
- OCaml
- Estrelas
- 7.5k
- Forks
- 485
- Merge médio
- 1d 2h
- PRs com merge (30d)
- 55
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de rescript-lang/rescript
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
rescript-lang/rescript#8659 · 2 comentários · 2 reações ·
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
rescript-lang/rescript#8647 ·
-
rescript-lang/rescript#8632 · 1 responsável ·
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 28/100
rescript-lang/rescript#8624 ·
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 30/100
rescript-lang/rescript#8596 · 2 comentários ·
Todas as issues de rescript-lang/rescript
Issues semelhantes
-
`String.Parser.chompUntilEndOr` leaves the column one short when it runs to the end past a newline Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
-
enhancement PyCDE
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
llvm:support
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
llvm/llvm-project#226296 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
abseil/abseil-cpp#2176 ·