Skip to content

Commit

Permalink
clarify on field order + reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Oct 25, 2024
1 parent d2ac19e commit 4c1274a
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions crates/oxc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@
//!
//! Supports JavaScript, TypeScript and JSX.
//!
//! Compared to [estree] and [typescript-eslint]'s definition, node ordering is identifical and the shape is similar except a few places:
//! * `Identifier` is replaced with explicit [`BindingIdentifier`], [`IdentifierReference`], [`IdentifierName`] per ECMAScript Specification
//! * `AssignmentExpression`.`left` `Pattern` is replaced with [`AssignmentTarget`]
//! ## Types
//!
//! AST types are similar to [estree] and [typescript-eslint]'s definition, with a few notable exceptions:
//!
//! * `Identifier` is replaced with explicit [`BindingIdentifier`], [`IdentifierReference`],
//! [`IdentifierName`], per ECMAScript Specification.
//! * `AssignmentExpression`.`left` `Pattern` is replaced with [`AssignmentTarget`].
//! * `Literal` is replaced with [`BooleanLiteral`], [`NumericLiteral`], [`StringLiteral`] etc.
//!
//! Field order of types follows "Evaluation order" defined by [ECMAScript spec].
//! For TypeScript types, we follow how field order is defined in [tsc].
//!
//! Oxc's visitors ([`Visit`], [`VisitMut`], [`Traverse`]) visit AST node fields in same order
//! as they are defined in the types here.
//!
//! ## Parsing
//!
Expand All @@ -22,10 +33,16 @@
//! [`IdentifierReference`]: ast::IdentifierReference
//! [`IdentifierName`]: ast::IdentifierName
//! [`AssignmentTarget`]: ast::AssignmentTarget
//! [`BooleanLiteral`]: ast::BooleanLiteral
//! [`NumericLiteral`]: ast::NumericLiteral
//! [`StringLiteral`]: ast::StringLiteral
//! [`oxc_parser`]: <https://docs.rs/oxc_parser>
//! [`Parser`]: <https://docs.rs/oxc_parser/latest/oxc_parser/struct.Parser.html>
//! [estree]: <https://github.com/estree/estree>
//! [typescript-eslint]: <https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/ast-spec>
//! [ECMAScript spec]: <https://tc39.es/ecma262/>
//! [tsc]: <https://github.com/microsoft/TypeScript>
//! [`Traverse`]: <https://github.com/oxc-project/oxc/tree/main/crates/oxc_traverse>
#[cfg(feature = "serialize")]
mod serialize;
Expand Down

0 comments on commit 4c1274a

Please sign in to comment.