Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Add boilerplate for an AST structure intended to look close to idiomatic Rust. The top-level struct is `Node`, which contains common information to all nodes such as the `SourceRange` which they occupy. Most strings in the AST are represented by Rust strings, except for string and template literals, which may contains invalid UTF-8 and are therefore represented as UTF-16 by `Vec<u16>`. The AST being a tree, each node owns its children via either `Box<Node>` or `Vec<Node>`, which have been type aliased accordingly. Differentiate between AST nodes via `NodeKind`, an `enum` which houses each of the variants. `NodeKind` is generated via macro in order to make it easier to add more functions which `match` on every kind of node, such as visitors. Change the names of the fields from ESTree.def to Rust naming conventions, so `camelCase` has been changed to `snake_case`. The fields with reserved words as names have added `is_` at the front. In the future, if we need serialization or compatibility, mappings for those can be added within copying/conversion logic. Reviewed By: tmikov Differential Revision: D29623395 fbshipit-source-id: 27ae213feb53ca84c0882191ec30b7b8503dce5f
- Loading branch information