Open Boshen opened 1 year ago
Something related: esbuild marks used features in the parser https://github.com/evanw/esbuild/blob/427ee6054401042f509c2b3a2d31bc6eebca655c/internal/js_parser/js_parser_lower.go#L42
hi @Boshen can I take on this issue?
hi @Boshen can I take on this issue?
Have fun! Please be aware of our rules https://oxc-project.github.io/docs/contribute/rules.html and sure that you submit smaller PRs!
hi @Boshen Is it possible to do this just by checking(handwriting rules) the AST parsed by oxc_parser for new syntax for a particular version here?
And Do I still need to use the oxc_transformer package?
hi @Boshen Is it possible to do this just by checking(handwriting rules) the AST parsed by oxc_parser for new syntax for a particular version here?
And Do I still need to use the oxc_transformer package?
It should be similar to how the linter is written, see
I see, but do I need to write the syntax matching rules by hand, or has someone else already done that part and I can just bring them in?
Like this?
AstKind::VariableDeclaration(stmt)
if ecma_version < 6
&& (stmt.kind == VariableDeclarationKind::Const
|| stmt.kind == VariableDeclarationKind::Let) =>
{
The let declaration is not yet supported in the es5 environment.
// errors...;
}```
I see, but do I need to write the syntax matching rules by hand, or has someone else already done that part and I can just bring them in?
Like this?
AstKind::VariableDeclaration(stmt) if ecma_version < 6 && (stmt.kind == VariableDeclarationKind::Const || stmt.kind == VariableDeclarationKind::Let) => { The let declaration is not yet supported in the es5 environment. // errors...; }```
do I need to write the syntax matching rules by hand
Yes, you need to write them by hand. All the tests from https://github.com/yowainwright/es-check/tree/main/tests has to be passed.
I'm going to move this to another repository, in private for some experimentation.
我将把它转移到另一个存储库,私下进行一些实验。
ok
We need this for the transformer after finishing Milestone 1 @Dunqing
Ok this isn't the right direction, closing again.
Reopen again because I need this to validate the transformer.
See https://github.com/yowainwright/es-check
Usecases:
oxc_transformer
is correctApproach:
oxc_parser
parses esnext, which means we are not going to add aecmaVersion
option to the parser. Instead we are just going to add a special linter. The the code setup can be copied from https://github.com/web-infra-dev/oxc/blob/main/crates/oxc_linter/examples/linter.rs