Crates.io | fastexpr-rs |
lib.rs | fastexpr-rs |
version | 1.0.2 |
source | src |
created_at | 2024-07-30 18:00:24.699619 |
updated_at | 2024-07-30 18:12:37.833013 |
description | A tiny, fast Javascript expression parser |
homepage | |
repository | https://github.com/anpete/fastexpr.rs |
max_upload_size | |
id | 1320171 |
size | 109,389 |
A fast, tiny, minimal dependency JavaScript expression parser, written in Rust.
esprima
style AST.Usage:
let result = parse("(s) => `hello from ${s}!`");
match result {
Ok(expr) => {
println!("{:#?}", expr);
}
Err(err) => {
println!("{:#?}", err);
}
}
which produces:
ArrowFunction {
params: [
Identifier {
token: Identifier(
"s",
),
},
],
body: TemplateLiteral {
quasis: [
TemplateString {
token: String(
"hello from ",
),
tail: false,
},
TemplateString {
token: String(
"!",
),
tail: true,
},
],
expressions: [
Identifier {
token: Identifier(
"s",
),
},
],
},
}