Crates.io | ezno-parser |
lib.rs | ezno-parser |
version | 0.1.7 |
created_at | 2023-02-25 18:09:19.693802+00 |
updated_at | 2024-11-13 19:51:15.396856+00 |
description | Parser and AST definitions for Ezno |
homepage | https://kaleidawave.github.io/posts/introducing-ezno/ |
repository | https://github.com/kaleidawave/ezno |
max_upload_size | |
id | 794477 |
size | 616,567 |
Contains "string to AST" parser, AST definitions, AST back to text/string form methods and hooks for traversing/visiting AST. Used in ezno-checker
and the Ezno toolchain.
use ezno_parser::{ASTNode, Expression};
fn main() {
let expressions = [
"4 + 2 * 5",
"4 * 2 + 5",
"4 * 2 * 5",
"console.log(4 * 2, t ? true : `Hi`) == 2 && 4 == 2",
];
for expression in expressions {
let expression = Expression::from_string(expression.to_owned(), Default::default());
println!("{expression:#?}");
}
}
Also checkout other parsers such as boa, biome, oxc and swc.
/tests
and /examples
folders)/tests
and /examples
folders for example usage)satisfies
and as
😑feature = "extras"
👀ezno-parser-visitable-derive
is a macro that automates/generates the visiting implementation)
etc (useful in if
etc) or (2) Whether the next token is const
etc and on the next lineToStringOptions { include_types: false, ..Default::default() }
pretty: true
, not adding whitespace for production buildsmax_line_length
to a size to wrap certain structuresIf in main root rather than this folder, add
-p ezno-parser
aftercargo run
to the following commands.
For testing whether the parser can lex a file
cargo run --example lex path/to/file.js
and parse
cargo run --example parse path/to/file.js
Note the Ezno CLI includes the
ast-playground
subcommand: a more user oriented version of these commands