Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
"vimagination.zapto.org/javascript"
"vimagination.zapto.org/parser"
)
func main() {
src := `function greet(name) {console.log("Hello, " + name)} for (const name of ["Alice", "Bob", "Charlie"]) greet(name)`
tk := parser.NewStringTokeniser(src)
ast, err := javascript.ParseModule(&tk)
if err != nil {
fmt.Println(err)
return
}
javascript.UnwrapConditional(javascript.WrapConditional(javascript.UnwrapConditional(javascript.UnwrapConditional(ast.ModuleListItems[0].StatementListItem.Declaration.FunctionDeclaration.FunctionBody.StatementList[0].Statement.ExpressionStatement.Expressions[0].ConditionalExpression).(*javascript.CallExpression).Arguments.ArgumentList[0].AssignmentExpression.ConditionalExpression).(*javascript.AdditiveExpression).AdditiveExpression)).(*javascript.PrimaryExpression).Literal.Data = `"Hi, "`
fmt.Printf("%s", ast)
}
Output: function greet(name) { console.log("Hi, " + name); } for (const name of ["Alice", "Bob", "Charlie"]) greet(name);
Index ¶
- Constants
- Variables
- func QuoteTemplate(t string, templateType TemplateType) string
- func SetTokeniser(t *parser.Tokeniser) *parser.Tokeniser
- func Unquote(str string) (string, error)
- func UnquoteTemplate(t string) (string, error)
- type AdditiveExpression
- type AdditiveOperator
- type Argument
- type Arguments
- type ArrayAssignmentPattern
- type ArrayBindingPattern
- type ArrayElement
- type ArrayLiteral
- type ArrowFunction
- type AssignmentElement
- type AssignmentExpression
- type AssignmentOperator
- type AssignmentPattern
- type AssignmentProperty
- type BindingElement
- type BindingProperty
- type BitwiseANDExpression
- type BitwiseORExpression
- type BitwiseXORExpression
- type Block
- type CallExpression
- type CaseClause
- type ClassDeclaration
- type ClassElement
- type ClassElementName
- type CoalesceExpression
- type Comments
- type ConditionalExpression
- type ConditionalWrappable
- type Declaration
- type DestructuringAssignmentTarget
- type EqualityExpression
- type EqualityOperator
- type Error
- type ExponentiationExpression
- type ExportClause
- type ExportDeclaration
- type ExportSpecifier
- type Expression
- type FieldDefinition
- type ForType
- type FormalParameters
- type FromClause
- type FunctionDeclaration
- type FunctionType
- type IfStatement
- type ImportClause
- type ImportDeclaration
- type ImportSpecifier
- type IterationStatementDo
- type IterationStatementFor
- type IterationStatementWhile
- type LeftHandSideExpression
- type LetOrConst
- type LexicalBinding
- type LexicalDeclaration
- type LogicalANDExpression
- type LogicalORExpression
- type MemberExpression
- type MethodDefinition
- type MethodType
- type Module
- type ModuleItem
- type MultiplicativeExpression
- type MultiplicativeOperator
- type NamedImports
- type NewExpression
- type ObjectAssignmentPattern
- type ObjectBindingPattern
- type ObjectLiteral
- type OptionalChain
- type OptionalExpression
- type ParenthesizedExpression
- type PrimaryExpression
- type PropertyDefinition
- type PropertyName
- type RelationalExpression
- type RelationshipOperator
- type Script
- type ShiftExpression
- type ShiftOperator
- type Statement
- type StatementListItem
- type StatementType
- type SwitchStatement
- type TemplateLiteral
- type TemplateType
- type Token
- type Tokeniser
- type Tokens
- type TryStatement
- type Type
- type UnaryExpression
- type UnaryOperator
- type UnaryOperatorComments
- type UpdateExpression
- type UpdateOperator
- type VariableDeclaration
- type VariableStatement
- type WithClause
- type WithEntry
- type WithStatement
Examples ¶
Constants ¶
const ( TokenWhitespace parser.TokenType = iota TokenLineTerminator TokenSingleLineComment TokenMultiLineComment TokenIdentifier TokenPrivateIdentifier TokenBooleanLiteral TokenKeyword TokenPunctuator TokenNumericLiteral TokenStringLiteral TokenNoSubstitutionTemplate TokenTemplateHead TokenTemplateMiddle TokenTemplateTail TokenDivPunctuator TokenRightBracePunctuator TokenRegularExpressionLiteral TokenNullLiteral TokenFutureReservedWord )
JavaScript Token values
Variables ¶
var ( ErrBadRestElement = errors.New("bad rest element") ErrDuplicateDefaultClause = errors.New("duplicate default clause") ErrInvalidAssignment = errors.New("invalid assignment operator") ErrInvalidAssignmentProperty = errors.New("invalid assignment property") ErrInvalidAsyncArrowFunction = errors.New("invalid async arrow function") ErrInvalidCallExpression = errors.New("invalid CallExpression") ErrInvalidCharacter = errors.New("invalid character") ErrInvalidClassDeclaration = errors.New("invalid class declaration") ErrInvalidDeclaration = errors.New("invalid declaration") ErrInvalidDestructuringAssignmentTarget = errors.New("invalid DestructuringAssignmentTarget") ErrInvalidEscapeSequence = errors.New("invalid escape sequence") ErrInvalidExportClause = errors.New("invalid export clause") ErrInvalidExportDeclaration = errors.New("invalid export declaration") ErrInvalidForAwaitLoop = errors.New("invalid for await loop") ErrInvalidForLoop = errors.New("invalid for loop") ErrInvalidFunction = errors.New("invalid function") ErrInvalidIfStatement = errors.New("invalid if statement") ErrInvalidImport = errors.New("invalid import statement") ErrInvalidImportSpecifier = errors.New("invalid import specifier") ErrInvalidIterationStatementDo = errors.New("invalid do iteration statement") ErrInvalidIterationStatementFor = errors.New("invalid for iteration statement") ErrInvalidIterationStatementWhile = errors.New("invalid while iteration statement") ErrInvalidLexicalDeclaration = errors.New("invalid lexical declaration") ErrInvalidMetaProperty = errors.New("invalid meta property") ErrInvalidMethodName = errors.New("invalid method name") ErrInvalidNameSpaceImport = errors.New("invalid namespace import") ErrInvalidNamedImport = errors.New("invalid named import list") ErrInvalidNumber = errors.New("invalid number") ErrInvalidOptionalChain = errors.New("invalid OptionalChain") ErrInvalidPropertyName = errors.New("invalid property name") ErrInvalidQuoted = errors.New("invalid quoted string") ErrInvalidRegexpCharacter = errors.New("invalid regexp character") ErrInvalidRegexpSequence = errors.New("invalid regexp sequence") ErrInvalidSequence = errors.New("invalid character sequence") ErrInvalidStatement = errors.New("invalid statement") ErrInvalidStatementList = errors.New("invalid statement list") ErrInvalidSuperProperty = errors.New("invalid super property") ErrInvalidSwitchStatement = errors.New("invalid switch statement") ErrInvalidTemplate = errors.New("invalid template") ErrInvalidTryStatement = errors.New("invalid try statement") ErrInvalidUnicode = errors.New("invalid unicode escape sequence") ErrInvalidVariableStatement = errors.New("invalid variable statement") ErrInvalidWithStatement = errors.New("invalid with statement") ErrLabelledFunction = errors.New("LabelledItemFunction not allowed here") ErrMissingArrow = errors.New("missing arrow") ErrMissingAttributeKey = errors.New("missing attribute key") ErrMissingCaseClause = errors.New("missing case clause") ErrMissingCatchFinally = errors.New("missing catch/finally block") ErrMissingClosingBrace = errors.New("missing closing brace") ErrMissingClosingBracket = errors.New("missing closing bracket") ErrMissingClosingParenthesis = errors.New("missing closing parenthesis") ErrMissingColon = errors.New("missing colon") ErrMissingComma = errors.New("missing comma") ErrMissingExpression = errors.New("missing expression") ErrMissingFrom = errors.New("missing from") ErrMissingFunction = errors.New("missing function") ErrMissingInitializer = errors.New("missing initializer") ErrMissingModuleSpecifier = errors.New("missing module specifier") ErrMissingOpeningBrace = errors.New("missing opening brace") ErrMissingOpeningBracket = errors.New("missing opening bracket") ErrMissingOpeningParenthesis = errors.New("missing opening parenthesis") ErrMissingOptional = errors.New("missing optional chain punctuator") ErrMissingSemiColon = errors.New("missing semi-colon") ErrMissingString = errors.New("missing string value") ErrNoIdentifier = errors.New("missing identifier") ErrNotSimple = errors.New("not a simple expression") ErrReservedIdentifier = errors.New("reserved identifier") ErrUnexpectedBackslash = errors.New("unexpected backslash") ErrUnexpectedLineTerminator = errors.New("line terminator in string") )
Errors
Functions ¶
func QuoteTemplate ¶ added in v1.4.1
func QuoteTemplate(t string, templateType TemplateType) string
QuoteTemplate creates a minimally quoted template string.
templateType determines the prefix and suffix.
| Template Type | Prefix | Suffix | |------------------------|----------|----------| | TemplateNoSubstitution | "`" | "`" | | TemplateHead | "`" | "${" | | TemplateMiddle | "}" | "}" | | TemplateTail | "}" | "`" |
func SetTokeniser ¶
SetTokeniser provides JavaScript parsing functions to a Tokeniser
func UnquoteTemplate ¶ added in v1.4.1
UnquoteTemplate parses a JavaScript template (either NoSubstitution Template, or any template part), and produces the unquoted version.
Types ¶
type AdditiveExpression ¶
type AdditiveExpression struct {
AdditiveExpression *AdditiveExpression
AdditiveOperator AdditiveOperator
MultiplicativeExpression MultiplicativeExpression
Tokens Tokens
}
AdditiveExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-AdditiveExpression
If AdditiveOperator is not AdditiveNone then AdditiveExpression must be non-nil, and vice-versa.
type AdditiveOperator ¶
type AdditiveOperator int
AdditiveOperator determines the additive type for AdditiveExpression
const ( AdditiveNone AdditiveOperator = iota AdditiveAdd AdditiveMinus )
Valid AdditiveOperator's
func (AdditiveOperator) String ¶
func (a AdditiveOperator) String() string
String implements the fmt.Stringer interface
type Argument ¶ added in v0.2.9
type Argument struct {
Spread bool
AssignmentExpression AssignmentExpression
Comments Comments
Tokens Tokens
}
Argument is an item in an ArgumentList and contains the spread information and the AssignementExpression
type Arguments ¶
Arguments as defined in TC39 https://tc39.es/ecma262/#prod-Arguments
type ArrayAssignmentPattern ¶ added in v0.0.10
type ArrayAssignmentPattern struct {
AssignmentElements []AssignmentElement
AssignmentRestElement *LeftHandSideExpression
Comments [3]Comments
Tokens Tokens
}
ArrayAssignmentPattern as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ArrayAssignmentPattern
type ArrayBindingPattern ¶
type ArrayBindingPattern struct {
BindingElementList []BindingElement
BindingRestElement *BindingElement
Comments [3]Comments
Tokens Tokens
}
ArrayBindingPattern as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ArrayBindingPattern
type ArrayElement ¶ added in v0.2.5
type ArrayElement struct {
Spread bool
AssignmentExpression AssignmentExpression
Comments Comments
Tokens Tokens
}
ArrayElement is an element of ElementList in ECMA-262 https://262.ecma-international.org/11.0/#prod-ElementList
type ArrayLiteral ¶
type ArrayLiteral struct {
ElementList []ArrayElement
Comments [2]Comments
Tokens Tokens
}
ArrayLiteral as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ArrayLiteral
type ArrowFunction ¶
type ArrowFunction struct {
Async bool
BindingIdentifier *Token
FormalParameters *FormalParameters
AssignmentExpression *AssignmentExpression
FunctionBody *Block
Comments [5]Comments
Tokens Tokens
}
ArrowFunction as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ArrowFunction
Also includes AsyncArrowFunction.
Only one of BindingIdentifier or FormalParameters must be non-nil.
Only one of AssignmentExpression or FunctionBody must be non-nil.
type AssignmentElement ¶ added in v0.0.10
type AssignmentElement struct {
DestructuringAssignmentTarget DestructuringAssignmentTarget
Initializer *AssignmentExpression
Tokens Tokens
}
AssignmentElement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-AssignmentElement
type AssignmentExpression ¶
type AssignmentExpression struct {
ConditionalExpression *ConditionalExpression
ArrowFunction *ArrowFunction
LeftHandSideExpression *LeftHandSideExpression
AssignmentPattern *AssignmentPattern
Yield bool
Delegate bool
AssignmentOperator AssignmentOperator
AssignmentExpression *AssignmentExpression
Comments [2]Comments
Tokens Tokens
}
AssignmentExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-AssignmentExpression
It is only valid for one of ConditionalExpression, ArrowFunction, LeftHandSideExpression, and AssignmentPattern to be non-nil.
If LeftHandSideExpression, or AssignmentPattern are non-nil, then AssignmentOperator must not be AssignmentNone and AssignmentExpression must be non-nil.
If LeftHandSideArray, or LeftHandSideObject are non-nil, AssignmentOperator must be AssignmentAssign.
If Yield is true, AssignmentExpression must be non-nil.
It is only valid for Delegate to be true if Yield is also true.
If AssignmentOperator is AssignmentNone LeftHandSideExpression must be nil.
If LeftHandSideExpression, and AssignmentPattern are nil and Yield is false, AssignmentExpression must be nil.
type AssignmentOperator ¶
type AssignmentOperator uint8
AssignmentOperator specifies the type of assignment in AssignmentExpression
const ( AssignmentNone AssignmentOperator = iota AssignmentAssign AssignmentMultiply AssignmentDivide AssignmentRemainder AssignmentAdd AssignmentSubtract AssignmentLeftShift AssignmentSignPropagatingRightShift AssignmentZeroFillRightShift AssignmentBitwiseAND AssignmentBitwiseXOR AssignmentBitwiseOR AssignmentExponentiation AssignmentLogicalAnd AssignmentLogicalOr AssignmentNullish )
Valid AssignmentOperator's
func (AssignmentOperator) String ¶
func (a AssignmentOperator) String() string
String implements the fmt.Stringer interface
type AssignmentPattern ¶ added in v0.0.10
type AssignmentPattern struct {
ObjectAssignmentPattern *ObjectAssignmentPattern
ArrayAssignmentPattern *ArrayAssignmentPattern
Comments [2]Comments
Tokens Tokens
}
AssignmentPattern as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-AssignmentPattern
Only one of ObjectAssignmentPattern or ArrayAssignmentPattern must be non-nil
type AssignmentProperty ¶ added in v0.0.10
type AssignmentProperty struct {
PropertyName PropertyName
DestructuringAssignmentTarget *DestructuringAssignmentTarget
Initializer *AssignmentExpression
Comments [2]Comments
Tokens Tokens
}
AssignmentProperty as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-AssignmentProperty
type BindingElement ¶
type BindingElement struct {
SingleNameBinding *Token
ArrayBindingPattern *ArrayBindingPattern
ObjectBindingPattern *ObjectBindingPattern
Initializer *AssignmentExpression
Comments [2]Comments
Tokens Tokens
}
BindingElement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-BindingElement
Only one of SingleNameBinding, ArrayBindingPattern, or ObjectBindingPattern must be non-nil.
The Initializer is optional.
type BindingProperty ¶
type BindingProperty struct {
PropertyName PropertyName
BindingElement BindingElement
Comments [2]Comments
Tokens Tokens
}
BindingProperty as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-BindingProperty
A SingleNameBinding, with or without an initializer, is cloned into the Property Name and Binding Element. This allows the Binding Element Identifier to be modified while keeping the correct Property Name
type BitwiseANDExpression ¶
type BitwiseANDExpression struct {
BitwiseANDExpression *BitwiseANDExpression
EqualityExpression EqualityExpression
Tokens Tokens
}
BitwiseANDExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-BitwiseANDExpression
type BitwiseORExpression ¶
type BitwiseORExpression struct {
BitwiseORExpression *BitwiseORExpression
BitwiseXORExpression BitwiseXORExpression
Tokens Tokens
}
BitwiseORExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-BitwiseORExpression
type BitwiseXORExpression ¶
type BitwiseXORExpression struct {
BitwiseXORExpression *BitwiseXORExpression
BitwiseANDExpression BitwiseANDExpression
Tokens Tokens
}
BitwiseXORExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-BitwiseXORExpression
type Block ¶
type Block struct {
StatementList []StatementListItem
Comments [2]Comments
Tokens Tokens
}
Block as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-Block
type CallExpression ¶
type CallExpression struct {
MemberExpression *MemberExpression
SuperCall bool
ImportCall *AssignmentExpression
CallExpression *CallExpression
Arguments *Arguments
Expression *Expression
IdentifierName *Token
TemplateLiteral *TemplateLiteral
PrivateIdentifier *Token
Comments [5]Comments
Tokens Tokens
}
CallExpression as defined in ECMA-262 https://tc39.es/ecma262/#prod-CallExpression
It is only valid for one of MemberExpression, ImportCall, or CallExpression to be non-nil or SuperCall to be true.
If MemberExpression is non-nil, or SuperCall is true, Arguments must be non-nil.
If CallExpression is non-nil, only one of Arguments, Expression, IdentifierName, TemplateLiteral, or PrivateIdentifier must be non-nil.
func (CallExpression) Format ¶
func (f CallExpression) Format(s fmt.State, v rune)
Format implements the fmt.Formatter interface
func (*CallExpression) IsSimple ¶ added in v0.1.0
func (ce *CallExpression) IsSimple() bool
IsSimple returns whether or not the CallExpression is classed as 'simple'
type CaseClause ¶
type CaseClause struct {
Expression Expression
StatementList []StatementListItem
Comments [2]Comments
Tokens Tokens
}
CaseClause as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-CaseClauses
type ClassDeclaration ¶
type ClassDeclaration struct {
BindingIdentifier *Token
ClassHeritage *LeftHandSideExpression
ClassBody []ClassElement
Comments [5]Comments
Tokens Tokens
}
ClassDeclaration as defined in ECMA-262 https://tc39.es/ecma262/#prod-ClassDeclaration
Also covers ClassExpression when BindingIdentifier is nil.
type ClassElement ¶ added in v0.2.0
type ClassElement struct {
Static bool
MethodDefinition *MethodDefinition
FieldDefinition *FieldDefinition
ClassStaticBlock *Block
Comments [3]Comments
Tokens Tokens
}
ClassElement as defined in ECMA-262 https://tc39.es/ecma262/#prod-ClassElement
Only one of MethodDefinition, FieldDefinition, or ClassStaticBlock must be non-nil.
If ClassStaticBlock is non-nil, Static should be true
type ClassElementName ¶ added in v0.2.0
type ClassElementName struct {
PropertyName *PropertyName
PrivateIdentifier *Token
Comments [2]Comments
Tokens Tokens
}
ClassElementName as defined in ECMA-262 https://tc39.es/ecma262/#prod-ClassElementName
Only one of PropertyName or PrivateIdentifier must be non-nil
type CoalesceExpression ¶
type CoalesceExpression struct {
CoalesceExpressionHead *CoalesceExpression
BitwiseORExpression BitwiseORExpression
Tokens Tokens
}
CoalesceExpression as defined in TC39 https://tc39.es/ecma262/#prod-CoalesceExpression
type Comments ¶ added in v1.6.0
type Comments []*Token
Comments is a collection of Comment Tokens.
func (Comments) LastIsMulti ¶ added in v1.6.0
type ConditionalExpression ¶
type ConditionalExpression struct {
LogicalORExpression *LogicalORExpression
CoalesceExpression *CoalesceExpression
True *AssignmentExpression
False *AssignmentExpression
Tokens Tokens
}
ConditionalExpression as defined in TC39 https://tc39.es/ecma262/#prod-ConditionalExpression
One, and only one, of LogicalORExpression or CoalesceExpression must be non-nil.
If True is non-nil, False must be non-nil also.
func WrapConditional ¶
func WrapConditional(p ConditionalWrappable) *ConditionalExpression
WrapConditional takes one of many types and wraps it in a *ConditionalExpression.
The accepted types/pointers are as follows:
ConditionalExpression LogicalORExpression LogicalANDExpression BitwiseORExpression BitwiseXORExpression BitwiseANDExpression EqualityExpression RelationalExpression ShiftExpression AdditiveExpression MultiplicativeExpression ExponentiationExpression UnaryExpression UpdateExpression LeftHandSideExpression CallExpression OptionalExpression NewExpression MemberExpression PrimaryExpression ArrayLiteral ObjectLiteral FunctionDeclaration (FunctionExpression) ClassDeclaration (ClassExpression) TemplateLiteral ParenthesizedExpression
type ConditionalWrappable ¶ added in v0.0.2
type ConditionalWrappable interface {
Type
// contains filtered or unexported methods
}
ConditionalWrappable is an interface that is implemented by all types that are accepted by the WrapConditional function, and is the returned type of the UnwrapConditional function
func UnwrapConditional ¶
func UnwrapConditional(c *ConditionalExpression) ConditionalWrappable
UnwrapConditional returns the first value up the ConditionalExpression chain that contains all of the information required to rebuild the lower chain.
Possible returns types are as follows:
*ConditionalExpression *LogicalORExpression *LogicalANDExpression *BitwiseORExpression *BitwiseXORExpression *BitwiseANDExpression *EqualityExpression *RelationalExpression *ShiftExpression *AdditiveExpression *MultiplicativeExpression *ExponentiationExpression *UnaryExpression *UpdateExpression *CallExpression *OptionalExpression *NewExpression *MemberExpression *PrimaryExpression *ArrayLiteral *ObjectLiteral *FunctionDeclaration (FunctionExpression) *ClassDeclaration (ClassExpression) *TemplateLiteral *ParenthesizedExpression
type Declaration ¶
type Declaration struct {
ClassDeclaration *ClassDeclaration
FunctionDeclaration *FunctionDeclaration
LexicalDeclaration *LexicalDeclaration
Comments Comments
Tokens Tokens
}
Declaration as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-Declaration
Only one of ClassDeclaration, FunctionDeclaration or LexicalDeclaration must be non-nil
type DestructuringAssignmentTarget ¶ added in v0.0.10
type DestructuringAssignmentTarget struct {
LeftHandSideExpression *LeftHandSideExpression
AssignmentPattern *AssignmentPattern
Tokens Tokens
}
DestructuringAssignmentTarget as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-DestructuringAssignmentTarget
Only one of LeftHandSideExpression or AssignmentPattern must be non-nil
type EqualityExpression ¶
type EqualityExpression struct {
EqualityExpression *EqualityExpression
EqualityOperator EqualityOperator
RelationalExpression RelationalExpression
Tokens Tokens
}
EqualityExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-EqualityExpression
If EqualityOperator is not EqualityNone, then EqualityExpression must be non-nil, and vice-versa.
type EqualityOperator ¶
type EqualityOperator int
EqualityOperator determines the type of EqualityExpression
const ( EqualityNone EqualityOperator = iota EqualityEqual EqualityNotEqual EqualityStrictEqual EqualityStrictNotEqual )
Valid EqualityOperator's
func (EqualityOperator) String ¶
func (e EqualityOperator) String() string
String implements the fmt.Stringer interface
type ExponentiationExpression ¶
type ExponentiationExpression struct {
ExponentiationExpression *ExponentiationExpression
UnaryExpression UnaryExpression
Tokens Tokens
}
ExponentiationExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ExponentiationExpression
type ExportClause ¶
type ExportClause struct {
ExportList []ExportSpecifier
Comments [2]Comments
Tokens Tokens
}
ExportClause as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ExportClause
type ExportDeclaration ¶
type ExportDeclaration struct {
ExportClause *ExportClause
ExportFromClause *Token
FromClause *FromClause
VariableStatement *VariableStatement
Declaration *Declaration
DefaultFunction *FunctionDeclaration
DefaultClass *ClassDeclaration
DefaultAssignmentExpression *AssignmentExpression
Comments [7]Comments
Tokens Tokens
}
ExportDeclaration as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ExportDeclaration
It is only valid for one of ExportClause, ExportFromClause, VariableStatement, Declaration, DefaultFunction, DefaultClass, or DefaultAssignmentExpression to be non-nil.
FromClause can be non-nil exclusively or paired with ExportClause.
type ExportSpecifier ¶
type ExportSpecifier struct {
IdentifierName *Token
EIdentifierName *Token
Comments [4]Comments
Tokens Tokens
}
ExportSpecifier as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ExportSpecifier
IdentifierName must be non-nil, EIdentifierName should be non-nil.
type Expression ¶
type Expression struct {
Expressions []AssignmentExpression
Tokens Tokens
}
Expression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-Expression
Expressions must have a length of at least one to be valid.
type FieldDefinition ¶ added in v0.2.0
type FieldDefinition struct {
ClassElementName ClassElementName
Initializer *AssignmentExpression
Comments Comments
Tokens Tokens
}
FieldDefinition as defined in ECMA-262 https://tc39.es/ecma262/#prod-FieldDefinition
type ForType ¶
type ForType uint8
ForType determines which kind of for-loop is described by IterationStatementFor
type FormalParameters ¶
type FormalParameters struct {
FormalParameterList []BindingElement
BindingIdentifier *Token
ArrayBindingPattern *ArrayBindingPattern
ObjectBindingPattern *ObjectBindingPattern
Comments [5]Comments
Tokens Tokens
}
FormalParameters as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-FormalParameters
Only one of BindingIdentifier, ArrayBindingPattern, or ObjectBindingPattern can be non-nil.
type FromClause ¶
FromClause as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-FromClause
ModuleSpecifier must be non-nil.
type FunctionDeclaration ¶
type FunctionDeclaration struct {
Type FunctionType
BindingIdentifier *Token
FormalParameters FormalParameters
FunctionBody Block
Comments [5]Comments
Tokens Tokens
}
FunctionDeclaration as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-FunctionDeclaration
Also parses FunctionExpression, for when BindingIdentifier is nil.
Include TC39 proposal for async generator functions https://github.com/tc39/proposal-async-iteration#async-generator-functions
type FunctionType ¶
type FunctionType uint8
FunctionType determines which type of function is specified by FunctionDeclaration
const ( FunctionNormal FunctionType = iota FunctionGenerator FunctionAsync FunctionAsyncGenerator )
Valid FunctionTypes
func (FunctionType) String ¶
func (ft FunctionType) String() string
String implements the fmt.Stringer interface
type IfStatement ¶
type IfStatement struct {
Expression Expression
Statement Statement
ElseStatement *Statement
Comments [6]Comments
Tokens Tokens
}
IfStatement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-IfStatement
type ImportClause ¶
type ImportClause struct {
ImportedDefaultBinding *Token
NameSpaceImport *Token
NamedImports *NamedImports
Comments [6]Comments
Tokens Tokens
}
ImportClause as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ImportClause
At least one of ImportedDefaultBinding, NameSpaceImport, and NamedImports must be non-nil.
Both NameSpaceImport and NamedImports can not be non-nil.
type ImportDeclaration ¶
type ImportDeclaration struct {
*ImportClause
FromClause
*WithClause
Comments [4]Comments
Tokens Tokens
}
ImportDeclaration as defined in ECMA-262 https://tc39.es/ecma262/#prod-ImportDeclaration
type ImportSpecifier ¶
type ImportSpecifier struct {
IdentifierName *Token
ImportedBinding *Token
Comments [4]Comments
Tokens Tokens
}
ImportSpecifier as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ImportSpecifier
ImportedBinding must be non-nil, and IdentifierName should be non-nil.
type IterationStatementDo ¶
type IterationStatementDo struct {
Statement Statement
Expression Expression
Comments [6]Comments
Tokens Tokens
}
IterationStatementDo is the do-while part of IterationStatement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-IterationStatement
type IterationStatementFor ¶
type IterationStatementFor struct {
Type ForType
InitExpression *Expression
InitVar []VariableDeclaration
InitLexical *LexicalDeclaration
Conditional *Expression
Afterthought *Expression
LeftHandSideExpression *LeftHandSideExpression
ForBindingIdentifier *Token
ForBindingPatternObject *ObjectBindingPattern
ForBindingPatternArray *ArrayBindingPattern
In *Expression
Of *AssignmentExpression
Statement Statement
Comments [8]Comments
Tokens Tokens
}
IterationStatementFor is the for part of IterationStatement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-IterationStatement
Includes TC39 proposal for for-await-of https://github.com/tc39/proposal-async-iteration#the-async-iteration-statement-for-await-of
The Type determines which fields must be non-nil:
ForInLeftHandSide: LeftHandSideExpression and In ForInVar, ForInLet, ForInConst: ForBindingIdentifier, ForBindingPatternObject, or ForBindingPatternArray and In ForOfLeftHandSide, ForAwaitOfLeftHandSide: LeftHandSideExpression and Of ForOfVar, ForAwaitOfVar, ForOfLet, ForAwaitOfLet, ForOfConst, ForAwaitOfConst: ForBindingIdentifier, ForBindingPatternObject, or ForBindingPatternArray and Of
type IterationStatementWhile ¶
type IterationStatementWhile struct {
Expression Expression
Statement Statement
Comments [4]Comments
Tokens Tokens
}
IterationStatementWhile is the while part of IterationStatement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-IterationStatement
type LeftHandSideExpression ¶
type LeftHandSideExpression struct {
NewExpression *NewExpression
CallExpression *CallExpression
OptionalExpression *OptionalExpression
Comments Comments
Tokens Tokens
}
LeftHandSideExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-LeftHandSideExpression
It is only valid for one of NewExpression, CallExpression or OptionalExpression to be non-nil.
Includes OptionalExpression as per TC39 (2020-03)
func (LeftHandSideExpression) Format ¶
func (f LeftHandSideExpression) Format(s fmt.State, v rune)
Format implements the fmt.Formatter interface
func (*LeftHandSideExpression) IsSimple ¶ added in v0.1.0
func (lhs *LeftHandSideExpression) IsSimple() bool
IsSimple returns whether or not the LeftHandSideExpression is classed as 'simple'
type LetOrConst ¶
type LetOrConst bool
LetOrConst specifies whether a LexicalDeclaration is a let or const declaration
const ( Let LetOrConst = false Const LetOrConst = true )
Valid LetOrConst values
func (LetOrConst) String ¶
func (l LetOrConst) String() string
String implements the fmt.Stringer interface
type LexicalBinding ¶
type LexicalBinding struct {
BindingIdentifier *Token
ArrayBindingPattern *ArrayBindingPattern
ObjectBindingPattern *ObjectBindingPattern
Initializer *AssignmentExpression
Comments [2]Comments
Tokens Tokens
}
LexicalBinding as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-LexicalBinding
Only one of BindingIdentifier, ArrayBindingPattern or ObjectBindingPattern must be non-nil. The Initializer is optional only for a BindingIdentifier.
type LexicalDeclaration ¶
type LexicalDeclaration struct {
LetOrConst
BindingList []LexicalBinding
Tokens Tokens
}
LexicalDeclaration as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-LexicalDeclaration
type LogicalANDExpression ¶
type LogicalANDExpression struct {
LogicalANDExpression *LogicalANDExpression
BitwiseORExpression BitwiseORExpression
Tokens Tokens
}
LogicalANDExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-LogicalANDExpression
type LogicalORExpression ¶
type LogicalORExpression struct {
LogicalORExpression *LogicalORExpression
LogicalANDExpression LogicalANDExpression
Tokens Tokens
}
LogicalORExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-LogicalORExpression
type MemberExpression ¶
type MemberExpression struct {
MemberExpression *MemberExpression
PrimaryExpression *PrimaryExpression
Expression *Expression
IdentifierName *Token
TemplateLiteral *TemplateLiteral
SuperProperty bool
NewTarget bool
ImportMeta bool
Arguments *Arguments
PrivateIdentifier *Token
Comments [5]Comments
Tokens Tokens
}
MemberExpression as defined in ECMA-262 https://tc39.es/ecma262/#prod-MemberExpression
If PrimaryExpression is nil, SuperProperty is true, NewTarget is true, or ImportMeta is true, Expression, IdentifierName, TemplateLiteral, Arguments and PrivateIdentifier must be nil.
If Expression, IdentifierName, TemplateLiteral, Arguments, or PrivateIdentifier is non-nil, then MemberExpression must be non-nil.
It is only valid if one of Expression, IdentifierName, TemplateLiteral, Arguments, and PrivateIdentifier is non-nil.
func (MemberExpression) Format ¶
func (f MemberExpression) Format(s fmt.State, v rune)
Format implements the fmt.Formatter interface
func (*MemberExpression) IsSimple ¶ added in v0.1.0
func (me *MemberExpression) IsSimple() bool
IsSimple returns whether or not the MemberExpression is classed as 'simple'
type MethodDefinition ¶
type MethodDefinition struct {
Type MethodType
ClassElementName ClassElementName
Params FormalParameters
FunctionBody Block
Comments [4]Comments
Tokens Tokens
}
MethodDefinition as specified in ECMA-262 https://tc39.es/ecma262/#prod-MethodDefinition
type MethodType ¶
type MethodType uint8
MethodType determines the prefixes for MethodDefinition
const ( MethodNormal MethodType = iota MethodGenerator MethodAsync MethodAsyncGenerator MethodGetter MethodSetter )
Valid MethodType's
func (MethodType) String ¶
func (mt MethodType) String() string
String implements the fmt.Stringer interface
type Module ¶
type Module struct {
ModuleListItems []ModuleItem
Comments [2]Comments
Tokens Tokens
}
Module represents the top-level of a parsed JavaScript module
func ParseModule ¶
ParseModule parses a JavaScript module
func ScriptToModule ¶ added in v1.4.1
ScriptToModule converts a Script type to a Module type
type ModuleItem ¶
type ModuleItem struct {
ImportDeclaration *ImportDeclaration
StatementListItem *StatementListItem
ExportDeclaration *ExportDeclaration
Tokens Tokens
}
ModuleItem as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ModuleItem
Only one of ImportDeclaration, StatementListItem, or ExportDeclaration must be non-nil.
type MultiplicativeExpression ¶
type MultiplicativeExpression struct {
MultiplicativeExpression *MultiplicativeExpression
MultiplicativeOperator MultiplicativeOperator
ExponentiationExpression ExponentiationExpression
Tokens Tokens
}
MultiplicativeExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-MultiplicativeExpression
If MultiplicativeOperator is not MultiplicativeNone then MultiplicativeExpression must be non-nil, and vice-versa.
type MultiplicativeOperator ¶
type MultiplicativeOperator int
MultiplicativeOperator determines the multiplication type for MultiplicativeExpression
const ( MultiplicativeNone MultiplicativeOperator = iota MultiplicativeMultiply MultiplicativeDivide MultiplicativeRemainder )
Valid MultiplicativeOperator's
func (MultiplicativeOperator) String ¶
func (m MultiplicativeOperator) String() string
String implements the fmt.Stringer interface
type NamedImports ¶
type NamedImports struct {
ImportList []ImportSpecifier
Comments [2]Comments
Tokens Tokens
}
NamedImports as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-NamedImports
type NewExpression ¶
type NewExpression struct {
News []Comments
MemberExpression MemberExpression
Tokens Tokens
}
NewExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-NewExpression
The News field is a count of the number of 'new' keywords that proceed the MemberExpression
type ObjectAssignmentPattern ¶ added in v0.0.10
type ObjectAssignmentPattern struct {
AssignmentPropertyList []AssignmentProperty
AssignmentRestElement *LeftHandSideExpression
Comments [3]Comments
Tokens Tokens
}
ObjectAssignmentPattern as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ObjectAssignmentPattern
type ObjectBindingPattern ¶
type ObjectBindingPattern struct {
BindingPropertyList []BindingProperty
BindingRestProperty *Token
Comments [5]Comments
Tokens Tokens
}
ObjectBindingPattern as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ObjectBindingPattern
type ObjectLiteral ¶
type ObjectLiteral struct {
PropertyDefinitionList []PropertyDefinition
Comments [2]Comments
Tokens Tokens
}
ObjectLiteral as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ObjectLiteral
type OptionalChain ¶
type OptionalChain struct {
OptionalChain *OptionalChain
Arguments *Arguments
Expression *Expression
IdentifierName *Token
TemplateLiteral *TemplateLiteral
PrivateIdentifier *Token
Comments [4]Comments
Tokens Tokens
}
OptionalChain as defined in TC39 https://tc39.es/ecma262/#prod-OptionalExpression
It is only valid for one of Arguments, Expression, IdentifierName, TemplateLiteral, or PrivateIdentifier to be non-nil.
type OptionalExpression ¶
type OptionalExpression struct {
MemberExpression *MemberExpression
CallExpression *CallExpression
OptionalExpression *OptionalExpression
OptionalChain OptionalChain
Tokens Tokens
}
OptionalExpression as defined in TC39 https://tc39.es/ecma262/#prod-OptionalExpression
It is only valid for one of NewExpression, CallExpression or OptionalExpression to be non-nil.
type ParenthesizedExpression ¶ added in v0.1.1
type ParenthesizedExpression struct {
Expressions []AssignmentExpression
Comments [2]Comments
Tokens Tokens
}
ParenthesizedExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ParenthesizedExpression
type PrimaryExpression ¶
type PrimaryExpression struct {
This *Token
IdentifierReference *Token
Literal *Token
ArrayLiteral *ArrayLiteral
ObjectLiteral *ObjectLiteral
FunctionExpression *FunctionDeclaration
ClassExpression *ClassDeclaration
TemplateLiteral *TemplateLiteral
ParenthesizedExpression *ParenthesizedExpression
Tokens Tokens
}
PrimaryExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-PrimaryExpression
It is only valid is one IdentifierReference, Literal, ArrayLiteral, ObjectLiteral, FunctionExpression, ClassExpression, TemplateLiteral, or ParenthesizedExpression is non-nil or This is true.
func (PrimaryExpression) Format ¶
func (f PrimaryExpression) Format(s fmt.State, v rune)
Format implements the fmt.Formatter interface
func (*PrimaryExpression) IsSimple ¶ added in v0.1.0
func (pe *PrimaryExpression) IsSimple() bool
IsSimple returns whether or not the PrimaryExpression is classed as 'simple'
type PropertyDefinition ¶
type PropertyDefinition struct {
IsCoverInitializedName bool
PropertyName *PropertyName
AssignmentExpression *AssignmentExpression
MethodDefinition *MethodDefinition
Comments [2]Comments
Tokens Tokens
}
PropertyDefinition as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-PropertyDefinition
One, and only one, of AssignmentExpression or MethodDefinition must be non-nil.
It is only valid for PropertyName to be non-nil when AssignmentExpression is also non-nil.
The IdentifierReference is stored within PropertyName.
type PropertyName ¶
type PropertyName struct {
LiteralPropertyName *Token
ComputedPropertyName *AssignmentExpression
Comments [2]Comments
Tokens Tokens
}
PropertyName as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-PropertyName
Only one of LiteralPropertyName or ComputedPropertyName must be non-nil.
type RelationalExpression ¶
type RelationalExpression struct {
PrivateIdentifier *Token
RelationalExpression *RelationalExpression
RelationshipOperator RelationshipOperator
ShiftExpression ShiftExpression
Comments [2]Comments
Tokens Tokens
}
RelationalExpression as defined in ECMA-262 https://tc39.es/ecma262/#prod-RelationalExpression
If PrivateIdentifier is non-nil, then RelationshipOperator should be RelationshipIn.
If PrivateIdentifier is nil and RelationshipOperator does not equal RelationshipNone, then RelationalExpression should be non-nil
type RelationshipOperator ¶
type RelationshipOperator int
RelationshipOperator determines the relationship type for RelationalExpression
const ( RelationshipNone RelationshipOperator = iota RelationshipLessThan RelationshipGreaterThan RelationshipLessThanEqual RelationshipGreaterThanEqual RelationshipInstanceOf RelationshipIn )
Valid RelationshipOperator's
func (RelationshipOperator) String ¶
func (r RelationshipOperator) String() string
String implements the fmt.Stringer interface
type Script ¶
type Script struct {
StatementList []StatementListItem
Comments [2]Comments
Tokens Tokens
}
Script represents the top-level of a parsed JavaScript text
func ParseScript ¶
ParseScript parses a JavaScript input into an AST.
It is recommended to use ParseModule instead of this function.
type ShiftExpression ¶
type ShiftExpression struct {
ShiftExpression *ShiftExpression
ShiftOperator ShiftOperator
AdditiveExpression AdditiveExpression
Tokens Tokens
}
ShiftExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-ShiftExpression
If ShiftOperator is not ShiftNone then ShiftExpression must be non-nil, and vice-versa.
type ShiftOperator ¶
type ShiftOperator int
ShiftOperator determines the shift type for ShiftExpression
const ( ShiftNone ShiftOperator = iota ShiftLeft ShiftRight ShiftUnsignedRight )
Valid ShiftOperator's
func (ShiftOperator) String ¶
func (s ShiftOperator) String() string
String implements the fmt.Stringer interface
type Statement ¶
type Statement struct {
Type StatementType
BlockStatement *Block
VariableStatement *VariableStatement
ExpressionStatement *Expression
IfStatement *IfStatement
IterationStatementDo *IterationStatementDo
IterationStatementWhile *IterationStatementWhile
IterationStatementFor *IterationStatementFor
SwitchStatement *SwitchStatement
WithStatement *WithStatement
LabelIdentifier *Token
LabelledItemFunction *FunctionDeclaration
LabelledItemStatement *Statement
TryStatement *TryStatement
Comments [2]Comments
Tokens Tokens
}
Statement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-Statement
It is only valid for one of the pointer type to be non-nil.
If LabelIdentifier is non-nil, either one of LabelledItemFunction, or LabelledItemStatement must be non-nil, or Type must be StatementContinue or StatementBreak.
If Type is StatementThrow, ExpressionStatement must be non-nil.
type StatementListItem ¶
type StatementListItem struct {
Statement *Statement
Declaration *Declaration
Comments [2]Comments
Tokens Tokens
}
StatementListItem as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-StatementListItem Only one of Statement, or Declaration must be non-nil.
type StatementType ¶
type StatementType uint8
StatementType determines the type of a Statement type
const ( StatementNormal StatementType = iota StatementContinue StatementBreak StatementReturn StatementThrow StatementDebugger )
Valid StatementType's
func (StatementType) String ¶
func (st StatementType) String() string
String implements the fmt.Stringer interface
type SwitchStatement ¶
type SwitchStatement struct {
Expression Expression
CaseClauses []CaseClause
DefaultClause []StatementListItem
PostDefaultCaseClauses []CaseClause
Comments [9]Comments
Tokens Tokens
}
SwitchStatement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-SwitchStatement
type TemplateLiteral ¶
type TemplateLiteral struct {
NoSubstitutionTemplate *Token
TemplateHead *Token
Expressions []Expression
TemplateMiddleList []*Token
TemplateTail *Token
Tokens Tokens
}
TemplateLiteral as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-TemplateLiteral
If NoSubstitutionTemplate is non-nil it is only valid for TemplateHead, Expressions, TemplateMiddleList, and TemplateTail to be nil.
If NoSubstitutionTemplate is nil, the TemplateHead, Expressions, and TemplateTail must be non-nil. TemplateMiddleList must have a length of one less than the length of Expressions.
type TemplateType ¶ added in v1.4.1
type TemplateType byte
TemplateType determines the type of Template used in QuoteTemplate.
const ( TemplateNoSubstitution TemplateType = iota TemplateHead TemplateMiddle TemplateTail )
func TokenTypeToTemplateType ¶ added in v1.4.1
func TokenTypeToTemplateType(tokenType parser.TokenType) TemplateType
TokenTypeToTemplateType converts from a parser.TokenType to the appropriate TemplateType.
Invalid TokenTypes return 255.
type Token ¶
Token represents a single parsed token with source positioning.
func (Token) IsTypescript ¶ added in v1.6.0
IsTypescript returns true when the token was processed as part of a Typescript section.
type Tokeniser ¶ added in v1.3.0
type Tokeniser interface {
TokeniserState(parser.TokenFunc)
Iter(func(parser.Token) bool)
GetError() error
}
Tokeniser is an interface representing a tokeniser.
func AsTypescript ¶ added in v1.4.0
AsTypescript converts the tokeniser to one that reads Typescript.
When used with ParseScript or ParseModule, will produce JavaScript AST from most valid Typescript files, though it may also parse invalid Typescript.
Currently does not support any Typescript feature that requires code-gen or lookahead/lookback, such as the Typescript 'private' modifier, or the 'enum' and 'namespace' declarations.
type TryStatement ¶
type TryStatement struct {
TryBlock Block
CatchParameterBindingIdentifier *Token
CatchParameterObjectBindingPattern *ObjectBindingPattern
CatchParameterArrayBindingPattern *ArrayBindingPattern
CatchBlock *Block
FinallyBlock *Block
Comments [10]Comments
Tokens Tokens
}
TryStatement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-TryStatement
Only one of CatchParameterBindingIdentifier, CatchParameterObjectBindingPattern, and CatchParameterArrayBindingPattern can be non-nil, and must be so if CatchBlock is non-nil.
If one of CatchParameterBindingIdentifier, CatchParameterObjectBindingPattern, CatchParameterArrayBindingPattern is non-nil, then CatchBlock must be non-nil.
type UnaryExpression ¶
type UnaryExpression struct {
UnaryOperators []UnaryOperatorComments
UpdateExpression UpdateExpression
Tokens Tokens
}
UnaryExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-UnaryExpression
type UnaryOperator ¶
type UnaryOperator byte
UnaryOperator determines a unary operator within UnaryExpression
const ( UnaryNone UnaryOperator = iota UnaryDelete UnaryVoid UnaryTypeOf UnaryAdd UnaryMinus UnaryBitwiseNot UnaryLogicalNot UnaryAwait )
Valid UnaryOperator's
func (UnaryOperator) String ¶
func (u UnaryOperator) String() string
String implements the fmt.Stringer interface
type UnaryOperatorComments ¶ added in v1.6.0
type UnaryOperatorComments struct {
UnaryOperator
Comments
}
UnaryOperatorComments is a UnaryOperator and any following comments.
type UpdateExpression ¶
type UpdateExpression struct {
LeftHandSideExpression *LeftHandSideExpression
UpdateOperator UpdateOperator
UnaryExpression *UnaryExpression
Comments Comments
Tokens Tokens
}
UpdateExpression as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-UpdateExpression
If UpdateOperator is UpdatePreIncrement or UpdatePreDecrement UnaryExpression must be non-nil, and vice-versa. In all other cases, LeftHandSideExpression must be non-nil.
type UpdateOperator ¶
type UpdateOperator int
UpdateOperator determines the type of update operation for UpdateExpression
const ( UpdateNone UpdateOperator = iota UpdatePostIncrement UpdatePostDecrement UpdatePreIncrement UpdatePreDecrement )
Valid UpdateOperator's
func (UpdateOperator) String ¶
func (u UpdateOperator) String() string
String implements the fmt.Stringer interface
type VariableDeclaration ¶
type VariableDeclaration = LexicalBinding
VariableDeclaration as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-VariableDeclaration
type VariableStatement ¶
type VariableStatement struct {
VariableDeclarationList []VariableDeclaration
Tokens Tokens
}
VariableStatement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-VariableStatement
VariableDeclarationList must have a length or at least one.
type WithClause ¶ added in v1.5.0
WithClause as defined in ECMA-262 https://tc39.es/ecma262/#prod-WithClause
type WithEntry ¶ added in v1.5.0
WithEntry as defined in ECMA-262 https://tc39.es/ecma262/#prod-WithEntries
type WithStatement ¶
type WithStatement struct {
Expression Expression
Statement Statement
Comments [4]Comments
Tokens Tokens
}
WithStatement as defined in ECMA-262 https://262.ecma-international.org/11.0/#prod-WithStatement