Skip to content

解析器

🌐 Parser

这已经准备好生产了。

🌐 This is production ready.

特性

🌐 Features

安装

🌐 Installation

Node.js

Rust

使用总的箱子 oxc 或单独的 oxc_astoxc_解析器 箱子。

🌐 Use the umbrella crate oxc or the individual oxc_ast and oxc_parser crates.

可以在这里找到 Rust 使用示例。

🌐 Rust usage example can be found here.

打印

🌐 Print

解析和转换后,你可以打印代码。

🌐 After parsing and transforming, you can print code.

这是一个直接使用 esrap 的例子 parse 倒过来!)

🌐 Here's a direct example using esrap (parse in reverse!):

js
import { print } from "esrap";
import ts from "esrap/languages/ts";
import { parseSync } from "oxc-parser";

const { program } = parseSync("test.js", 'alert("hello oxc & esrap");');
const { code } = print(program, ts());

console.log(code); // alert("hello oxc & esrap");

INFO

今天,注释不会被打印。它将通过 oxc-parser #13285 获得支持。