Package-level declarations

Types

Link copied to clipboard

Base class for the entries of an object literal: ObjectProperty and SpreadObjectProperty.

Link copied to clipboard
class ArrayComprehension(pos: Int = -1, len: Int = 1) : Scope

An array comprehension such as [expr for (x in y) if (cond)]. Node type is Token.ARRAYCOMP. It introduces a scope, so it extends Scope.

Link copied to clipboard
class ArrayComprehensionLoop(pos: Int = -1, len: Int = 1) : ForInLoop

One for clause inside an ArrayComprehension or a generator expression. It carries no body: the comprehension result plays that role.

Link copied to clipboard
class ArrayLiteral(pos: Int = -1, len: Int = 1) : AstNode, DestructuringForm

An array literal, which doubles as an array destructuring target. Node type is Token.ARRAYLIT.

Link copied to clipboard

An assignment expression such as a = b or a += b. The node type is the assignment operator token.

Link copied to clipboard
abstract class AstNode(pos: Int = -1, len: Int = 1) : Node, Comparable<AstNode>

Base class for AST node types. The AST represents the physical source code, which makes it useful for IDEs and pretty-printers; the parser must not rewrite the tree when producing it.

Link copied to clipboard
class AstRoot(pos: Int = -1) : ScriptNode

Root of a parse tree. Holds the statements and functions in the script plus the Comment nodes attached to the script as a whole. Node type is Token.SCRIPT.

Link copied to clipboard

A BigInt literal such as 123n. Node type is Token.BIGINT.

Link copied to clipboard
class BreakStatement(pos: Int = -1, len: Int = 1) : Jump

A break statement, with or without a label. Node type is Token.BREAK.

Link copied to clipboard
class CatchClause(pos: Int = -1, len: Int = 1) : AstNode

One catch clause of a try statement. Node type is Token.CATCH. The catchCondition is the SpiderMonkey catch (e if cond) extension.

Link copied to clipboard
class Comment(pos: Int, len: Int, type: Token.CommentType, value: String) : AstNode

A comment. Node type is Token.COMMENT.

Link copied to clipboard
class ComputedPropertyKey(pos: Int, len: Int) : AstNode

A computed property key such as the [a + b] in { [a + b]: 1 }. Node type is Token.COMPUTED_PROPERTY.

Link copied to clipboard
class ConditionalExpression(pos: Int = -1, len: Int = 1) : AstNode

A ternary expression test ? then : else. Node type is Token.HOOK.

Link copied to clipboard

A continue statement, with or without a label. Node type is Token.CONTINUE.

Link copied to clipboard

Shared by ArrayLiteral and ObjectLiteral, the two node types that can appear in a destructuring position.

Link copied to clipboard
class DoLoop(pos: Int = -1, len: Int = 1) : Loop

A do ... while loop. Node type is Token.DO.

Link copied to clipboard

A bracketed element access such as a[b]. Node type is Token.GETELEM.

Link copied to clipboard
class EmptyExpression(pos: Int = -1, len: Int = 1) : AstNode

An empty expression. Node type is Token.EMPTY. Wrap it in an ExpressionStatement to make an empty statement.

Link copied to clipboard
class EmptyStatement(pos: Int = -1, len: Int = 1) : AstNode

An empty statement, a lone semicolon. Node type is Token.EMPTY.

Link copied to clipboard

An error reporter that records problems instead of throwing, for IDE-mode parsing. Only the offset-and-length overloads are supported; the line-based ones throw.

Link copied to clipboard
class ErrorNode(pos: Int = -1, len: Int = 1) : AstNode

A placeholder the parser leaves where an expression failed to parse, in error-recovery mode. Node type is Token.ERROR. It renders as the empty string.

Link copied to clipboard
class ExpressionStatement(pos: Int = -1, len: Int = 1) : AstNode

An expression statement. Node type is Token.EXPR_VOID when the value is discarded, and Token.EXPR_RESULT when it becomes the script result.

Link copied to clipboard
open class ForInLoop(pos: Int = -1, len: Int = 1) : Loop

A for..in or for..of loop, and with isForEach the SpiderMonkey for each..in form. Node type is Token.FOR.

Link copied to clipboard
class ForLoop(pos: Int = -1, len: Int = 1) : Loop

A C-style for (init; cond; incr) loop. Node type is Token.FOR.

Link copied to clipboard
open class FunctionCall(pos: Int = -1, len: Int = 1) : AstNode

A function or method call. Node type is Token.CALL.

Link copied to clipboard
open class FunctionNode(pos: Int = -1, name: Name? = null) : ScriptNode

A JavaScript function declaration or expression. Node type is Token.FUNCTION.

Link copied to clipboard
class GeneratorExpression(pos: Int = -1, len: Int = 1) : Scope

A generator expression such as (expr for (x in y) if (cond)). Node type is Token.GENEXPR. It introduces a scope, so it extends Scope.

Link copied to clipboard
class GeneratorExpressionLoop(pos: Int = -1, len: Int = 1) : ForInLoop

One for clause inside a generator expression. Unlike ArrayComprehensionLoop it does not support the for each form.

Link copied to clipboard
class GeneratorMethodDefinition(pos: Int, len: Int, methodName: AstNode) : AstNode

The *name part of a generator method in an object literal. Node type is Token.MUL.

Link copied to clipboard

Error reporting protocol for IDE-mode parsing. If the parser's error reporter implements this interface, these offset/length overloads are called instead of the line-based ErrorReporter versions.

Link copied to clipboard
class IfStatement(pos: Int = -1, len: Int = 1) : AstNode

An if statement with an optional else part. Node type is Token.IF.

Link copied to clipboard
open class InfixExpression(pos: Int = -1, len: Int = 1) : AstNode

A binary expression: left op right. The node type is the operator token, so a plus expression has type Token.ADD.

Link copied to clipboard
open class Jump(nodeType: Int = Token.ERROR) : AstNode

Used for code generation. During codegen the AST is lowered to an IR where loops, ifs, switches and other control flow become labeled jumps. In IDE mode the resulting AST holds no instances of this class.

Link copied to clipboard

A keyword literal: this, super, null, undefined, true, false or debugger. The node type is the keyword's own token, and setting it rejects anything else.

Link copied to clipboard
class Label : Jump

One label in a LabeledStatement, for example the outer in outer: for (;;) {}. Node type is Token.LABEL.

Link copied to clipboard
class LabeledStatement(pos: Int = -1, len: Int = 1) : AstNode

A labeled statement. A statement can carry several labels, as in a: b: c: while (...) {}. Node type is Token.EXPR_VOID.

Link copied to clipboard
class LetNode(pos: Int = -1, len: Int = 1) : Scope

A let expression or statement, as in let (a = 1) expr. Node type is Token.LETEXPR. It introduces a scope.

Link copied to clipboard
abstract class Loop(pos: Int = -1, len: Int = 1) : Scope

Base class for loop nodes. A loop introduces a scope, so it extends Scope.

Link copied to clipboard
class Name : AstNode

A simple name: an identifier that is not a keyword. Node type is Token.NAME.

Link copied to clipboard
class NewExpression(pos: Int = -1, len: Int = 1) : FunctionCall

A new expression. Node type is Token.NEW. The initializer is Rhino's non-standard new Foo() {a: 1} object-initializer extension.

Link copied to clipboard
fun interface NodeVisitor

Simple visitor for traversing the AST. Nodes are visited in an arbitrary order; the visitor casts nodes to the right type based on their token type.

Link copied to clipboard

A Number literal. Node type is Token.NUMBER.

Link copied to clipboard
class ObjectLiteral(pos: Int = -1, len: Int = 1) : AstNode, DestructuringForm

An object literal, which doubles as an object destructuring target. Node type is Token.OBJECTLIT.

Link copied to clipboard
class ObjectProperty(pos: Int = -1, len: Int = 1) : AbstractObjectProperty

One key: value entry of an object literal, or a getter, setter or method definition. The node type is Token.COLON, Token.GET, Token.SET or Token.METHOD.

Link copied to clipboard

A parenthesized expression. Node type is Token.LP.

Link copied to clipboard
class ParseProblem(var type: ParseProblem.Type, var message: String?, var sourceName: String?, var fileOffset: Int, var length: Int)

One error or warning recorded by an ErrorCollector during a parse.

Link copied to clipboard

A dotted property access such as a.b. Node type is Token.GETPROP. The target is the left side and the property is the Name on the right.

Link copied to clipboard
class RegExpLiteral(pos: Int = -1, len: Int = 1) : AstNode

A regular expression literal. Node type is Token.REGEXP. The value is the pattern without the delimiting slashes and flags are the trailing letters.

Link copied to clipboard
class ReturnStatement(pos: Int = -1, len: Int = 1) : AstNode

A return statement. Node type is Token.RETURN. The returnValue is null for a bare return;.

Link copied to clipboard
open class Scope(pos: Int = -1, len: Int = 1) : Jump

A scope in the lexical scope chain. Base type for every AstNode that introduces a scope.

Link copied to clipboard
open class ScriptNode(pos: Int = -1) : Scope

Base type for AstRoot and FunctionNode, which collect much of the same information.

Link copied to clipboard
class Spread(pos: Int, len: Int) : AstNode

A spread element ...expr. Node type is Token.DOTDOTDOT.

Link copied to clipboard

A ...expr entry of an object literal. Node type is Token.DOTDOTDOT.

Link copied to clipboard

A single- or double-quoted string literal. Node type is Token.STRING.

Link copied to clipboard
class SwitchCase(pos: Int = -1, len: Int = 1) : AstNode

One case or default clause of a switch. Node type is Token.CASE; a null expression means it is the default clause.

Link copied to clipboard
class SwitchStatement(pos: Int = -1) : Scope

A switch statement. Node type is Token.SWITCH. It introduces a scope.

Link copied to clipboard
class Symbol

A symbol-table entry.

Link copied to clipboard
class TaggedTemplateLiteral(pos: Int = -1, len: Int = 1) : AstNode

A tagged template such as `tag`a${b}c` `. Node type is Token.TAGGED_TEMPLATE_LITERAL.

Link copied to clipboard
class TemplateCharacters(pos: Int = -1, len: Int = 1) : AstNode

The literal text between substitutions in a template literal. Node type is Token.TEMPLATE_CHARS. value is the cooked text and rawValue the source text.

Link copied to clipboard
class TemplateLiteral(pos: Int = -1, len: Int = 1) : AstNode

A template literal. Node type is Token.TEMPLATE_LITERAL. Its elements alternate between TemplateCharacters runs and substitution expressions.

Link copied to clipboard

A throw statement. Node type is Token.THROW.

Link copied to clipboard
class TryStatement(pos: Int = -1, len: Int = 1) : AstNode

A try statement with its catch clauses and optional finally block. Node type is Token.TRY.

Link copied to clipboard

A prefix unary expression such as !a, -a, typeof a or void a. The node type is the operator token. Increment and decrement live in UpdateExpression.

Link copied to clipboard

An increment or decrement expression, prefix or postfix. The node type is Token.INC or Token.DEC.

Link copied to clipboard
class VariableDeclaration(pos: Int = -1, len: Int = 1) : AstNode

A var, const or let declaration holding one or more VariableInitializer entries. The node type is the declaration keyword's token, and setting it rejects anything else.

Link copied to clipboard
class VariableInitializer(pos: Int = -1, len: Int = 1) : AstNode

One name = value entry of a VariableDeclaration. The target is a Name, or an array or object literal for a destructuring binding. Node type matches the declaration keyword.

Link copied to clipboard
class WhileLoop(pos: Int = -1, len: Int = 1) : Loop

A while loop. Node type is Token.WHILE.

Link copied to clipboard
class WithStatement(pos: Int = -1, len: Int = 1) : AstNode

A with statement. Node type is Token.WITH.

Link copied to clipboard
class Yield : AstNode

A yield expression. Node type is Token.YIELD, or Token.YIELD_STAR for yield*.