From dd8856d5cc7ed1fd305b1fbe6e3a6db6e0591c0b Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Sat, 18 Jun 2016 10:30:55 +0300 Subject: [PATCH 1/2] Correct Options heading level in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85cee86fca..d21787bc55 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Significant diversions are expected to occur in the future such as streaming, EB ### `babylon.parse(code, [options])` -## Options +### Options - **allowImportExportEverywhere**: By default, `import` and `export` declarations can only appear at a program's top level. Setting this From d7dc857bbf2e106b774450e671b6364c81a46162 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Sat, 18 Jun 2016 11:05:48 +0300 Subject: [PATCH 2/2] Document AST deviations from ESTree spec Refs #40 --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/README.md b/README.md index d21787bc55..6bdc436589 100644 --- a/README.md +++ b/README.md @@ -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