Documentation ¶
Index ¶
- Variables
- func Assemble(p Program) (result string, err error)
- type ArrayExpression
- type AssignmentExpression
- type AssignmentOperator
- type AwaitExpression
- type BinaryExpression
- type BinaryOperator
- type BlockStatement
- type BreakStatement
- type CallExpression
- type CatchClause
- type ConditionalExpression
- type ContinueStatement
- type DebuggerStatement
- type Declaration
- type Directive
- type DoWhileStatement
- type EmptyStatement
- type Expression
- type ExpressionStatement
- type ForInStatement
- type ForStatement
- type Function
- type FunctionBody
- type FunctionDeclaration
- type FunctionExpression
- func CreateAsyncFunctionExpression(id *Identifier, params []IPattern, body FunctionBody) FunctionExpression
- func CreateFunctionExpression(id *Identifier, params []IPattern, body FunctionBody) FunctionExpression
- func CreateGeneratorFunctionExpression(id *Identifier, params []IPattern, body FunctionBody) FunctionExpression
- type IBlockStatement
- type IDeclaration
- type IExpression
- type IExpressionStatement
- type IFunction
- type ILiteral
- type INode
- type IPattern
- type IStatement
- type Identifier
- type IfStatement
- type LabeledStatement
- type Literal
- type LogicalExpression
- type LogicalOperator
- type MemberExpression
- type MultiStatement
- type NewExpression
- type Node
- type ObjectExpression
- type Pattern
- type Position
- type Program
- type Property
- type Raw
- type RegExpLiteral
- type ReturnStatement
- type SequenceExpression
- type SourceLocation
- type Statement
- type SwitchCase
- type SwitchStatement
- type ThisExpression
- type ThrowStatement
- type TryStatement
- type UnaryExpression
- type UnaryOperator
- type UpdateExpression
- type UpdateOperator
- type VariableDeclaration
- type VariableDeclarator
- type WhileStatement
- type WithStatement
Constants ¶
This section is empty.
Variables ¶
var ( EmptyString = CreateString("") True = CreateBoolean(true) False = CreateBoolean(false) Zero = CreateInt(0) Null = CreateNull() )
Singletons.
Functions ¶
Types ¶
type ArrayExpression ¶
type ArrayExpression struct { Type string `json:"type,omitempty"` Elements []IExpression `json:"elements,omitempty"` }
ArrayExpression struct
func CreateArrayExpression ¶
func CreateArrayExpression(elements ...IExpression) ArrayExpression
CreateArrayExpression fn
type AssignmentExpression ¶
type AssignmentExpression struct { Type string `json:"type,omitempty"` Operator AssignmentOperator `json:"operator,omitempty"` Left interface{} `json:"left,omitempty"` // Pattern | Expression Right IExpression `json:"right,omitempty"` }
AssignmentExpression struct
func CreateAssignmentExpression ¶
func CreateAssignmentExpression(left interface{}, operator AssignmentOperator, right IExpression) AssignmentExpression
CreateAssignmentExpression fn
func (AssignmentExpression) Expression ¶
func (n AssignmentExpression) Expression() Expression
Expression fn
type AssignmentOperator ¶
type AssignmentOperator string
AssignmentOperator enum
"=" | "+=" | "-=" | "*=" | "/=" | "%="
| "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&="
type AwaitExpression ¶
type AwaitExpression struct { Type string `json:"type,omitempty"` Argument IExpression `json:"argument,omitempty"` }
AwaitExpression struct
func CreateAwaitExpression ¶
func CreateAwaitExpression(argument IExpression) AwaitExpression
CreateAwaitExpression fn
type BinaryExpression ¶
type BinaryExpression struct { Type string `json:"type,omitempty"` Operator BinaryOperator `json:"operator,omitempty"` Left IExpression `json:"left,omitempty"` Right IExpression `json:"right,omitempty"` }
BinaryExpression struct
func CreateBinaryExpression ¶
func CreateBinaryExpression(l IExpression, op BinaryOperator, r IExpression) BinaryExpression
CreateBinaryExpression fn
func (BinaryExpression) Expression ¶
func (n BinaryExpression) Expression() Expression
Expression fn
type BinaryOperator ¶
type BinaryOperator string
BinaryOperator enum "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in" | "instanceof"
type BlockStatement ¶
type BlockStatement struct { Type string `json:"type,omitempty"` // [ Directive | Statement ] // // TODO: this is non-standard, but it doesn't // make sense that a FunctionBody is a // BlockStatement but the FunctionBody // can contain a DirectiveType while // the BlockStatement cannot Body []interface{} `json:"body,omitempty"` }
BlockStatement struct
func CreateBlockStatement ¶
func CreateBlockStatement(body ...IStatement) BlockStatement
CreateBlockStatement fn
func (BlockStatement) BlockStatement ¶
func (n BlockStatement) BlockStatement() BlockStatement
BlockStatement fn
type BreakStatement ¶
type BreakStatement struct { Type string `json:"type,omitempty"` Label *Identifier `json:"label,omitempty"` }
BreakStatement struct
func CreateBreakStatement ¶
func CreateBreakStatement(label *Identifier) BreakStatement
CreateBreakStatement fn
type CallExpression ¶
type CallExpression struct { Type string `json:"type,omitempty"` Callee IExpression `json:"callee,omitempty"` Arguments []IExpression `json:"arguments,omitempty"` }
CallExpression struct
A function or method call expression.
func CreateCallExpression ¶
func CreateCallExpression(callee IExpression, arguments []IExpression) CallExpression
CreateCallExpression fn
type CatchClause ¶
type CatchClause struct { Type string `json:"type,omitempty"` Param IPattern `json:"param,omitempty"` Body IBlockStatement `json:"body,omitempty"` }
CatchClause struct
type ConditionalExpression ¶
type ConditionalExpression struct { Type string `json:"type,omitempty"` Test IExpression `json:"test,omitempty"` Alternate IExpression `json:"alternate,omitempty"` Consequent IExpression `json:"consequent,omitempty"` }
ConditionalExpression struct
A conditional expression, i.e., a ternary ?/: expression.
func (ConditionalExpression) Expression ¶
func (n ConditionalExpression) Expression() Expression
Expression fn
type ContinueStatement ¶
type ContinueStatement struct { Type string `json:"type,omitempty"` Label *Identifier `json:"label,omitempty"` }
ContinueStatement struct
type DebuggerStatement ¶
type DebuggerStatement struct {
Type string `json:"type,omitempty"`
}
DebuggerStatement struct
type Declaration ¶
type Declaration struct {
Type string `json:"type,omitempty"`
}
Declaration struct
type Directive ¶
type Directive struct { Type string `json:"type,omitempty"` Expression IExpression `json:"expression,omitempty"` Directive string `json:"directive,omitempty"` }
Directive struct
func (Directive) ExpressionStatement ¶
func (n Directive) ExpressionStatement() ExpressionStatement
ExpressionStatement fn
type DoWhileStatement ¶
type DoWhileStatement struct { Type string `json:"type,omitempty"` Body IStatement `json:"body,omitempty"` Test IExpression `json:"test,omitempty"` }
DoWhileStatement struct
type EmptyStatement ¶
type EmptyStatement struct {
Type string `json:"type,omitempty"`
}
EmptyStatement struct
type ExpressionStatement ¶
type ExpressionStatement struct { Type string `json:"type,omitempty"` Expression IExpression `json:"expression,omitempty"` }
ExpressionStatement struct
func CreateExpressionStatement ¶
func CreateExpressionStatement(expression IExpression) ExpressionStatement
CreateExpressionStatement fn
func (ExpressionStatement) ExpressionStatement ¶
func (n ExpressionStatement) ExpressionStatement() ExpressionStatement
ExpressionStatement fn
func (ExpressionStatement) Statement ¶
func (n ExpressionStatement) Statement() Statement
Statement fn
type ForInStatement ¶
type ForInStatement struct { Type string `json:"type,omitempty"` Left interface{} `json:"left,omitempty"` // VariableDeclaration | Pattern Right IExpression `json:"right,omitempty"` Body IStatement `json:"body,omitempty"` }
ForInStatement struct
func CreateForInStatement ¶
func CreateForInStatement(left interface{}, right IExpression, body IStatement) ForInStatement
CreateForInStatement fn
type ForStatement ¶
type ForStatement struct { Type string `json:"type,omitempty"` Init interface{} `json:"init,omitempty"` // VariableDeclaration | Expression | null Test IExpression `json:"test,omitempty"` Update IExpression `json:"update,omitempty"` Body IStatement `json:"body,omitempty"` }
ForStatement struct
func CreateForStatement ¶
func CreateForStatement(init interface{}, test IExpression, update IExpression, body IStatement) ForStatement
CreateForStatement fn
type Function ¶
type Function struct { Type string ID *Identifier `json:"id,omitempty"` Params []IPattern `json:"params,omitempty"` Body FunctionBody `json:"body,omitempty"` }
Function struct
type FunctionBody ¶
type FunctionBody struct { Type string `json:"type,omitempty"` // [ Directive | Statement ] Body []interface{} `json:"body,omitempty"` }
FunctionBody struct
func CreateFunctionBody ¶
func CreateFunctionBody(body ...interface{}) FunctionBody
CreateFunctionBody fn
func (FunctionBody) BlockStatement ¶
func (n FunctionBody) BlockStatement() BlockStatement
BlockStatement fn
type FunctionDeclaration ¶
type FunctionDeclaration struct { Type string `json:"type,omitempty"` ID *Identifier `json:"id,omitempty"` Params []IPattern Body FunctionBody Generator bool Async bool }
FunctionDeclaration struct
func CreateAsyncFunction ¶
func CreateAsyncFunction(id *Identifier, params []IPattern, body FunctionBody) FunctionDeclaration
CreateAsyncFunction fn
func CreateFunction ¶
func CreateFunction(id *Identifier, params []IPattern, body FunctionBody) FunctionDeclaration
CreateFunction fn
func CreateGeneratorFunction ¶
func CreateGeneratorFunction(id *Identifier, params []IPattern, body FunctionBody) FunctionDeclaration
CreateGeneratorFunction fn
func (FunctionDeclaration) Declaration ¶
func (n FunctionDeclaration) Declaration() Declaration
Declaration fn
func (FunctionDeclaration) Statement ¶
func (n FunctionDeclaration) Statement() Statement
Statement fn
type FunctionExpression ¶
type FunctionExpression struct { Type string `json:"type,omitempty"` ID *Identifier Params []IPattern Body FunctionBody Async bool Generator bool }
FunctionExpression struct
func CreateAsyncFunctionExpression ¶
func CreateAsyncFunctionExpression(id *Identifier, params []IPattern, body FunctionBody) FunctionExpression
CreateAsyncFunctionExpression fn
func CreateFunctionExpression ¶
func CreateFunctionExpression(id *Identifier, params []IPattern, body FunctionBody) FunctionExpression
CreateFunctionExpression fn
func CreateGeneratorFunctionExpression ¶
func CreateGeneratorFunctionExpression(id *Identifier, params []IPattern, body FunctionBody) FunctionExpression
CreateGeneratorFunctionExpression fn
func (FunctionExpression) Expression ¶
func (n FunctionExpression) Expression() Expression
Expression fn
type IBlockStatement ¶
type IBlockStatement interface { IStatement BlockStatement() BlockStatement }
IBlockStatement interface
type IDeclaration ¶
type IDeclaration interface { IStatement Declaration() Declaration }
IDeclaration interface
type IExpression ¶
type IExpression interface { INode Expression() Expression }
IExpression interface
type IExpressionStatement ¶
type IExpressionStatement interface { IStatement ExpressionStatement() ExpressionStatement }
IExpressionStatement interface
type IStatement ¶
IStatement interface
func CreateMultiStatement ¶
func CreateMultiStatement(statements ...IStatement) IStatement
CreateMultiStatement fn
type Identifier ¶
Identifier struct
type IfStatement ¶
type IfStatement struct { Type string `json:"type,omitempty"` Test IExpression `json:"test,omitempty"` Consequent IStatement `json:"consequent,omitempty"` Alternate IStatement `json:"alternate,omitempty"` }
IfStatement struct
func CreateIfStatement ¶
func CreateIfStatement(test IExpression, consequent IStatement, alternate IStatement) IfStatement
CreateIfStatement fn
type LabeledStatement ¶
type LabeledStatement struct { Type string `json:"type,omitempty"` Label Identifier `json:"label,omitempty"` Body IStatement `json:"body,omitempty"` }
LabeledStatement struct
type Literal ¶
type Literal struct { Type string `json:"type,omitempty"` Value interface{} `json:"value,omitempty"` // string | boolean | null | number | RegExp; }
Literal struct
type LogicalExpression ¶
type LogicalExpression struct { Type string `json:"type,omitempty"` Operator LogicalOperator `json:"operator,omitempty"` Left IExpression `json:"left,omitempty"` Right IExpression `json:"right,omitempty"` }
LogicalExpression struct
func CreateLogicalExpression ¶
func CreateLogicalExpression(left IExpression, operator LogicalOperator, right IExpression) LogicalExpression
CreateLogicalExpression fn
func (LogicalExpression) Expression ¶
func (n LogicalExpression) Expression() Expression
Expression fn
type MemberExpression ¶
type MemberExpression struct { Type string `json:"type,omitempty"` Object IExpression `json:"object,omitempty"` Property IExpression `json:"property,omitempty"` Computed bool `json:"computed,omitempty"` }
MemberExpression struct
A member expression. If computed is true, the node corresponds to a computed (a[b]) member expression and property is an Expression. If computed is false, the node corresponds to a static (a.b) member expression and property is an Identifier.
func CreateMemberExpression ¶
func CreateMemberExpression(object IExpression, property IExpression, computed bool) MemberExpression
CreateMemberExpression fn
func (MemberExpression) Expression ¶
func (n MemberExpression) Expression() Expression
Expression fn
type MultiStatement ¶
type MultiStatement struct { Type string `json:"type,omitempty"` Statements []IStatement }
MultiStatement struct
type NewExpression ¶
type NewExpression struct { Type string `json:"type,omitempty"` Callee IExpression `json:"callee,omitempty"` Arguments []IExpression `json:"arguments,omitempty"` }
NewExpression struct
A `new` expression.
func CreateNewExpression ¶
func CreateNewExpression(callee IExpression, arguments []IExpression) NewExpression
CreateNewExpression fn
type Node ¶
type Node struct { Type string `json:"type,omitempty"` Loc *SourceLocation `json:"loc,omitempty"` }
Node struct
type ObjectExpression ¶
type ObjectExpression struct { Type string `json:"type,omitempty"` Properties []Property `json:"properties,omitempty"` }
ObjectExpression struct
func CreateObjectExpression ¶
func CreateObjectExpression(properties []Property) ObjectExpression
CreateObjectExpression fn
func (ObjectExpression) Expression ¶
func (n ObjectExpression) Expression() Expression
Expression fn
type Pattern ¶
type Pattern struct {
Type string
}
Pattern struct
Destructuring binding and assignment are not part of ES5, but all binding positions accept Pattern to allow for destructuring in ES6. Nevertheless, for ES5, the only Pattern subtype is Identifier.
type Program ¶
type Program struct { Type string `json:"type,omitempty"` // [ Directive | Statement ] Body []interface{} `json:"body,omitempty"` }
Program struct
type Property ¶
type Property struct { Type string `json:"type,omitempty"` Key interface{} `json:"key,omitempty"` // Literal | Identifier Value IExpression `json:"value,omitempty"` Kind string `json:"kind,omitempty"` // "init" | "get" | "set" }
Property struct
func CreateProperty ¶
func CreateProperty(key interface{}, value IExpression, kind string) Property
CreateProperty fn
type RegExpLiteral ¶
type RegExpLiteral struct { Type string `json:"type,omitempty"` Value interface{} `json:"value,omitempty"` // string | boolean | null | number | RegExp; Regex struct { Pattern string `json:"pattern,omitempty"` Flags string `json:"flags,omitempty"` } `json:"regex,omitempty"` }
RegExpLiteral struct
type ReturnStatement ¶
type ReturnStatement struct { Type string `json:"type,omitempty"` Argument IExpression `json:"argument,omitempty"` }
ReturnStatement struct
func CreateReturnStatement ¶
func CreateReturnStatement(argument IExpression) ReturnStatement
CreateReturnStatement fn
type SequenceExpression ¶
type SequenceExpression struct { Type string `json:"type,omitempty"` Expressions []IExpression `json:"expressions,omitempty"` }
SequenceExpression struct
A sequence expression, i.e., a comma-separated sequence of expressions.
func CreateSequenceExpression ¶
func CreateSequenceExpression(expressions ...IExpression) SequenceExpression
CreateSequenceExpression fn
func (SequenceExpression) Expression ¶
func (n SequenceExpression) Expression() Expression
Expression fn
type SourceLocation ¶
type SourceLocation struct { Source *string `json:"source,omitempty"` Start Position `json:"start,omitempty"` End Position `json:"end,omitempty"` }
SourceLocation struct
type SwitchCase ¶
type SwitchCase struct { Type string `json:"type,omitempty"` Test IExpression `json:"test,omitempty"` Consequent []IStatement `json:"consequent,omitempty"` }
SwitchCase struct
type SwitchStatement ¶
type SwitchStatement struct { Type string `json:"type,omitempty"` Discriminant IExpression `json:"discriminant,omitempty"` Cases []SwitchCase `json:"cases,omitempty"` }
SwitchStatement struct
type ThisExpression ¶
type ThisExpression struct {
Type string `json:"type,omitempty"`
}
ThisExpression struct
type ThrowStatement ¶
type ThrowStatement struct { Type string `json:"type,omitempty"` Argument IExpression `json:"argument,omitempty"` }
ThrowStatement struct
func CreateThrowStatement ¶
func CreateThrowStatement(argument IExpression) ThrowStatement
CreateThrowStatement fn
type TryStatement ¶
type TryStatement struct { Type string `json:"type,omitempty"` Block IBlockStatement `json:"block,omitempty"` Handler *CatchClause `json:"handler,omitempty"` Finalizer IBlockStatement `json:"finalizer,omitempty"` }
TryStatement struct
type UnaryExpression ¶
type UnaryExpression struct { Type string `json:"type,omitempty"` Operator UnaryOperator `json:"operator,omitempty"` Prefix bool `json:"prefix,omitempty"` Argument IExpression `json:"argument,omitempty"` }
UnaryExpression struct
type UnaryOperator ¶
type UnaryOperator string
UnaryOperator enum "-" | "+" | "!" | "~" | "typeof" | "void" | "delete"
type UpdateExpression ¶
type UpdateExpression struct { Type string `json:"type,omitempty"` Operator UpdateOperator `json:"operator,omitempty"` Argument IExpression `json:"argument,omitempty"` Prefix bool `json:"prefix,omitempty"` }
UpdateExpression struct
func CreateUpdateExpression ¶
func CreateUpdateExpression(argument IExpression, operator UpdateOperator, prefix bool) UpdateExpression
CreateUpdateExpression fn
func (UpdateExpression) Expression ¶
func (n UpdateExpression) Expression() Expression
Expression fn
type VariableDeclaration ¶
type VariableDeclaration struct { Type string `json:"type,omitempty"` Declarations []VariableDeclarator `json:"declarations,omitempty"` Kind string `json:"kind,omitempty"` // "var" }
VariableDeclaration struct
func CreateVariableDeclaration ¶
func CreateVariableDeclaration(kind string, decls ...VariableDeclarator) VariableDeclaration
CreateVariableDeclaration fn
func (VariableDeclaration) Declaration ¶
func (n VariableDeclaration) Declaration() Declaration
Declaration fn
func (VariableDeclaration) Statement ¶
func (n VariableDeclaration) Statement() Statement
Statement fn
type VariableDeclarator ¶
type VariableDeclarator struct { Type string `json:"type,omitempty"` ID IPattern `json:"id,omitempty"` Init IExpression `json:"init,omitempty"` }
VariableDeclarator struct
func CreateVariableDeclarator ¶
func CreateVariableDeclarator(id IPattern, init IExpression) VariableDeclarator
CreateVariableDeclarator fn
type WhileStatement ¶
type WhileStatement struct { Type string `json:"type,omitempty"` Test IExpression `json:"test,omitempty"` Body IStatement `json:"body,omitempty"` }
WhileStatement struct
type WithStatement ¶
type WithStatement struct { Type string `json:"type,omitempty"` Object IExpression `json:"object,omitempty"` Body IStatement `json:"body,omitempty"` }
WithStatement struct