/** * Copyright 2014 Shape Security, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* INFO: This specification is currently divided into the following sections: * supporting types * node classes * bindings * classes * modules * functions * object expressions * literals * other expressions * other statements * directives * other nodes */ // supporting types typedef (SpreadElement or Expression)[] Arguments; typedef DOMString string; typedef string Identifier; typedef string IdentifierName; typedef string Label; enum VariableDeclarationKind { "var", "let", "const" }; enum AssignmentOperator { "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=", "|=", "^=", "&=" }; enum BinaryOperator { "==", "!=", "===", "!==", "<", "<=", ">", ">=", "in", "instanceof", "<<", ">>", ">>>", "+", "-", "*", "/", "%", ",", "||", "&&", "|", "^", "&" }; enum PrefixOperator { "+", "-", "!", "~", "typeof", "void", "delete", "++", "--" }; enum PostfixOperator { "++", "--" }; interface SourceLocation { attribute unsigned long line; attribute unsigned long column; attribute unsigned long offset; }; interface SourceSpan { attribute string? source; attribute SourceLocation start; attribute SourceLocation end; }; interface Function { attribute boolean isGenerator; attribute FormalParameters params; attribute FunctionBody body; }; // node classes interface Node { [TypeIndicator] readonly attribute Type type; attribute SourceSpan? loc; }; interface Statement : Node { }; interface IterationStatement : Statement { attribute Statement body; }; interface Expression : Node { }; interface UnaryExpression : Expression { attribute Expression operand; }; interface MemberExpression : Expression { attribute (Expression or Super) _object; }; interface PropertyName : Node { }; interface ObjectProperty : Node { }; interface NamedObjectProperty : ObjectProperty { attribute PropertyName name; }; interface MethodDefinition : NamedObjectProperty { attribute FunctionBody body; }; interface ImportDeclaration : Node { attribute string moduleSpecifier; }; interface ExportDeclaration : Node { }; // bindings typedef (ObjectBinding or ArrayBinding or BindingIdentifier or MemberExpression) Binding; interface BindingWithDefault : Node { attribute Binding binding; attribute Expression init; }; interface BindingIdentifier : Node { attribute Identifier name; }; interface ArrayBinding : Node { attribute (Binding or BindingWithDefault)?[] elements; attribute Binding? restElement; }; interface ObjectBinding : Node { attribute BindingProperty[] properties; }; interface BindingProperty : Node { }; interface BindingPropertyIdentifier : BindingProperty { attribute BindingIdentifier binding; attribute Expression? init; }; interface BindingPropertyProperty : BindingProperty { attribute PropertyName name; attribute (Binding or BindingWithDefault) binding; }; // classes interface Class { attribute Expression? super; attribute ClassElement[] elements; }; interface ClassExpression : Expression { attribute BindingIdentifier? name; }; ClassExpression implements Class; interface ClassDeclaration : Statement { attribute BindingIdentifier name; }; ClassDeclaration implements Class; interface ClassElement : Node { attribute boolean isStatic; attribute MethodDefinition method; }; // modules interface Module : Node { attribute (ImportDeclaration or ExportDeclaration or Statement)[] items; }; interface Import : ImportDeclaration { attribute BindingIdentifier? defaultBinding; attribute ImportSpecifier[] namedImports; }; interface ImportNamespace : ImportDeclaration { attribute BindingIdentifier? defaultBinding; attribute BindingIdentifier namespaceBinding; }; interface ImportSpecifier : Node { attribute IdentifierName? name; attribute BindingIdentifier binding; }; interface ExportAllFrom : ExportDeclaration { attribute string moduleSpecifier; }; interface ExportFrom : ExportDeclaration { attribute ExportSpecifier[] namedExports; attribute string? moduleSpecifier; }; interface Export : ExportDeclaration { attribute (FunctionDeclaration or ClassDeclaration or VariableDeclaration) declaration; }; interface ExportDefault : ExportDeclaration { attribute (FunctionDeclaration or ClassDeclaration or Expression) body; }; interface ExportSpecifier : Node { attribute IdentifierName? name; attribute IdentifierName exportedName; }; // property definition interface Method : MethodDefinition { attribute boolean isGenerator; attribute FormalParameters params; }; interface Getter : MethodDefinition { }; interface Setter : MethodDefinition { attribute Binding param; }; interface DataProperty : NamedObjectProperty { attribute Expression expression; }; interface ShorthandProperty : ObjectProperty { attribute Identifier name; }; interface ComputedPropertyName : PropertyName { attribute Expression expression; }; interface StaticPropertyName : PropertyName { attribute string value; }; // literals interface LiteralBooleanExpression : Expression { attribute boolean value; }; interface LiteralInfinityExpression : Expression { }; interface LiteralNullExpression : Expression { }; interface LiteralNumericExpression : Expression { attribute double value; }; interface LiteralRegExpExpression : Expression { attribute string pattern; attribute string flags; }; interface LiteralStringExpression : Expression { attribute string value; }; // other expressions interface ArrayExpression : Expression { attribute (SpreadElement or Expression)?[] elements; }; interface ArrowExpression : Expression { attribute FormalParameters params; attribute (FunctionBody or Expression) body; }; interface AssignmentExpression : Expression { attribute AssignmentOperator operator; attribute Binding binding; attribute Expression expression; }; interface BinaryExpression : Expression { attribute BinaryOperator operator; attribute Expression left; attribute Expression right; }; interface CallExpression : Expression { attribute (Expression or Super) callee; attribute Arguments arguments; }; interface ComputedMemberExpression : MemberExpression { attribute Expression expression; }; interface ConditionalExpression : Expression { attribute Expression test; attribute Expression consequent; attribute Expression alternate; }; interface FunctionExpression : Expression { attribute BindingIdentifier? name; }; FunctionExpression implements Function; interface IdentifierExpression : Expression { attribute Identifier name; }; interface NewExpression : Expression { attribute Expression callee; attribute Arguments arguments; }; interface NewTargetExpression : Expression { }; interface ObjectExpression : Expression { attribute ObjectProperty[] properties; }; interface PostfixExpression : UnaryExpression { attribute PostfixOperator operator; }; interface PrefixExpression : UnaryExpression { attribute PrefixOperator operator; }; interface StaticMemberExpression : MemberExpression { attribute IdentifierName property; }; interface TemplateExpression : Expression { attribute Expression? tag; attribute (Expression or TemplateElement)[] elements; }; interface ThisExpression : Expression { }; interface YieldExpression : Expression { attribute Expression? expression; }; interface YieldGeneratorExpression : Expression { attribute Expression expression; }; // other statements interface BlockStatement : Statement { attribute Block block; }; interface BreakStatement : Statement { attribute Label? label; }; interface ContinueStatement : Statement { attribute Label? label; }; interface DebuggerStatement : Statement { }; interface DoWhileStatement : IterationStatement { attribute Expression test; }; interface EmptyStatement : Statement { }; interface ExpressionStatement : Statement { attribute Expression expression; }; interface ForInStatement : IterationStatement { attribute (VariableDeclaration or Binding) left; attribute Expression right; }; interface ForOfStatement : IterationStatement { attribute (VariableDeclaration or Binding) left; attribute Expression right; }; interface ForStatement : IterationStatement { attribute (VariableDeclaration or Expression)? init; attribute Expression? test; attribute Expression? update; }; interface IfStatement : Statement { attribute Expression test; attribute Statement consequent; attribute Statement? alternate; }; interface LabeledStatement : Statement { attribute Label label; attribute Statement body; }; interface ReturnStatement : Statement { attribute Expression? expression; }; interface SwitchStatement : Statement { attribute Expression discriminant; attribute SwitchCase[] cases; }; interface SwitchStatementWithDefault : Statement { attribute Expression discriminant; attribute SwitchCase[] preDefaultCases; attribute SwitchDefault defaultCase; attribute SwitchCase[] postDefaultCases; }; interface ThrowStatement : Statement { attribute Expression expression; }; interface TryCatchStatement : Statement { attribute Block body; attribute CatchClause catchClause; }; interface TryFinallyStatement : Statement { attribute Block body; attribute CatchClause? catchClause; attribute Block finalizer; }; interface VariableDeclarationStatement : Statement { attribute VariableDeclaration declaration; }; interface WhileStatement : IterationStatement { attribute Expression test; }; interface WithStatement : Statement { attribute Expression _object; attribute Statement body; }; // other nodes interface Block : Node { attribute Statement[] statements; }; interface CatchClause : Node { attribute Binding binding; attribute Block body; }; interface Directive : Node { attribute string rawValue; }; interface FormalParameters : Node { attribute (Binding or BindingWithDefault)[] items; attribute BindingIdentifier? rest; }; interface FunctionBody : Node { attribute Directive[] directives; attribute Statement[] statements; }; interface FunctionDeclaration : Statement { attribute BindingIdentifier name; }; FunctionDeclaration implements Function; interface Script : Node { attribute FunctionBody body; }; interface SpreadElement : Node { attribute Expression expression; }; interface Super : Node { }; interface SwitchCase : Node { attribute Expression test; attribute Statement[] consequent; }; interface SwitchDefault : Node { attribute Statement[] consequent; }; interface TemplateElement : Node { attribute string rawValue; }; interface VariableDeclaration : Node { attribute VariableDeclarationKind kind; [NonEmpty] attribute VariableDeclarator[] declarators; }; interface VariableDeclarator : Node { attribute Binding binding; attribute Expression? init; };