Document AST deviations from ESTree spec

Refs #40
This commit is contained in:
Rene Saarsoo 2016-06-18 11:05:48 +03:00
parent dd8856d5cc
commit d7dc857bbf

View File

@ -45,6 +45,43 @@ Significant diversions are expected to occur in the future such as streaming, EB
- **plugins**: Array containing the plugins that you want to enable.
### Output
Babylon generates AST according to [Babel AST format][].
It is based on [ESTree spec][] with the following deviations:
- [Literal][] token is replaced with [StringLiteral][], [NumericLiteral][], [BooleanLiteral][], [NullLiteral][], [RegExpLiteral][]
- [Property][] token is replaced with [ObjectProperty][] and [ObjectMethod][]
- [MethodDefinition][] is replaced with [ClassMethod][]
- [Program][] and [BlockStatement][] contain additional `directives` field with [Directive][] and [DirectiveLiteral][]
AST for JSX code is based on [Facebook JSX AST][] with the addition of one node type:
- `JSXText`
[Babel AST format]: https://github.com/babel/babel/blob/master/doc/ast/spec.md
[ESTree spec]: https://github.com/estree/estree
[Literal]: https://github.com/estree/estree/blob/master/spec.md#literal
[Property]: https://github.com/estree/estree/blob/master/spec.md#property
[MethodDefinition]: https://github.com/estree/estree/blob/master/es6.md#methoddefinition
[StringLiteral]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#stringliteral
[NumericLiteral]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#numericliteral
[BooleanLiteral]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#booleanliteral
[NullLiteral]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#nullliteral
[RegExpLiteral]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#regexpliteral
[ObjectProperty]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#objectproperty
[ObjectMethod]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#objectmethod
[ClassMethod]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#classmethod
[Program]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#programs
[BlockStatement]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#blockstatement
[Directive]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#directive
[DirectiveLiteral]: https://github.com/babel/babel/blob/master/doc/ast/spec.md#directiveliteral
[Facebook JSX AST]: https://github.com/facebook/jsx/blob/master/AST.md
### Example
```javascript