Strongly-typed AST types for JavaScript, auto-generated from
tree-sitter-javascript's node-types.json.
This crate is generated by treesitter-types and is
automatically kept up to date when a new version of the grammar crate is released.
These types have been tested by parsing the Node.js source code.
See the Tree-sitter project for more information about the underlying parser framework.
Example
use *;
// A minimal JavaScript hello-world program.
let src = b"\
function greet(name) {
console.log(\"Hello, \" + name + \"!\");
}
greet(\"World\");
";
// Parse the source with tree-sitter and convert into typed AST.
let mut parser = new;
parser.set_language.unwrap;
let tree = parser.parse.unwrap;
let program = from_node.unwrap;
// The program has two top-level children.
assert_eq!;
// 1) The function declaration — `function greet(name) { ... }`.
let Statement = &program.children else ;
let Declaration = stmt.as_ref else ;
let FunctionDeclaration = decl.as_ref else ;
assert_eq!;
assert_eq!; // one parameter: `name`
// 2) The call expression — `greet("World");`.
let Statement = &program.children else ;
let ExpressionStatement = call_stmt.as_ref else ;
assert_eq!;