diff --git a/demo/autocomplete.html b/demo/autocomplete.html index 36c31cdfe..e4b206d1a 100644 --- a/demo/autocomplete.html +++ b/demo/autocomplete.html @@ -61,10 +61,9 @@
In a certain specific case, Esprima intentially does not throw an exception (indicating - a parsing error) although the input being parsed contains an invalid syntax. - This is to achieve implementation compatibility with major web browsers. - For further details, refer to the official - ECMAScript 2015 - Language Specification, Section B.3.3 on Block-Level Function - Declarations Web Legacy Compatibility Semantics:
- -- Prior to ECMAScript 2015, the ECMAScript specification did not define the occurrence of - a FunctionDeclaration as an element of a Block statement’s StatementList. - However, support for that form of FunctionDeclaration was an allowable extension and most - browser-hosted ECMAScript implementations permitted them. -- -
This is illustrated in the following simple example:
- --var syntax = esprima.parse('if (x) function y() {}'); -- -
In the above example, Esprima returns a syntax tree for the code - (see the result).
- -According to the specification, declaring a function inside the block - of an If statement is not possible. Yet, this is permitted in web browsers - such as Firefox, Chrome, and many others.
- +Please read the documentation on Browser Compatibility.
From version 2.0, Esprima starts to support new features in ECMAScript 6.
- -Since: version 2.0. Specification: section 14.2.
- -Example code snippet:
- --array.map(x => x * x) -- - -
The corresponding syntax tree:
- --{ - "type": "Program", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "computed": false, - "object": { - "type": "Identifier", - "name": "array" - }, - "property": { - "type": "Identifier", - "name": "map" - } - }, - "arguments": [ - { - "type": "ArrowFunctionExpression", - "id": null, - "params": [ - { - "type": "Identifier", - "name": "x" - } - ], - "defaults": [], - "body": { - "type": "BinaryExpression", - "operator": "*", - "left": { - "type": "Identifier", - "name": "x" - }, - "right": { - "type": "Identifier", - "name": "x" - } - }, - "rest": null, - "generator": false, - "expression": true - } - ] - } - } - ] -} -- -
Since: version 2.0. Specification: section 14.1.
- -Example code snippet:
- --function answer(x = 42) { say(x); } -- -
The corresponding syntax tree:
- --{ - "type": "Program", - "body": [ - { - "type": "FunctionDeclaration", - "id": { - "type": "Identifier", - "name": "answer" - }, - "params": [ - { - "type": "Identifier", - "name": "x" - } - ], - "defaults": [ - { - "type": "Literal", - "value": 42, - "raw": "42" - } - ], - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "say" - }, - "arguments": [ - { - "type": "Identifier", - "name": "x" - } - ] - } - } - ] - }, - "rest": null, - "generator": false, - "expression": false - } - ] -} -- -
Since: version 2.0. Specification: section 11.8.4.
- -Example code snippet:
- --x = '\u{41}' -- -
The corresponding syntax tree:
- --{ - "type": "Program", - "body": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "AssignmentExpression", - "operator": "=", - "left": { - "type": "Identifier", - "name": "x" - }, - "right": { - "type": "Literal", - "value": "A", - "raw": "'\\u{41}'" - } - } - } - ] -} -+
Please read the documentation on the Syntax Tree Format.
Contents
- -Note: Partial ES6 support also exists in the experimental harmony branch. However, this branch has never been officially released and the features are not documented.
diff --git a/doc/index.html b/doc/index.html index c264b8ea4..758565c49 100644 --- a/doc/index.html +++ b/doc/index.html @@ -6,6 +6,7 @@