Class

class Annotation

public class Annotation <: Node {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a built-in annotation node of the compiler.

Examples of an Annotation node: @CallingConv[xxx], @Attribute[xxx], and @When[condition]

Parent Type:

prop arguments

public mut prop arguments: ArrayList<Argument>

Description: Obtains or sets the parameter sequence in Annotation, for example, xxx in @CallingConv[xxx].

Type: ArrayList<Argument>

prop at

public mut prop at: Token

Description: Obtains or sets the operator @ in an Annotation node.

Type: Token

Throws:

prop attributes

public mut prop attributes: Tokens

Description: Obtains or sets an attribute value in Attribute in @Attribute format, for example, xxx in @Attribute[xxx].

Type: Tokens

prop condition

public mut prop condition: Expr

Description: Obtains or sets a condition expression in conditional compilation in @When format, for example, xxx in @When[xxx].

Type: Expr

Throws:

prop identifier

public mut prop identifier: Token

Description: Obtains or sets the identifier of an Annotation node, for example, CallingConv in @CallingConv[xxx].

Type: Token

init()

public init()

Description: Constructs a default Annotation object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an Annotation object based on input lexical units.

Parameters:

Throws:

class Argument

public class Argument <: Node {
    public init()
}

Description: Specifies an argument node in function call.

Example: arg:value in foo(arg:value)

Parent Type:

prop colon

public mut prop colon: Token

Description: Obtains or sets the operator ":" in an Argument node, which may be an ILLEGAL lexical unit.

Type: Token

Throws:

prop expr

public mut prop expr: Expr

Description: Obtains or sets the expression in an Argument node, for example, value in arg:value.

Type: Expr

prop identifier

public mut prop identifier: Token

Description: Obtains or sets the identifier in an Argument node, for example, arg in arg:value, which may be an ILLEGAL lexical unit.

Type: Token

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the keyword inout in an Argument node, which may be an ILLEGAL lexical unit.

Type: Token

init()

public init()

Description: Constructs a default Argument object.

class ArrayLiteral

public class ArrayLiteral <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an Array literal node.

An ArrayLiteral node is specified in the format of [element1, element2, ... , elementN], where each element is an expression.

Parent Type:

prop elements

public mut prop elements: ArrayList<Expr>

Description: Obtains or sets the expression list in ArrayLiteral.

Type: ArrayList<Expr>

prop lSquare

public mut prop lSquare: Token

Description: Obtains or sets the left square bracket ([) in ArrayLiteral.

Type: Token

Throws:

prop rSquare

public mut prop rSquare: Token

Description: Obtains or sets the right square bracket (]) in ArrayLiteral.

Type: Token

Throws:

  • ASTException: If Token is not a right square bracket (]), this exception is thrown.

init()

public init()

Description: Constructs a default ArrayLiteral object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an ArrayLiteral object.

Parameters:

Throws:

class AsExpr

public class AsExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a type check expression.

An AsExpr expression is in the e as T format and of the Option<T> type. e can be any type of expression, and T can be any type.

Parent Type:

prop expr

public mut prop expr: Expr

Description: Obtains or sets the expression node in an AsExpr node.

Type: Expr

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the operator as in an AsExpr node.

Type: Token

Throws:

prop shiftType

public mut prop shiftType: TypeNode

Description: Obtains or sets the target type in an AsExpr node.

Type: TypeNode

init()

public init()

Description: Constructs a default AsExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an AsExpr object.

Parameters:

Throws:

class AssignExpr

public class AssignExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an assignment expression node.

Such node changes the value of the left operand to the value of the right operand. Example of an AssignExpr node: a = b

Parent Type:

prop assign

public mut prop assign: Token

Description: Obtains or sets the assignment operator (such as =) in an AssignExpr node.

Type: Token

Throws:

prop leftExpr

public mut prop leftExpr: Expr

Description: Obtains or sets the left operand in an AssignExpr node.

Type: Expr

prop rightExpr

public mut prop rightExpr: Expr

Description: Obtains or sets the right operand in an AssignExpr node.

Type: Expr

init()

public init()

Description: Constructs a default AssignExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an AssignExpr object.

Parameters:

Throws:

class BinaryExpr

public class BinaryExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a binary operation expression node.

Examples of a BinaryExpr node: a + b and a - b

Parent Type:

prop leftExpr

public mut prop leftExpr: Expr

Description: Obtains or sets the expression node on the left of the operator in a BinaryExpr node.

Type: Expr

prop op

public mut prop op: Token

Description: Obtains or sets the binary operator in a BinaryExpr node.

Type: Token

prop rightExpr

public mut prop rightExpr: Expr

Description: Obtains or sets the expression node on the right of the operator in a BinaryExpr node.

Type: Expr

init()

public init()

Description: Constructs a default BinaryExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a BinaryExpr object.

Parameters:

Throws:

class Block

public class Block <: Expr {
    public init()
}

Description: Specifies a block node.

Block is a structure consisting of a pair of matching braces and an optional expression/declaration sequence in them.

Parent Type:

prop lBrace

public mut prop lBrace: Token

Description: Obtains or sets the left curly bracket ({) in a Block.

Type: Token

Throws:

prop nodes

public mut prop nodes: ArrayList<Node>

Description: Obtains or sets the expression or declaration sequence in Block.

Type: ArrayList<Node>

prop rBrace

public mut prop rBrace: Token

Description: Obtains or sets the right curly bracket (}) in a Block.

Type: Token

Throws:

init()

public init()

Description: Constructs a default Block object.

Note:

A Block node cannot exist independently of the expression or declaration node. Therefore, no other constructor is provided.

class Body

public class Body <: Node {
    public init()
    public init(decls: ArrayList<Decl>)
}

Description: Specifies a structure of Class, Struct, or Interface type, or consisting of {} and a group of declaration nodes in the extension.

Parent Type:

prop decls

public mut prop decls: ArrayList<Decl>

Description: Obtains or sets the set of declaration nodes in Body.

Type: ArrayList<Decl>

prop lBrace

public mut prop lBrace: Token

Description: Obtains or sets the lexical unit {.

Type: Token

Throws:

prop rBrace

public mut prop rBrace: Token

Description: Obtains or sets the lexical unit }.

Type: Token

Throws:

init()

public init()

Description: Constructs a default Body object.

init(ArrayList<Decl>)

public init(decls: ArrayList<Decl>)

Description: Constructs a Body object.

Parameters:

class CallExpr

public class CallExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a function call node.

A CallExpr node contains an expression followed by a parameter list, for example, foo(100).

Parent Type:

prop arguments

public mut prop arguments: ArrayList<Argument>

Description: Obtains or sets the function parameters in a CallExpr node.

Type: ArrayList<Argument>

prop callFunc

public mut prop callFunc: Expr

Description: Obtains or sets the function call node in a CallExpr node.

Type: Expr

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in a CallExpr node.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in a CallExpr node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default CallExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a CallExpr object.

Parameters:

Throws:

class ClassDecl

public class ClassDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a class definition node.

A class is defined using the keyword class in the following sequence: modifier (default or not), class keyword, class name, optional type parameter, whether to specify a parent class or interface, optional generic constraint, and class body.

Parent Type:

prop body

public mut prop body: Body

Description: Obtains or sets the class body of a ClassDecl node.

Type: Body

prop superTypeBitAnds

public mut prop superTypeBitAnds: Tokens

Description: Obtains or sets the lexical unit sequence of the operator & in the parent class or parent interface declaration of a ClassDecl node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

prop superTypes

public mut prop superTypes: ArrayList<TypeNode>

Description: Obtains or sets the parent class or parent interface of a ClassDecl node.

Type: ArrayList<TypeNode>

prop upperBound

public mut prop upperBound: Token

Description: Obtains or sets the operator <:.

Type: Token

Throws:

init()

public init()

Description: Constructs a default ClassDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a ClassDecl object.

Parameters:

  • inputs: [Tokens](ast_package_classes.md#class-tokens: collection of lexical units (Tokens) used to construct the ClassDecl type

Throws:

class ConstPattern

public class ConstPattern <: Pattern {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a constant pattern node.

The constant pattern can be an integer literal, a character byte literal, a floating-point number literal, a character literal, a Boolean literal, a character string literal, or the like, for example, 1 in case 1 => 0.

Parent Type:

prop litConstExpr

public mut prop litConstExpr: LitConstExpr

Description: Obtains or sets the literal expression in a ConstPattern node.

Type: LitConstExpr

init()

public init()

Description: Constructs a default ConstPattern object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a ConstPattern object.

Parameters:

Throws:

class Constructor

public class Constructor <: Node {
    public init()
}

Description: Specifies a Constructor node in the enum type.

Example of a Constructor node: Year and Month(Float32, Float32) in enum TimeUnit { Year | Month(Float32, Float32)}

Note:

Constructor may have no parameter or a group of parameters of different types.

Parent Type:

prop identifier

public mut prop identifier: Token

Description: Obtains or sets the lexical unit identifier of Constructor.

Type: Token

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the lexical unit left parenthesis "(" in a Constructor node.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the lexical unit right parenthesis ")" in a Constructor node.

Type: Token

Throws:

prop typeArguments

public mut prop typeArguments: ArrayList<TypeNode>

Description: Obtains or sets the collection of optional parameter type nodes for a Constructor node.

Type: ArrayList<TypeNode>

init()

public init()

Description: Constructs a default Constructor object.

class Decl

public open class Decl <: Node

Description: Specifies the parent class of all declaration nodes, which is inherited from a Node node and provides universal APIs for all declaration nodes.

Note:

Class definition, interface definition, function definition, variable definition, enumeration definition, struct definition, extension definition, type alias definition, and macro definition all belong to a Decl node.

Parent Type:

prop annotations

public mut prop annotations: ArrayList<Annotation>

Description: Obtains or sets the annotation list applying to a Decl node.

Type: ArrayList<Annotation>

prop constraintCommas

public mut prop constraintCommas: Tokens

Description: Obtains or sets the lexical unit sequence comma (,) in a Decl node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence comma (,), this exception is thrown.

prop genericConstraint

public mut prop genericConstraint: ArrayList<GenericConstraint>

Description: Obtains or sets the generic constraint for defining a node, which may be empty, for example, where T <: Comparable<T> in func foo<T>() where T <: Comparable<T> {}.

Type: ArrayList<GenericConstraint>

prop genericParam

public mut prop genericParam: GenericParam

Description: Obtains or sets a formal parameter list. A type formal parameter list is enclosed by <>. Multiple type formal parameters are separated by commas (,).

Type: GenericParam

Throws:

  • ASTException: If the type formal parameter list is not defined for the node, this exception is thrown.

prop identifier

public mut open prop identifier: Token

Description: Obtains or sets the identifier for defining a node, for example, foo in class foo {}.

Type: Token

prop isGenericDecl()

public mut prop isGenericDecl: Bool

Description: Checks whether a node is a generic node.

Type: Bool: If the node is a generic node, true is returned. Otherwise, false is returned.

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the keyword for defining a node.

Type: Token

prop modifiers

public mut prop modifiers: ArrayList<Modifier>

Description: Obtains or sets the list of modifiers for modifying a node.

Type: ArrayList<Modifier>

func getAttrs()

public func getAttrs(): Tokens

Description: Obtains attributes of the current node. (Generally, a built-in Attribute is used to set a declared attribute value.)

Returns:

  • Tokens: attributes of the current node

func hasAttr(String)

public func hasAttr(attr: String): Bool

Description: Checks whether the current node has a certain attribute. (Generally, a built-in Attribute is used to set a declared attribute value.)

Parameters:

  • attr: String: attribute to be checked for whether it belongs to the node

Returns:

  • Bool: If the current node has the attribute, true is returned. Otherwise, false is returned.

class DoWhileExpr

public class DoWhileExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a do-while expression.

Parent Type:

prop block

public mut prop block: Block

Description: Obtains or sets the block expression in DoWhileExpr.

Type: Block

prop condition

public mut prop condition: Expr

Description: Obtains or sets the condition expression in the keyword DoWhileExpr.

Type: Expr

prop keywordD

public mut prop keywordD: Token

Description: Obtains or sets the keyword do in a DoWhileExpr node. D in keywordD is the uppercase first letter of the keyword do, indicating the keyword do.

Type: Token

Throws:

prop keywordW

public mut prop keywordW: Token

Description: Obtains or sets the keyword while in a DoWhileExpr node. W in keywordW is the uppercase first letter of the keyword while, indicating the keyword while.

Type: Token

Throws:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" following the keyword while in DoWhileExpr.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" following the keyword while in DoWhileExpr.

Type: Token

Throws:

init()

public init()

Description: Constructs a default DoWhileExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a DoWhileExpr object.

Parameters:

Throws:

class EnumDecl

public class EnumDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an Enum definition node.

Enum is defined using the keyword enum in the following sequence: modifier (default or not), enum keyword, enum name, optional type parameter, whether to specify a parent interface, optional generic constraint, and enum body.

Parent Type:

prop constructors

public mut prop constructors: ArrayList<Constructor>

Description: Obtains or sets the constructors in an EnumDecl node.

Type: ArrayList<Constructor>

prop decls

public mut prop decls: ArrayList<Decl>

Description: Obtains or sets members other than constructors in an EnumDecl node.

Type: ArrayList<Decl>

prop lBrace

public mut prop lBrace: Token

Description: Obtains or sets the { lexical unit type of an EnumDecl node.

Type: Token

Throws:

prop rBrace

public mut prop rBrace: Token

Description: Obtains or sets the } lexical unit type of an EnumDecl node.

Type: Token

Throws:

prop superTypeBitAnds

public mut prop superTypeBitAnds: Tokens

Description: Obtains or sets the lexical unit sequence of the operator & in the parent interface declaration of an EnumDecl node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

prop superTypes

public mut prop superTypes: ArrayList<TypeNode>

Description: Obtains or sets the parent interface of an EnumDecl node.

Type: ArrayList<TypeNode>

prop upperBound

public mut prop upperBound: Token

Description: Obtains or sets the operator <:.

Type: Token

Throws:

init()

public init()

Description: Constructs a default EnumDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an EnumDecl object.

Parameters:

Throws:

class EnumPattern

public class EnumPattern <: Pattern {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an enum pattern node.

Such node is used to match the constructor of enum, for example, Year(n) in case Year(n) => 1.

Parent Type:

prop commas

public mut prop commas: Tokens

Description: Obtains or sets the lexical unit sequence comma (,) in an EnumPattern node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence comma (,), this exception is thrown.

prop constructor

public mut prop constructor: Expr

Description: Obtains or sets the constructor expression node in an EnumPattern node.

Type: Expr

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the lexical unit left parenthesis "(" in an EnumPattern node.

Type: Token

Throws:

prop patterns

public mut prop patterns: ArrayList<Pattern>

Description: Obtains or sets the list of pattern nodes in the parameterized constructor in an EnumPattern node.

Type: ArrayList<Pattern>

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the lexical unit right parenthesis ")" in an EnumPattern node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default EnumPattern object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an EnumPattern object.

Parameters:

Throws:

class ExceptTypePattern

public class ExceptTypePattern <: Pattern {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a node used in exception pattern.

Example: e: Exception1 | Exception2

Parent Type:

prop colon

public mut prop colon: Token

Description: Obtains or sets the lexical unit of the operator colon (:) in an ExceptTypePattern node.

Type: Token

Throws:

prop pattern

public mut prop pattern: Pattern

Description: Obtains or sets the pattern node in an ExceptTypePattern node.

Type: Pattern

prop types

public mut prop types: ArrayList<TypeNode>

Description: Obtains or sets the type list in an ExceptTypePattern node.

Type: ArrayList<TypeNode>

init()

public init()

Description: Constructs a default ExceptTypePattern object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an ExceptTypePattern object.

Parameters:

Throws:

class Expr

public open class Expr <: Node

Description: Specifies the parent class of all expression nodes, which is inherited from a Node node.

The toTokens method of an expression node adds parentheses based on the operator priority. For example, if the left expression a of the BinaryExpr node a * b is modified to a + 1, the toTokens method adds parentheses to the left expression, and (a + 1) * b is outputted.

Parent Type:

class ExtendDecl

public class ExtendDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an extension definition node.

Extension is defined using the keyword extend in the following sequence: extend keyword, extension type, whether to specify a parent interface, optional generic constraint, and extension body.

Parent Type:

prop body

public mut prop body: Body

Description: Obtains or sets the class body of an ExtendDecl node.

Type: Body

prop extendType

public mut prop extendType: TypeNode

Description: Obtains or sets the extension type.

Type: TypeNode

prop identifier

public mut override prop identifier: Token

Description: The ExtendDecl node inherits a Decl node but does not support the identifier attribute, whose usage triggers an exception.

Type: Token

Throws:

  • ASTException: If the identifier attribute is used, this exception is thrown.

prop superTypeBitAnds

public mut prop superTypeBitAnds: Tokens

Description: Obtains or sets the lexical unit sequence of the operator & in the parent interface declaration of an ExtendDecl node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

prop superTypes

public mut prop superTypes: ArrayList<TypeNode>

Description: Obtains or sets the parent interface of an ExtendDecl node.

Type: ArrayList<TypeNode>

prop upperBound

public mut prop upperBound: Token

Description: Obtains or sets the operator <:.

Type: Token

Throws:

init()

public init()

Description: Constructs a default ExtendDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an ExtendDecl object.

Parameters:

  • inputs: Tokens: collection of lexical units (Tokens) used to construct the [ExtendDecl](ast_package_classes.md#class-extenddecl type

Throws:

class ForInExpr

public class ForInExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a for-in expression.

In the ForInExpr type, the keyword for is followed by Pattern, the keyword in and expression node, and an execution loop body Block.

Parent Type:

prop block

public mut prop block: Block

Description: Obtains or sets the loop body in ForInExpr.

Type: Block

prop expr

public mut prop expr: Expr

Description: Obtains or sets an expression in ForInExpr.

Type: Expr

prop keywordF

public mut prop keywordF: Token

Description: Obtains or sets the keyword for in ForInExpr.

Type: Token

Throws:

prop keywordI

public mut prop keywordI: Token

Description: Obtains or sets the keyword in in ForInExpr.

Type: Token

Throws:

prop keywordW

public mut prop keywordW: Token

Description: Obtains or sets the keyword where in ForInExpr.

Type: Token

Throws:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" following the keyword for in ForInExpr.

Type: Token

Throws:

prop pattern

public mut prop pattern: Pattern

Description: Obtains or sets the Pattern node in ForInExpr.

Type: Pattern

prop patternGuard

public mut prop patternGuard: Expr

Description: Obtains or sets the patternGuard condition expression in ForInExpr.

Type: Expr

Throws:

  • ASTException: If the ForInExpr node contains no patternGuard condition expression, this exception is thrown.

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in ForInExpr.

Type: Token

Throws:

init()

public init()

Description: Constructs a default ForInExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a ForInExpr object.

Parameters:

Throws:

class FuncDecl

public class FuncDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a function definition node.

A function is defined by an optional function modifier, the keyword func, a function name, an optional type formal parameter list, function parameters, and a function return type (default or not). A function body is a block and mandatory during definition.

Parent Type:

prop block

public mut prop block: Block

Description: Obtains or sets the function body of a FuncDecl node.

Type: Block

prop colon

public mut prop colon: Token

Description: Obtains or sets colons (:) of a FuncDecl node.

Type: Token

Throws:

prop declType

public mut prop declType: TypeNode

Description: Obtains or sets the function return type of a FuncDecl node.

Type: TypeNode

Throws:

prop funcParams

public mut prop funcParams: ArrayList<FuncParam>

Description: Obtains or sets the function parameters of a FuncDecl node.

Type: ArrayList<FuncParam>

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in a FuncDecl node.

Type: Token

Throws:

prop overloadOp

public mut prop overloadOp: Tokens

Description: Obtains or sets the overload operator of a FuncDecl node.

Type: Tokens

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in a FuncDecl node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default FuncDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a FuncDecl object.

Parameters:

Throws:

func isConst()

public func isConst(): Bool

Description: Checks whether a node is of the Const type.

Returns:

  • Bool: If the node is of the Const type, true is returned. Otherwise, false is returned.

class FuncParam

public open class FuncParam <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a function parameter node, including non-named parameters and named parameters.

Example of a FuncParam node: a: Int64 and b: Float64 in func foo(a: Int64, b: Float64) {...}

Parent Type:

prop assign

public mut prop assign: Token

Description: Obtains or sets = in a function parameter with a default value.

Type: Token

Throws:

prop colon

public mut prop colon: Token

Description: Obtains or sets the colon (:) in a formal parameter.

Type: Token

Throws:

prop expr

public mut prop expr: Expr

Description: Obtains or sets the variable initialization node of a function parameter with a default value.

Type: Expr

Throws:

  • ASTException: If the function parameters are not initialized, this exception is thrown.

prop not

public mut prop not: Token

Description: Obtains or sets ! in named formal parameters.

Type: Token

Throws:

prop paramType

public mut prop paramType: TypeNode

Description: Obtains or sets the type of function parameters.

Type: TypeNode

init()

public init()

Description: Constructs a default FuncParam object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a FuncParam object.

Parameters:

Throws:

func isMemberParam()

public func isMemberParam(): Bool

Description: Specifies whether the current function parameter is in a primary constructor.

Returns:

  • Bool: Boolean type. If the parameter is in the primary constructor, true is returned.

class FuncType

public class FuncType <: TypeNode {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a function type node.

The node consists of the parameter type and return type of the function. The parameter type and return type are separated by ->, for example, (Int32) -> Unit.

Parent Type:

prop arrow

public mut prop arrow: Token

Description: Obtains or sets the lexical unit -> between the parameter type and return type of a FuncType node.

Type: Token

Throws:

prop commas

public mut prop commas: Tokens

Description: Obtains or sets the lexical unit sequence comma (,) in a FuncType node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence comma (,), this exception is thrown.

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the lexical unit keyword CFunc in a FuncType node. If the type is not CFunc, an ILLEGAL lexical unit is obtained.

Type: Token

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the lexical unit left parenthesis "(" in a FuncType node.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the lexical unit right parenthesis ")" in a FuncType node.

Type: Token

Throws:

prop returnType

public mut prop returnType: TypeNode

Description: Obtains or sets the FuncType return type node.

Type: TypeNode

prop types

public mut prop types: ArrayList<TypeNode>

Description: Obtains or sets the parameter type list of the function in a FuncType node.

Type: ArrayList<TypeNode>

init()

public init()

Description: Constructs a default FuncType object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a FuncType object.

Parameters:

Throws:

class GenericConstraint

public class GenericConstraint <: Node {
    public init()
}

Description: Specifies a generic constraint node.

Example of a GenericConstraint node: where where U <: Bounded in interface Enumerable<U> where U <: Bounded {}

Note:

The node is declared by the operator <: after where and consists of a lower bound and an upper bound. The part on the left of <: is referred to as the lower constraint bound, which can only be a type variable. The part on the right of <: is referred to as the upper constraint bound, which can be a type.

Parent Type:

prop bitAnds

public mut prop bitAnds: Tokens

Description: Obtains or sets the lexical unit sequence of the operator & in a GenericConstraint node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the lexical unit keyword where in a GenericConstraint node, which may be an ILLEGAL lexical unit.

Type: Token

Throws:

prop typeArgument

public mut prop typeArgument: TypeNode

Description: Obtains or sets the lower constraint bound in a GenericConstraint node.

Type: TypeNode

prop upperBound

public mut prop upperBound: Token

Description: Obtains or sets the operator <: in a GenericConstraint node.

Type: Token

Throws:

prop upperBounds

public mut prop upperBounds: ArrayList<TypeNode>

Description: Obtains or sets a collection of TypeNode type nodes on the upper constraint bound of a GenericConstraint node.

Type: ArrayList<TypeNode>

init()

public init()

Description: Constructs a default GenericConstraint object.

class GenericParam

public class GenericParam <: Node {
    public init()
    public init(parameters: Tokens)
}

Description: Specifies a type formal parameter node.

Example of a GenericParam node: <T1, T2, T3>

Note:

Type formal parameters are enclosed in <>, and multiple type formal parameter names are separated by ,.

Parent Type:

prop lAngle

public mut prop lAngle: Token

Description: Obtains or sets the lexical unit left angle bracket in a GenericParam node.

Type: Token

Throws:

prop parameters

public mut prop parameters: Tokens

Description: Obtains or sets the Tokens type of the type formal parameters in a GenericParam node. The type may be empty, for example, T1, T2, and T3 in <T1, T2, T3>.

Type: Tokens

prop rAngle

public mut prop rAngle: Token

Description: Obtains or sets the lexical unit right angle bracket in a GenericParam node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default GenericParam object.

init(Tokens)

public init(parameters: Tokens)

Description: Constructs a GenericParam object.

Parameters:

class IfExpr

public class IfExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a condition expression.

Which code branch to be executed can be determined based on whether a condition is met. An IfExpr node has the keyword if, followed by a pair of parentheses in which an expression, or a deconstruction match declared by let is enclosed, a Block, and an optional else branch. The else branch starts with the keyword else, followed by a new if expression or a Block.

Parent Type:

prop condition

public mut prop condition: Expr

Description: Obtains or sets the condition expression after if in an IfExpr node.

Type: Expr

prop elseExpr

public mut prop elseExpr: Expr

Description: Obtains or sets the else branch node in an IfExpr node.

Type: Expr

Throws:

prop ifBlock

public mut prop ifBlock: Block

Description: Obtains or sets the block node after if in an IfExpr node.

Type: Block

prop keywordE

public mut prop keywordE: Token

Description: Obtains or sets the keyword else in an IfExpr node.

Type: Token

Throws:

prop keywordI

public mut prop keywordI: Token

Description: Obtains or sets the keyword if in an IfExpr node.

Type: Token

Throws:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" following if in an IfExpr node.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" following if in an IfExpr node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default IfExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an IfExpr object.

Parameters:

Throws:

class ImportContent

public class ImportContent <: Node {
    public init()
}

Parent Type:

prop importKind

public mut prop importKind: ImportKind

Description: Obtains or sets the import type in an ImportContent node.

Type: ImportKind

prop prefixPaths

public mut prop prefixPaths: Tokens

Description: Obtains or sets the lexical unit sequence of the prefix of a full package name in an ImportContent node. The lexical unit sequence may be empty. Example: a and b in import a.b.c.

Type: Tokens

prop prefixDots

public mut prop prefixDots: Tokens

Description: Obtains or sets the lexical unit sequence used to separate the subpackage layers in a full package name in an ImportContent node. The lexical unit sequence may be empty. Example: two periods (.) in import a.b.c.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence period (.), this exception is thrown.

prop identifier

public mut prop identifier: Token

Description: Obtains or sets the item imported in an ImportContent node. It may be a top-level definition or declaration in a package, or may be the name of a subpackage.

Type: Token

prop importAlias

public mut prop importAlias: Tokens

Description: Obtains or sets the alias lexical unit sequence of the definition or declaration imported in an ImportContent node. It is not empty only when importKind is ImportKind.Alias, for example, as yyy in import packageName.xxx as yyy.

Type: Tokens

prop lBrace

public mut prop lBrace: Token

Description: Obtains or sets the operator lexical unit { in an ImportContent node. It is not empty only when importKind is ImportKind.Multi.

Type: Token

Throws:

prop items

public mut prop items: ArrayList<ImportContent>

Description: Obtains or sets all items imported in an ImportContent node. It is not empty only when importKind is ImportKind.Multi.

Type: ArrayList<ImportContent>

prop commas

public mut prop commas: Tokens

Description: Obtains or sets the operator lexical unit comma (,) in an ImportContent node. It is not empty only when importKind is ImportKind.Multi.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence comma (,), this exception is thrown.

prop rBrace

public mut prop rBrace: Token

Description: Obtains or sets the operator lexical unit } in an ImportContent node. It is not empty only when importKind is ImportKind.Multi.

Type: Token

Throws:

init()

public init()

Description: Constructs a default ImportContent object.

func isImportAlias()

public func isImportAlias(): Bool

Description: Checks whether an ImportContent node has an alias for the imported item.

Returns:

func isImportAll()

public func isImportAll(): Bool

Description: Checks whether full import is configured for an ImportContent node.

Returns:

func isImportMulti()

public func isImportMulti(): Bool

Description: Checks whether multiple top-level definitions or declarations are imported in an ImportContent node.

Returns:

  • Bool: whether multiple top-level definitions or declarations are imported in the ImportContent node

func isImportSingle()

public func isImportSingle(): Bool

Description: Checks whether single import is configured for an ImportContent node.

Returns:

class ImportList

public class ImportList <: Node {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a package import node.

One ImportList node: import moduleName.packageName.foo as bar.

Note:

The import node starts with an optional access modifier (public/protected/internal/private) and the keyword import. Take import pkga.pkgb.item as an example. pkga.pkgb is the name of the package where an imported top-level definition or declaration resides, and item is the imported top-level definition or declaration.

Parent Type:

prop modifier

public mut prop modifier: Token

Description: Obtains or sets the modifier in an ImportList node, which may be an ILLEGAL lexical unit.

Type: Token

prop keywordI

public mut prop keywordI: Token

Description: Obtains or sets the lexical unit keyword import in an ImportList node. I is the first letter of the keyword.

Type: Token

prop content

public mut prop content: ImportContent

Description: Obtains or sets an imported item in an ImportList node, for example, a.b.c in import a.b.c.

Type: ImportContent

init()

public init()

Description: Constructs a default ImportList object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an ImportList object.

Parameters:

Throws:

func isImportMulti()

public func isImportMulti(): Bool

Description: Checks whether multiple top-level definitions or declarations are imported to an ImportList node.

Returns:

  • Bool: If multiple top-level definitions or declarations are imported to the ImportList node, true is returned. Otherwise, false is returned.

class IncOrDecExpr

public class IncOrDecExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an expression that contains an auto-increment operator (++) or auto-decrement operator (--).

Parent Type:

prop expr

public mut prop expr: Expr

Description: Obtains or sets an expression in IncOrDecExpr.

Type: Expr

prop op

public mut prop op: Token

Description: Obtains or sets an operator in IncOrDecExpr.

Type: Token

init()

public init()

Description: Constructs a default IncOrDecExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an IncOrDecExpr object.

Parameters:

Throws:

class InterfaceDecl

public class InterfaceDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an interface definition node.

An interface is defined using the keyword interface in the following sequence: modifier (default or not), interface keyword, interface name, optional type parameter, whether to specify a parent interface, optional generic constraint, and interface body.

Parent Type:

prop body

public mut prop body: Body

Description: Obtains or sets the class body of an InterfaceDecl node.

Type: Body

prop superTypeBitAnds

public mut prop superTypeBitAnds: Tokens

Description: Obtains or sets the lexical unit sequence of the operator & in the parent interface declaration of an InterfaceDecl node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

prop superTypes

public mut prop superTypes: ArrayList<TypeNode>

Description: Obtains or sets the parent interface of an InterfaceDecl node.

Type: ArrayList<TypeNode>

prop upperBound

public mut prop upperBound: Token

Description: Obtains or sets the operator <:.

Type: Token

Throws:

init()

public init()

Description: Constructs a default InterfaceDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an InterfaceDecl object.

Parameters:

Throws:

class IsExpr

public class IsExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a type check expression.

An IsExpr expression is in the e is T format and of the Bool type. e can be any type of expression, and T can be any type.

Parent Type:

prop exprs

public mut prop expr: Expr

Description: Obtains or sets the expression node in an IsExpr node.

Type: Expr

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the operator is in an IsExpr node.

Type: Token

Throws:

prop shiftType

public mut prop shiftType: TypeNode

Description: Obtains or sets the target type in an IsExpr node.

Type: TypeNode

init()

public init()

Description: Constructs a default IsExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an IsExpr object.

Parameters:

Throws:

class JumpExpr

public class JumpExpr <: Expr {
    public init()
    public init(kind: Tokens)
}

Description: Specifies break and continue in the body of a loop expression.

Parent Type:

prop keyword

public mut prop keyword: Token

Description: Obtains or sets a keyword.

Type: Token

init()

public init()

Description: Constructs a default JumpExpr object.

init(Tokens)

public init(kind: Tokens)

Description: Constructs a JumpExpr object.

Parameters:

Throws:

class LambdaExpr

public class LambdaExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a Lambda expression, which is an anonymous function.

A LambdaExpr node may have formal parameters, for example, {a: Int64 => e1; e2 }, or have no formal parameter, for example, { => e1; e2 }.

Parent Type:

prop doubleArrow

public mut prop doubleArrow: Token

Description: Obtains or sets => in LambdaExpr.

Type: Token

Throws:

prop funcParams

public mut prop funcParams:  ArrayList<FuncParam>

Description: Obtains or sets the parameter list in LambdaExpr.

Type: ArrayList<FuncParam>

prop lBrace

public mut prop lBrace: Token

Description: Obtains or sets the left curly bracket ({) in LambdaExpr.

Type: Token

Throws:

prop nodes

public mut prop nodes: ArrayList<Node>

Description: Obtains or sets the expression or declaration node in LambdaExpr.

Type: ArrayList<Node>

prop rBrace

public mut prop rBrace: Token

Description: Obtains or sets the right curly bracket (}) in LambdaExpr.

Type: Token

Throws:

init()

public init()

Description: Constructs a default LambdaExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a LambdaExpr object.

Parameters:

Throws:

class LetPatternExpr

public class LetPatternExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a deconstruction match node declared by let.

Example of a LetPatternExpr node: let Some(v) <- x in if (let Some(v) <- x)

Parent Type:

prop backArrow

public mut prop backArrow: Token

Description: Obtains or sets the operator <- in a LetPatternExpr node.

Type: Token

Throws:

prop expr

public mut prop expr: Expr

Description: Obtains or sets the expression after the operator <- in a LetPatternExpr node.

Type: Expr

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the keyword let in a LetPatternExpr node.

Type: Token

Throws:

prop pattern

public mut prop pattern: Pattern

Description: Obtains or sets the pattern after let in a LetPatternExpr node.

Type: Pattern

init()

public init()

Description: Constructs a default LetPatternExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a LetPatternExpr object.

Parameters:

Throws:

class LitConstExpr

public class LitConstExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a constant expression node.

Examples of a LitConstExpr expression: "abc" and 123

Parent Type:

prop literal

public mut prop literal: Token

Description: Obtains or sets the literal in a LitConstExpr node.

Type: Token

init()

public init()

Description: Constructs a default LitConstExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a LitConstExpr object.

Parameters:

Throws:

class MacroDecl

public class MacroDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a macro definition node.

Example of a MacroDecl node: public macro M(input: Tokens): Tokens {...}

Parent Type:

prop block

public mut prop block: Block

Description: Obtains or sets the function body of a MacroDecl node.

Type: Block

prop colon

public mut prop colon: Token

Description: Obtains or sets colons (:) of a MacroDecl node.

Type: Token

Throws:

prop declType

public mut prop declType: TypeNode

Description: Obtains or sets the function return type of a MacroDecl node.

Type: TypeNode

Throws:

prop funcParams

public mut prop funcParams: ArrayList<FuncParam>

Description: Obtains or sets the parameters of a MacroDecl node.

Type: ArrayList<FuncParam>

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the right parenthesis ")" in a MacroDecl node.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in a MacroDecl node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default MacroDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a MacroDecl object.

Parameters:

Throws:

class MacroExpandDecl

public class MacroExpandDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a macro call node.

Example of a MacroExpandDecl node: @M class A {}

Parent Type:

prop fullIdentifier

public mut prop fullIdentifier: Token

Description: Obtains or sets the full identifier of a macro call node.

Type: Token

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" invoked by the MacroExpandDecl macro.

Type: Token

Throws:

prop lSquare

public mut prop lSquare: Token

Description: Obtains or sets the left square bracket ([) invoked by the MacroExpandDecl attribute macro.

Type: Token

Throws:

prop macroAttrs

public mut prop macroAttrs: Tokens

Description: Obtains or sets the input of a MacroExpandDecl attribute macro call.

Type: Tokens

prop macroInputDecl

public mut prop macroInputDecl: Decl

Description: Obtains or sets the declaration node in MacroExpandDecl.

Type: Decl

Throws:

prop macroInputs

public mut prop macroInputs: Tokens

Description: Obtains or sets the input of a MacroExpandDecl macro call.

Type: Tokens

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" invoked by the MacroExpandDecl macro.

Type: Token

Throws:

prop rSquare

public mut prop rSquare: Token

Description: Obtains or sets the right square bracket (]) invoked by the MacroExpandDecl attribute macro.

Type: Token

Throws:

  • ASTException: If Token is not a right square bracket (]), this exception is thrown.

init()

public init()

Description: Constructs a default MacroExpandDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a MacroExpandDecl object.

Parameters:

Throws:

class MacroExpandExpr

public class MacroExpandExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a macro call node.

Example of a MacroExpandExpr node: @M (a is Int64)

Parent Type:

prop at

public mut prop at: Token

Description: Obtains or sets the operator @ in a MacroExpandExpr node.

Type: Token

Throws:

prop identifier

public mut prop identifier: Token

Description: Obtains or sets the identifier of a macro call node.

Type: Token

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" invoked by the [MacroExpandExpr](ast_package_classes.md#class-macroexpandexpr) macro.

Type: Token

Throws:

prop lSquare

public mut prop lSquare: Token

Description: Obtains or sets the left square bracket ([) invoked by the [MacroExpandExpr](ast_package_classes.md#class-macroexpandexpr) attribute macro.

Type: Token

Throws:

prop macroAttrs

public mut prop macroAttrs: Tokens

Description: Obtains or sets the input of a MacroExpandExpr attribute macro call.

Type: Tokens

prop macroInputs

public mut prop macroInputs: Tokens

Description: Obtains or sets the input of a MacroExpandExpr macro call.

Type: Tokens

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" invoked by the [MacroExpandExpr](ast_package_classes.md#class-macroexpandexpr) macro.

Type: Token

Throws:

prop rSquare

public mut prop rSquare: Token

Description: Obtains or sets the right square bracket (]) invoked by the [MacroExpandExpr](ast_package_classes.md#class-macroexpandexpr) attribute macro.

Type: Token

Throws:

  • ASTException: If Token is not a right square bracket (]), this exception is thrown.

init()

public init()

Description: Constructs a default MacroExpandExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a MacroExpandExpr object.

Parameters:

Throws:

class MacroExpandParam

public class MacroExpandParam <: FuncParam {
    public init()
}

Description: Specifies a macro call node.

Example of a MacroExpandDecl node: @M a: Int64 in func foo (@M a: Int64)

Parent Type:

prop fullIdentifier

public mut prop fullIdentifier: Token

Description: Obtains or sets the full identifier of a macro call node.

Type: Token

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" invoked by the MacroExpandParam macro.

Type: Token

Throws:

prop lSquare

public mut prop lSquare: Token

Description: Obtains or sets the lfet square bracket ([) invoked by the MacroExpandParam attribute macro.

Type: Token

Throws:

prop macroAttrs

public mut prop macroAttrs: Tokens

Description: Obtains or sets the input of a MacroExpandParam attribute macro call.

Type: Tokens

prop macroInputDecl

public mut prop macroInputDecl: Decl

Description: Obtains or sets the declaration node in MacroExpandParam.

Type: Decl

Throws:

prop macroInputs

public mut prop macroInputs: Tokens

Description: Obtains or sets the input of a MacroExpandParam macro call.

Type: Tokens

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis of a MacroExpandParam macro call.

Type: Token

Throws:

prop rSquare

public mut prop rSquare: Token

Description: Obtains or sets the right square bracket (]) invoked by the MacroExpandParam attribute macro.

Type: Token

Throws:

  • ASTException: If Token is not a right square bracket (]), this exception is thrown.

init()

public init()

Description: Constructs a default MacroExpandParam object.

class MacroMessage

public class MacroMessage

Description: Records information sent by an inner macro.

func getBool(String)

public func getBool(key: String): Bool

Description: Obtains the Bool type information corresponding to a key value.

Parameters:

  • key: String: key of the keyword to be searched for

Returns:

  • Bool: The Bool type information corresponding to the key value is returned.

Throws:

  • Exception: If the Bool type information corresponding to the key value does not exist, this exception is thrown.

func getInt64(String)

public func getInt64(key: String): Int64

Description: Obtains the Int64 type information corresponding to a key value.

Parameters:

  • key: String: key of the keyword to be searched for

Returns:

  • Int64: The Int64 type information corresponding to the key value is returned.

Throws:

  • Exception: If the Int64 type information corresponding to the key value does not exist, this exception is thrown.

func getString(String)

public func getString(key: String): String

Description: Obtains the String type information corresponding to a key value.

Parameters:

  • key: String: key of the keyword to be searched for

Returns:

  • String: The String type information corresponding to the key value is returned.

Throws:

  • Exception: If the String type information corresponding to the key value does not exist, this exception is thrown.

func hasItem(String)

public func hasItem(key: String): Bool

Description: Checks whether the information corresponding to a key value exists.

Parameters:

  • key: String: key of the keyword to be searched for

Returns:

  • Bool: If the information corresponding to the key value exists, true is returned. Otherwise, false is returned.

class MainDecl

public class MainDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a main function definition node.

Example of a MainDecl node: main() {}

Parent Type:

prop block

public mut prop block: Block

Description: Obtains or sets the function body of a MainDecl node.

Type: Block

prop colon

public mut prop colon: Token

Description: Obtains or sets colons (:) of a MainDecl node.

Type: Token

Throws:

prop declType

public mut prop declType: TypeNode

Description: Obtains or sets the function return type of a MainDecl node.

Type: TypeNode

Throws:

prop funcParams

public mut prop funcParams: ArrayList<FuncParam>

Description: Obtains or sets the function parameters of a MainDecl node.

Type: ArrayList<FuncParam>

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in a MainDecl node.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in a MainDecl node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default MainDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a MainDecl object.

Parameters:

Throws:

class MatchCase

public class MatchCase <: Node {
    public init()
}

Description: Specifies a MatchCase type.

Example of a MatchCase node: case failScore where score > 0 => 0

Note:

  • MatchCase starts with the keyword case, followed by Expr or one or more pieces of pattern of the same type separated by |, one optional patternguard, one =>, and a series of declarations or expressions.
  • This node is strongly bound to MatchExpr.

Parent Type:

prop arrow

public mut prop arrow: Token

Description: Obtains or sets the lexical unit operator => in MatchCase.

Type: Token

Throws:

prop bitOrs

public mut prop bitOrs: Tokens

Description: Obtains or sets the lexical unit sequence of the operator | in MatchCase, which may be empty.

Type: Tokens

Throws:

prop block

public mut prop block: Block

Description: Obtains or sets a series of declaration or expression nodes in MatchCase.

Type: Block

prop expr

public mut prop expr: Expr

Description: Obtains or sets the expression node after case in MatchCase.

Type: Expr

Throws:

prop keywordC

public mut prop keywordC: Token

Description: Obtains or sets the lexical unit keyword case in MatchCase.

Type: Token

Throws:

prop keywordW

public mut prop keywordW: Token

Description: Obtains or sets the lexical unit optional keyword where in MatchCase, which may be an ILLEGAL lexical unit.

Type: Token

Throws:

prop patternGuard

public mut prop patternGuard: Expr

Description: Obtains or sets the optional pattern guard expression node in MatchCase.

Type: Expr

Throws:

prop patterns

public mut prop patterns: ArrayList<Pattern>

Description: Obtains or sets the pattern list after case in MatchCase.

Type: ArrayList<Pattern>

init()

public init()

Description: Constructs a default MatchCase object.

class MatchExpr

public class MatchExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies that a pattern matching expression implements pattern matching.

Pattern matching expressions are classified into match expressions with a selector and match expressions without any selector.

Parent Type:

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the keyword match in a MatchExpr node.

Type: Token

Throws:

prop lBrace

public mut prop lBrace: Token

Description: Obtains or sets the left curly bracket ({) following [MatchExpr](ast_package_classes.md#class-matchexpr).

Type: Token

Throws:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" following [MatchExpr](ast_package_classes.md#class-matchexpr).

Type: Token

Throws:

prop matchCases

public mut prop matchCases: ArrayList<MatchCase>

Description: Obtains or sets matchCase in MatchExpr. matchCase starts with the keyword case, followed by one or more Pattern or Expr nodes. For details, see MatchCase.

Type: ArrayList<MatchCase>

prop rBrace

public mut prop rBrace: Token

Description: Obtains or sets the right curly bracket (}) following [MatchExpr](ast_package_classes.md#class-matchexpr).

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" following [MatchExpr](ast_package_classes.md#class-matchexpr).

Type: Token

Throws:

prop selector

public mut prop selector: Expr

Description: Obtains or sets Expr after the keyword match.

Type: Expr

Throws:

  • ASTException: If the expression is a match expression without any selector, this exception is thrown.

init()

public init()

Description: Constructs a default MatchExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a MatchExpr object.

Parameters:

Throws:

class MemberAccess

public class MemberAccess <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a member access expression.

This can be used to access members of types such as class, interface, and struct. A MemberAccess node is in the form of T.a, where T is the body of the member access expression, and a is the name of the member.

Parent Type:

prop baseExpr

public mut prop baseExpr: Expr

Description: Obtains or sets the body of the member access expression of a MemberAccess node.

Type: Expr

prop commas

public mut prop commas: Tokens

Description: Obtains or sets the lexical unit sequence comma (,) in a MemberAccess node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence comma (,), this exception is thrown.

prop dot

public mut prop dot: Token

Description: Obtains or sets the period (.) in a MemberAccess node.

Type: Token

Throws:

  • ASTException: If Token is not the lexical unit sequence period (.), this exception is thrown.

prop field

public mut prop field: Token

Description: Obtains or sets the name of a MemberAccess node member.

Type: Token

prop lAngle

public mut prop lAngle: Token

Description: Obtains or sets the left angle bracket in a MemberAccess node.

Type: Token

Throws:

prop rAngle

public mut prop rAngle: Token

Description: Obtains or sets the right angle bracket in a MemberAccess node.

Type: Token

Throws:

prop typeArguments

public mut prop typeArguments: ArrayList<TypeNode>

Description: Obtains or sets the instantiation type in a MemberAccess node.

Type: ArrayList<TypeNode>

init()

public init()

Description: Constructs a default MemberAccess object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a MemberAccess object.

Parameters:

Throws:

class Modifier

public class Modifier <: Node {
    public init()
    public init(keyword: Token)
}

Description: Specifies that a definition has certain features. This class is usually placed at the beginning of a definition.

Example of a Modifier node: public in public func foo()

Parent Type:

prop keyword(Token)

public mut prop keyword: Token

Description: Obtains or sets the modifier lexical unit in a Modifier node.

Type: Token

init()

public init()

Description: Constructs a default Modifier object.

init(Token)

public init(keyword: Token)

Description: Constructs a Modifier object.

Parameters:

  • keyword: Token: lexical unit used to construct the Modifier type

class Node

abstract sealed class Node <: ToTokens

Description: Specifies the parent class of all Cangjie syntax tree nodes.

This class provides universal operation APIs for all data types.

Parent Type:

prop beginPos

public mut prop beginPos: Position

Description: Obtains or sets the start position of the current node.

Type: Position

prop endPos

public mut prop endPos: Position

Description: Obtains or sets the end position of the current node.

Type: Position

func dump()

public func dump(): Unit

Description: Converts the current syntax tree node into a tree structure and prints it.

In the tree structure output of the syntax tree node:

  • The - character string indicates the public attribute of the current node, for example, -keyword and -identifier.
  • The node type immediately follows the node attribute, for example, -declType: PrimitiveType indicates that the node type is PrimitiveType.
  • Braces indicate the application range of each type.

For details about the output format of a syntax tree, see Syntax Tree Node Printing in the sample code.

func toTokens()

public func toTokens(): Tokens

Description: Converts a syntax tree node to the Tokens type.

Returns:

func traverse(Visitor)

public func traverse(v: Visitor): Unit

Description: Traverses the current syntax tree node and its subnodes. To terminate subnode traversal in advance, rewrite the visit function and call the breakTraverse function. For details, see Examples of Traversing AST Objects Using a User-defined Access Function in the sample code.

Parameters:

class OptionalExpr

public class OptionalExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an expression node with the operator question mark (?).

Example of an OptionalExpr node: a? in a?.b, a?(b), a?[b]

Parent Type:

prop baseExpr

public mut prop baseExpr: Expr

Description: Obtains or sets the expression node of OptionalExpr.

Type: Expr

prop quest

public mut prop quest: Token

Description: Obtains or sets the operator question mark (?) in OptionalExpr.

Type: Token

Throws:

  • ASTException: If Token is not the operator question mark (?), this exception is thrown.

init()

public init()

Description: Constructs a default OptionalExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs an OptionalExpr object.

Parameters:

Throws:

class PackageHeader

public class PackageHeader <: Node {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a package declaration node.

Example of a PackageHeader node: package define or macro package define

Note:

A package declaration starts with the keyword package or macro package, followed by the package name, and must be in the first line of the source file.

Parent Type:

prop accessible

public mut prop accessible: Token

Description: Obtains or sets the lexical unit access modifier in a PackageHeader node, which may be an ILLEGAL lexical unit.

Type: Token

prop keywordM

public mut prop keywordM: Token

Description: Obtains or sets the lexical unit keyword macro in a PackageHeader node. (M is the first letter of the keyword, which applies to the following scenarios.) The lexical unit may be an ILLEGAL lexical unit.

Type: Token

Throws:

prop keywordP

public mut prop keywordP: Token

Description: Obtains or sets the lexical unit keyword package in a PackageHeader node.

Type: Token

Throws:

prop prefixPaths

public mut prop prefixPaths: Tokens

Description: Obtains or sets the lexical unit sequence of the prefix of a full package name in a PackageHeader node. The lexical unit sequence may be empty. Example: a and b in package a.b.c.

Type: Tokens

prop prefixDots

public mut prop prefixDots: Tokens

Description: Obtains or sets the lexical unit sequence used to separate the subpackage layers in a full package name in a PackageHeader node. The lexical unit sequence may be empty. Example: two periods (.) in package a.b.c.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence period (.), this exception is thrown.

prop packageIdentifier

public mut prop packageIdentifier: Token

Description: Obtains or sets the name of the current package in a PackageHeader node. If the current package is a root package, a full package name is returned. If the current package is a subpackage, the part following the last period (.) is returned.

Type: Token

init()

public init()

Description: Constructs a default PackageHeader object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a PackageHeader object.

Parameters:

Throws:

class ParenExpr

public class ParenExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a parenthesis expression node, which is an expression enclosed in parentheses.

Example of a ParenExpr node: (1 + 2)

Parent Type:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in a ParenExpr node.

Type: Token

Throws:

prop parenthesizedExpr

public mut prop parenthesizedExpr: Expr

Description: Obtains or sets a subexpression enclosed in parentheses in a ParenExpr node.

Type: Expr

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in a ParenExpr node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default ParenExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a ParenExpr object.

Parameters:

Throws:

class ParenType

public class ParenType <: TypeNode {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a parenthesis type node.

Example: (Int64) in var a: (Int64)

Parent Type:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the lexical unit left parenthesis "(" in a ParenType node.

Type: Token

Throws:

prop parenthesizedType

public mut prop parenthesizedType: TypeNode

Description: Obtains or sets the type enclosed in parentheses in a ParenType node, for example, Int64 in (Int64).

Type: TypeNode

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the lexical unit right parenthesis ")" in a ParenType node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default ParenType object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a ParenType object.

Parameters:

Throws:

class Pattern

public open class Pattern <: Node

Description: Specifies the parent class of all pattern matching nodes, which is inherited from a Node node.

Parent Type:

class PrefixType

public class PrefixType <: TypeNode {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a prefix type node with a question mark (?).

Example: ?A in var a: ?A

Parent Type:

prop baseType

public mut prop baseType: TypeNode

Description: Obtains or sets the type node in a PrefixType node, for example, A in var a: ?A.

Type: TypeNode

prop prefixOps

public mut prop prefixOps: Tokens

Description: Obtains or sets the collection of prefix operators in a PrefixType node.

Type: Tokens

init()

public init()

Description: Constructs a default PrefixType object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a PrefixType object.

Parameters:

Throws:

class PrimaryCtorDecl

public class PrimaryCtorDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a primary constructor node.

A primary constructor node consists of a modifier, a primary constructor name, a formal parameter list, and a primary constructor body.

Parent Type:

prop block

public mut prop block: Block

Description: Obtains or sets the primary constructor body of a PrimaryCtorDecl node.

Type: Block

prop funcParams

public mut prop funcParams: ArrayList<FuncParam>

Description: Obtains or sets the parameters of a PrimaryCtorDecl node.

Type: ArrayList<FuncParam>

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in a PrimaryCtorDecl node.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in a PrimaryCtorDecl node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default PrimaryCtorDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a PrimaryCtorDecl object.

Parameters:

Throws:

func isConst()

public func isConst(): Bool

Description: Checks whether a node is of the Const type.

Returns:

  • Bool: If the current node is of the Const type, true is returned. Otherwise, false is returned.

class PrimitiveType

public class PrimitiveType <: TypeNode {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a primitive type node.

Examples: value, run, and Boolean types

Parent Type:

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the keyword for constructing a PrimitiveType type, for example, Int8.

Type: Token

init()

public init()

Description: Constructs a default PrimitiveType object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a PrimitiveType object.

Parameters:

Throws:

class PrimitiveTypeExpr

public class PrimitiveTypeExpr <: Expr {
    public init()
    public init(kind: Tokens)
}

Description: Specifies a primitive type expression node.

A PrimitiveTypeExpr node is a primitive type built in the compiler appearing in the node as an expression, for example, Int64 in Int64.toSting().

Parent Type:

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the primitive type keywords in PrimitiveTypeExpr.

Type: Token

init()

public init()

Description: Constructs a default PrimitiveTypeExpr object.

init(Tokens)

public init(kind: Tokens)

Description: Constructs a PrimitiveTypeExpr object.

Parameters:

Throws:

class Program

public class Program <: Node {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a Cangjie source code file node.

A Cangjie source code file node includes a package definition node, a package import node, and all declaration nodes in the top-level scope.

Note:

Any Cangjie source code file can be parsed into a Program type.

Parent Type:

prop decls

public mut prop decls: ArrayList<Decl>

Description: Obtains or sets the declaration node list defined in the top-level scope in a Cangjie source code file.

Type: ArrayList<Decl>

prop importLists

public mut prop importLists: ArrayList<ImportList>

Description: Obtains or sets the package import node ImportList list in a Cangjie source code file.

Type: ArrayList<ImportList>

prop packageHeader

public mut prop packageHeader: PackageHeader

Description: Obtains or sets the package declaration node PackageHeader in a Cangjie source code file.

Type: PackageHeader

init()

public init()

Description: Constructs a default Program object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a Program object.

Parameters:

  • inputs: Tokens: the sequence of collection of lexical units (Tokens) used to construct the Program type

Throws:

  • ASTException: If the input Tokens type cannot be used to construct a file node, this exception is thrown.

class PropDecl

public class PropDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an attribute definition node.

Example of a PropDecl node: prop var X: Int64 { get() { 0 } }

Parent Type:

prop colon

public mut prop colon: Token

Description: Obtains or sets colons (:) of a PropDecl node.

Type: Token

Throws:

prop declType

public mut prop declType: TypeNode

Description: Obtains or sets the return type of a PropDecl node.

Type: TypeNode

prop getter

public mut prop getter: FuncDecl

Description: Obtains or sets the getter function of a PropDecl node.

Type: FuncDecl

Throws:

-ASTException: When the PropDecl node does not contain the getter function, this exception is thrown.

prop lBrace

public mut prop lBrace: Token

Description: Obtains or sets the left curly bracket ({) in a PropDecl node.

Type: Token

Throws:

prop rBrace

public mut prop rBrace: Token

Description: Obtains or sets the right curly bracket (}) in a PropDecl node.

Type: Token

Throws:

prop setter

public mut prop setter: FuncDecl

Description: Obtains or sets the setter function of a PropDecl node.

Type: FuncDecl

Throws:

-ASTException: When the PropDecl node does not contain the setter function, this exception is thrown.

init()

public init()

Description: Constructs a default PropDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a PropDecl object.

Parameters:

Throws:

class QualifiedType

public class QualifiedType <: TypeNode {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a user-defined member type.

Example: T.a in var a: T.a, where T is the package name, and a is the type imported from the T package.

Parent Type:

prop baseType

public mut prop baseType: TypeNode

Description: Obtains or sets the member access type body of a QualifiedType node, for example, T in var a : T.a.

Type: TypeNode

prop commas

public mut prop commas: Tokens

Description: Obtains or sets the lexical unit sequence comma (,) in a QualifiedType node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence comma (,), this exception is thrown.

prop dot

public mut prop dot: Token

Description: Obtains or sets the period (.) in a QualifiedType node.

Type: Token

Throws:

  • ASTException: If Tokens is not the lexical unit sequence period (.), this exception is thrown.

prop identifier

public mut prop identifier: Token

Description: Obtains or sets the identifier of a QualifiedType node member, for example, a in var a : T.a.

Type: Token

prop lAngle

public mut prop lAngle: Token

Description: Obtains or sets the lexical unit left angle bracket in a QualifiedType node, which may be an ILLEGAL lexical unit.

Type: Token

Throws:

prop rAngle

public mut prop rAngle: Token

Description: Obtains or sets the lexical unit right angle bracket in a QualifiedType node, which may be an ILLEGAL lexical unit.

Type: Token

Throws:

prop typeArguments

public mut prop typeArguments: ArrayList<TypeNode>

Description: Obtains or sets the list of instantiation types in a QualifiedType node, for example, Int32 in T.a<Int32>. The list may be empty.

Type: ArrayList<TypeNode>

init()

public init()

Description: Constructs a default QualifiedType object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a QualifiedType object.

Parameters:

Throws:

class QuoteExpr

public class QuoteExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a quote expression node.

Example of a QuoteExpr node: quote(var ident = 0)

Parent Type:

prop exprs

public mut prop exprs: ArrayList<Expr>

Description: Obtains or sets the internal reference expression node enclosed in () in QuoteExpr.

Type: ArrayList<Expr>

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the keyword quote in [QuoteExpr](ast_package_classes.md#class-quoteexpr).

Type: Token

Throws:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in QuoteExpr.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in QuoteExpr.

Type: Token

Throws:

init()

public init()

Description: Constructs a default QuoteExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a QuoteExpr object.

Parameters:

Throws:

class QuoteToken

public class QuoteToken <: Expr

Description: Specifies any valid token in a quote expression node.

Parent Type:

prop tokens

public mut prop tokens: Tokens

Description: Obtains Tokens in QuoteToken.

Type: Tokens

class RangeExpr

public class RangeExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an expression that contains range operators.

A RangeExpr node supports two Range operators: .. and ..=, which are used in the forms of start..end:step and start..=end:step to create left-closed and right-open Range instances and left-closed and right-closed Range instances, respectively.

Parent Type:

prop colon

public mut prop colon: Token

Description: Obtains or sets the operator colon (:) in RangeExpr.

Type: Token

Throws:

prop end

public mut prop end: Expr

Description: Obtains or sets the end value in RangeExpr.

Type: Expr

Throws:

  • ASTException: The end expression is omitted. Only when instances are of the Range<Int64> type, and the index operator [] is empty, this exception is thrown.

prop op

public mut prop op: Token

Description: Obtains or sets the operator of Range in RangeExpr.

Type: Token

prop start

public mut prop start: Expr

Description: Obtains or sets the start value in RangeExpr.

Type: Expr

Throws:

  • ASTException: The start expression is omitted. Only when instances are of the Range<Int64> type, and the index operator [] is empty, this exception is thrown.

prop step

public mut prop step: Expr

Description: Obtains or sets the difference between two adjacent elements in a sequence in RangeExpr.

Type: Expr

Throws:

  • ASTException: If the difference between the two adjacent elements in the sequence is not set in RangeExpr, this exception is thrown.

init()

public init()

Description: Constructs a default RangeExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a RangeExpr object.

Parameters:

Throws:

class RefExpr

public class RefExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: References a declared expression node.

RefExpr node: a in var b = a + 1 is one RefExpr node.

Parent Type:

prop commas

public mut prop commas: Tokens

Description: Obtains or sets the lexical unit sequence comma (,) in a RefExpr node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence comma (,), this exception is thrown.

prop identifier

public mut prop identifier: Token

Description: Obtains or sets the identifier of a user-defined type in a RefExpr node.

Type: Token

prop lAngle

public mut prop lAngle: Token

Description: Obtains or sets the left angle bracket in a RefExpr node.

Type: Token

Throws:

prop rAngle

public mut prop rAngle: Token

Description: Obtains or sets the right angle bracket in a RefExpr node.

Type: Token

Throws:

prop typeArguments

public mut prop typeArguments: ArrayList<TypeNode>

Description: Obtains or sets the instantiation type in a RefExpr node.

Type: ArrayList<TypeNode>

init()

public init()

Description: Constructs a default RefExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a RefExpr object.

Parameters:

Throws:

class RefType

public class RefType <: TypeNode {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a non-primitive type node.

For example, RefType can be used to specify user-defined types such as class, struct, and enum, as well as built-in types such as Array and String, for example, A in var a : A.

Parent Type:

prop commas

public mut prop commas: Tokens

Description: Obtains or sets the lexical unit sequence comma (,) in a RefType node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence comma (,), this exception is thrown.

prop identifier

public mut prop identifier: Token

Description: Obtains or sets the keyword for constructing a RefType type, for example, A in var a: A = A().

Type: Token

prop lAngle

public mut prop lAngle: Token

Description: Obtains or sets the lexical unit left angle bracket in a RefType node, which may be an ILLEGAL lexical unit.

Type: Token

Throws:

prop rAngle

public mut prop rAngle: Token

Description: Obtains or sets the lexical unit right angle bracket in a RefType node, which may be an ILLEGAL lexical unit.

Type: Token

Throws:

prop typeArguments

public mut prop typeArguments: ArrayList<TypeNode>

Description: Obtains or sets the list of instantiation types in a RefType node, which may be empty, for example, Int32 in var a: Array<Int32>.

Type: ArrayList<TypeNode>

init()

public init()

Description: Constructs a default RefType object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a RefType object.

Parameters:

Throws:

class ReturnExpr

public class ReturnExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a return expression node.

Example of a ReturnExpr node: return 1

Parent Type:

prop expr

public mut prop expr: Expr

Description: Obtains or sets the expression node in a ReturnExpr node.

Type: Expr

Throws:

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the keyword in a ReturnExpr node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default ReturnExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a ReturnExpr object.

Parameters:

Throws:

class SpawnExpr

public class SpawnExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a Spawn expression.

A SpawnExpr node consists of the keyword spawn and a closure that contains no formal parameter, for example, spawn { add(1, 2) }.

Parent Type:

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the keyword spawn in SpawnExpr.

Type: Token

Throws:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in SpawnExpr.

Type: Token

Throws:

prop lambdaExpr

public mut prop lambdaExpr: LambdaExpr

Description: Obtains or sets the closure that contains no formal parameter in SpawnExpr.

Type: LambdaExpr

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in SpawnExpr.

Type: Token

Throws:

prop threadContext

public mut prop threadContext: Expr

Description: Obtains or sets the thread context environment expression in SpawnExpr.

Type: Expr

Throws:

init()

public init()

Description: Constructs a default SpawnExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a SpawnExpr object.

Parameters:

Throws:

class StructDecl

public class StructDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a Struct node.

Struct is defined using the keyword struct in the following sequence: modifier (default or not), struct keyword, struct name, optional type parameter, whether to specify a parent interface, optional generic constraint, and struct body.

Parent Type:

prop body

public mut prop body: Body

Description: Obtains or sets the class body of a StructDecl node.

Type: Body

prop superTypeBitAnds

public mut prop superTypeBitAnds: Tokens

Description: Obtains or sets the lexical unit sequence of the operator & in the parent interface declaration of a StructDecl node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

prop superTypes

public mut prop superTypes: ArrayList<TypeNode>

Description: Obtains or sets the parent interface of a StructDecl node.

Type: ArrayList<TypeNode>

prop upperBound

public mut prop upperBound: Token

Description: Obtains or sets the operator <:.

Type: Token

Throws:

init()

public init()

Description: Constructs a default StructDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a StructDecl object.

Parameters:

Throws:

class SubscriptExpr

public class SubscriptExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies an index access expression.

A SubscriptExpr node is used by types (including Array and Tuple types) that support index access to access elements at specific locations through indexes, for example, arr[0].

Parent Type:

prop baseExpr

public mut prop baseExpr: Expr

Description: Obtains or sets an expression in SubscriptExpr.

Type: Expr

prop indexList

public mut prop indexList: ArrayList<Expr>

Description: Obtains or sets the index expression sequence in SubscriptExpr.

Type: ArrayList<Expr>

prop lSquare

public mut prop lSquare: Token

Description: Obtains or sets the left square bracket ([) in SubscriptExpr.

Type: Token

Throws:

prop rSquare

public mut prop rSquare: Token

Description: Obtains or sets the right square bracket (]) in SubscriptExpr.

Type: Token

Throws:

  • ASTException: If Token is not a right square bracket (]), this exception is thrown.

init()

public init()

Description: Constructs a default SubscriptExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a SubscriptExpr object.

Parameters:

Throws:

class SynchronizedExpr

public class SynchronizedExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a synchronized expression.

A SynchronizedExpr node consists of the keyword synchronized, StructuredMutex pair, and code block, for example, synchronized(m) { foo() }.

Parent Type:

prop block

public mut prop block: Block

Description: Obtains or sets a code block modified by SynchronizedExpr.

Type: Block

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the keyword synchronized in SynchronizedExpr.

Type: Token

Throws:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in SynchronizedExpr.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in SynchronizedExpr.

Type: Token

Throws:

prop structuredMutex

public mut prop structuredMutex: Expr

Description: Obtains or sets the StructuredMutex object in SynchronizedExpr.

Type: Expr

init()

public init()

Description: Constructs a default SynchronizedExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a SynchronizedExpr object.

Parameters:

Throws:

class ThisType

public class ThisType <: TypeNode {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a This type node.

Parent Type:

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the lexical unit keyword This of a ThisType node.

Type: Token

init()

public init()

Description: Constructs a default ThisType object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a ThisType object.

Parameters:

Throws:

class ThrowExpr

public class ThrowExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a throw expression node.

Example of a ThrowExpr node: throw Exception()

Parent Type:

prop expr

public mut prop expr: Expr

Description: Obtains or sets the expression node in a ThrowExpr node.

Type: Expr

prop keyword

public mut prop keyword: Token

Description: Obtains or sets a keyword in a ThrowExpr node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default ThrowExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a ThrowExpr object.

Parameters:

Throws:

class Tokens

public open class Tokens <: ToString & Iterable<Token> {
    public init()
    public init(tokArray: Array<Token>)
    public init(tokArrayList: ArrayList<Token>)
}

Description: Specifies a type for encapsulating a Token sequence.

Parent Type:

prop size

public open prop size: Int64

Description: Obtains the number of Token types in a Tokens object.

Type: Int64

init()

public init()

Description: Constructs a default Tokens object.

init(Array<Token>)

public init(tokArray: Array<Token>)

Description: Constructs a Tokens object.

Parameters:

init(ArrayList<Token>)

public init(tokArrayList: ArrayList<Token>)

Description: Constructs a Tokens object.

Parameters:

func append(Node)

public func append(node: Node): Tokens

Description: Concatenates the current Tokens with the Tokens converted from the input node.

Parameters:

  • node: Node: Node object to be concatenated

Returns:

func append(Token)

public open func append(token: Token): Tokens

Description: Concatenates the current Tokens with the input Token.

Parameters:

Returns:

func append(Tokens)

public open func append(tokens: Tokens): Tokens

Description: Adds the input Tokens to the end of the current Tokens for concatenation. (This function has better performance than other concatenation functions.)

Parameters:

Returns:

func concat(Tokens)

public func concat(tokens: Tokens): Tokens

Description: Concatenates the current Tokens with the input Tokens.

Parameters:

Returns:

func dump()

public func dump(): Unit

Description: Prints all Token information in Tokens.

func get(Int64)

public open func get(index: Int64): Token

Description: Obtains the Token element based on an index value.

Parameters:

  • index: Int64: value to be indexed

Returns:

func iterator()

public func iterator(): TokensIterator

Description: Obtains an iterator object in Tokens objects.

Returns:

func remove(Int64)

public func remove(index: Int64): Tokens

Description: Deletes a Token object from a specified location.

Parameters:

Returns:

func toString()

public func toString(): String

Description: Converts Tokens to the String type.

operator func +(Token)

public operator func +(r: Token): Tokens

Description: Adds the current Tokens and another Token to obtain new Tokens.

Parameters:

Returns:

  • Tokens: collection of lexical units obtained after concatenation for the new Tokens

operator func +(Tokens)

public operator func +(r: Tokens): Tokens

Description: Adds the current Tokens and Tokens to obtain a new Tokens type.

Parameters:

Returns:

  • Tokens: collection of lexical units obtained after concatenation for the new Tokens

operator func [](Int64)

public operator func [](index: Int64): Token

Description: Overloads operators and obtains the corresponding Token based on an index value.

Parameters:

  • index: Int64: value to be indexed

Returns:

  • Token: Token corresponding to the index is returned.

operator func [](Range<Int64>)

public open operator func [](range: Range<Int64>): Tokens

Description: Overloads operators and obtains the corresponding Tokens slice through range.

Parameters:

Returns:

  • The Tokens: Tokens corresponding to the slice index is returned.

Throws:

class TokensIterator

public class TokensIterator <: Iterator<Token> {
    public init(tokens: Tokens)
}

Description: Implements the iterator function of Tokens.

Parent Type:

init(Tokens)

public init(tokens: Tokens)

Description: Constructs a TokensIterator object.

Parameters:

func iterator()

public func iterator(): Iterator<Token>

Description: Obtains an instance of the current iterator.

Returns:

func next()

public func next(): Option<Token>

Description: Obtains the next value in an iterator.

Returns:

func peek()

public func peek(): Option<Token>

Description: Obtains the current value in an iterator.

Returns:

func seeing(TokenKind)

public func seeing(kind: TokenKind): Bool

Description: Checks whether the Token type of the current node is the input type.

Parameters:

Returns:

  • Bool: If the TokenKind of the current node is the same as the input type, true is returned. Otherwise, false is returned.

class TrailingClosureExpr

public class TrailingClosureExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a trailing Lambda node.

A TrailingClosureExpr node has the lambda expression placed at the end of a function call and outside parentheses, for example, f(a){ i => i * i }.

Parent Type:

prop expr

public mut prop expr: Expr

Description: Obtains or sets an expression in TrailingClosureExpr.

Type: Expr

prop lambdaExpr

public mut prop lambdaExpr: LambdaExpr

Description: Obtains or sets the trailing lambda in TrailingClosureExpr.

Type: LambdaExpr

init()

public init()

Description: Constructs a default TrailingClosureExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a TrailingClosureExpr object.

Parameters:

Throws:

class TryExpr

public class TryExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a try expression node.

A try expression includes three parts: a try block, a catch block, and a finally block.

Parent Type:

prop catchBlocks

public mut prop catchBlocks: ArrayList<Block>

Description: Obtains or sets the Catch block in TryExpr.

Type: ArrayList<Block>

prop catchPatterns

public mut prop catchPatterns: ArrayList<Pattern>

Description: Obtains or sets the exception sequence to be captured through pattern matching in TryExpr.

Type: ArrayList<Pattern>

prop finallyBlock

public mut prop finallyBlock: Block

Description: Obtains or sets the keyword Finally block in TryExpr.

Type: Block

Throws:

prop keywordF

public mut prop keywordF: Token

Description: Obtains or sets the keyword finally in TryExpr.

Type: Token

Throws:

prop keywordT

public mut prop keywordT: Token

Description: Obtains or sets the keyword try in TryExpr.

Type: Token

Throws:

prop keywordsC

public mut prop keywordsC: Tokens

Description: Obtains or sets the keyword catch in TryExpr.

Type: Tokens

Throws:

prop resourceSpec

public mut prop resourceSpec: ArrayList<VarDecl>

Description: Obtains or sets the instantiated object sequence of the Try-with-resources expression in TryExpr.

Type: ArrayList<VarDecl>

prop tryBlock

public mut prop tryBlock: Block

Description: Obtains or sets the block consisting of expressions and declarations in TryExpr.

Type: Block

init()

public init()

Description: Constructs a default TryExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a TryExpr object.

Parameters:

Throws:

class TupleLiteral

public class TupleLiteral <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a tuple literal node.

A TupleLiteral node is specified in the format of (expr1, expr2, ..., exprN), where each expr is an expression.

Parent Type:

prop elements

public mut prop elements: ArrayList<Expr>

Description: Obtains or sets the expression list in TupleLiteral.

Type: ArrayList<Expr>

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in TupleLiteral.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in TupleLiteral.

Type: Token

Throws:

init()

public init()

Description: Constructs a default TupleLiteral object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a TupleLiteral object.

Parameters:

Throws:

class TuplePattern

public class TuplePattern <: Pattern {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a Tuple pattern node.

This class is used to match the tuple value, for example, ("Bob", age) in case ("Bob", age) => 1.

Parent Type:

prop commas

public mut prop commas: Tokens

Description: Obtains or sets the lexical unit sequence comma (,) in a TuplePattern node. The lexical unit sequence may be empty.

Type: Tokens

Throws:

  • ASTException: If Tokens is not the lexical unit sequence comma (,), this exception is thrown.

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the lexical unit left parenthesis "(" in a TuplePattern node.

Type: Token

Throws:

prop patterns

public mut prop patterns: ArrayList<Pattern>

Description: Obtains or sets a group of Pattern nodes in a TuplePattern node.

Type: ArrayList<Pattern>

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the lexical unit right parenthesis ")" in a TuplePattern node.

Type: Token

Throws:

init()

public init()

Description: Constructs a default TuplePattern object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a TuplePattern object.

Parameters:

Throws:

class TupleType

public class TupleType <: TypeNode {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a tuple type node.

Example: (Int64, Int32) in var a: (Int64, Int32)

Parent Type:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the lexical unit left parenthesis "(" in a TupleType node.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the lexical unit right parenthesis ")" in a TupleType node.

Type: Token

Throws:

prop types

public mut prop types: ArrayList<TypeNode>

Description: Obtains or sets the type node list in a TupleType node.

Type: ArrayList<TypeNode>

init()

public init()

Description: Constructs a default TupleType object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a TupleType object.

Parameters:

Throws:

class TypeAliasDecl

public class TypeAliasDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a type alias node.

Example of a TypeAliasDecl node: type Point2D = Float64

Note:

In this node, type is used as a keyword and is followed by any valid identifier. The type on the right of the = is any top-level visible type.

Parent Type:

prop aliasType

public mut prop aliasType: TypeNode

Description: Obtains or sets the type whose alias is to be created.

Type: TypeNode

prop assign

public mut prop assign: Token

Description: Obtains or sets = between an identifier and type.

Type: Token

Throws:

init()

public init()

Description: Constructs a default TypeAliasDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a TypeAliasDecl object.

Parameters:

Throws:

class TypeConvExpr

public class TypeConvExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a type conversion expression.

This class is used to implement the conversion between several numeric types. Example of a TypeConvExpr node: Int8(32)

Parent Type:

prop expr

public mut prop expr: Expr

Description: Obtains or sets the original expression for type conversion in TypeConvExpr.

Type: Expr

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in TypeConvExpr.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in TypeConvExpr.

Type: Token

Throws:

prop targetType

public mut prop targetType: PrimitiveType

Description: Obtains or sets the target type for conversion in TypeConvExpr.

Type: PrimitiveType

init()

public init()

Description: Constructs a default TypeConvExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a TypeConvExpr object.

Parameters:

Throws:

class TypeNode

public open class TypeNode <: Node

Description: Specifies the parent class of all type nodes, which is inherited from Node.

Parent Type:

prop typeParameterName

public mut prop typeParameterName: Token

Description: Obtains or sets the parameters of a type node, for example, p1 and p2 in (p1:Int64, p2:Int64), which may be ILLEGAL lexical units.

Type: Token

prop colon

public mut prop colon: Token

Description: Obtains or sets the operator colon (:) in a TypeNode node, which may be an ILLEGAL lexical unit.

Type: Token

Throws:

class TypePattern

public class TypePattern <: Pattern {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a type pattern node.

This class is used to check whether the runtime type of a value is a subtype of a certain type, for example, b: Base in case b: Base => 0.

Parent Type:

prop colon

public mut prop colon: Token

Description: Obtains or sets the lexical unit of the operator colon (:) in a TypePattern node.

Type: Token

Throws:

prop pattern

public mut prop pattern: Pattern

Description: Obtains or sets the pattern node in a TypePattern node.

Type: Pattern

prop patternType

public mut prop patternType: TypeNode

Description: Obtains or sets the pattern type node to be matched in a TypePattern node.

Type: TypeNode

init()

public init()

Description: Constructs a default TypePattern object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a TypePattern object.

Parameters:

Throws:

class UnaryExpr

public class UnaryExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a unary operation expression node.

Parent Type:

prop expr

public mut prop expr: Expr

Description: Obtains or sets the operand in a UnaryExpr node.

Type: Expr

prop op

public mut prop op: Token

Description: Obtains or sets the unary operator in a UnaryExpr node.

Type: Token

init()

public init()

Description: Constructs a default UnaryExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a UnaryExpr object.

Parameters:

Throws:

class VArrayExpr

public class VArrayExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a VArray instance node.

Example of a VArrayExpr node: VArray<Int64, $5> { i => i} in let arr: VArray<Int64, $5> = VArray<Int64, $5> { i => i}

Parent Type:

prop arguments

public mut prop arguments: ArrayList<Argument>

Description: Obtains or sets the sequence of initialization parameters in VArrayExpr.

Type: ArrayList<Argument>

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" in VArrayExpr.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" in VArrayExpr.

Type: Token

Throws:

prop vArrayType

public mut prop vArrayType: VArrayType

Description: Obtains or sets the VArray type node of VArrayExpr.

Type: VArrayType

init()

public init()

Description: Constructs a default VArrayExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a VArrayExpr object.

Parameters:

Throws:

class VArrayType

public class VArrayType <: TypeNode {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a VArray node.

The generic VArray<T, size: Int64> is used to indicate a VArray type.

Parent Type:

prop dollar

public mut prop dollar: Token

Description: Obtains or sets the lexical unit operator $ in a VArrayType node.

Type: Token

Throws:

prop elementTy

public mut prop elementTy: TypeNode

Description: Obtains or sets the type variable node in a VArrayType node, for example, Int16 in VArray<Int16, $0>.

Type: TypeNode

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the lexical unit keyword VArray of a VArrayType node.

Type: Token

prop lAngle

public mut prop lAngle: Token

Description: Obtains or sets the lexical unit left angle bracket of a VArrayType node.

Type: Token

Throws:

prop rAngle

public mut prop rAngle: Token

Description: Obtains or sets the lexical unit right angle bracket of a VArrayType node.

Type: Token

Throws:

prop size

public mut prop size: Token

Description: Obtains or sets the lexical unit type length in a VArrayType node.

Type: Token

init()

public init()

Description: Constructs a default VArrayType object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a VArrayType object.

Parameters:

Throws:

class VarDecl

public class VarDecl <: Decl {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a variable definition node.

Example of a VarDecl node: var a: String or var b: Int64 = 1

Note:

The definition of a variable consists of the following: modifier, keyword, patternsMaybeIrrefutable, variable type, and initial value.

Parent Type:

prop assign

public mut prop assign: Token

Description: Obtains or sets the location information of the assignment operator in a VarDecl node.

Type: Token

Throws:

prop colon

public mut prop colon: Token

Description: Obtains or sets the location information of colons (:) in a VarDecl node.

Type: Token

Throws:

prop declType

public mut prop declType: TypeNode

Description: Obtains or sets the variable type of a VarDecl node.

Type: TypeNode

Throws:

  • ASTException: If the VarDecl node does not declare the variable type, this exception is thrown.

prop expr

public mut prop expr: Expr

Description: Obtains or sets the variable initialization node of a VarDecl node.

Type: Expr

Throws:

prop pattern

public mut prop pattern: Pattern

Description: Obtains or sets the pattern node of a VarDecl node.

Type: Pattern

Throws:

  • ASTException: If the VarDecl node does not declare the pattern node, this exception is thrown.

init()

public init()

Description: Constructs a default VarDecl object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a VarDecl object.

Parameters:

Throws:

func isConst()

public func isConst(): Bool

Description: Checks whether a node is of the Const type.

Returns:

  • Bool: If the node is of the Const type, true is returned. Otherwise, false is returned.

class VarOrEnumPattern

public class VarOrEnumPattern <: Pattern {
    public init()
    public init(identifier: Token)
}

Description: Specifies a node when the identifier of a pattern is the Enum constructor.

Example: RED in case RED is the Enum constructor.

Parent Type:

prop identifier

public mut prop identifier: Token

Description: Obtains or sets the lexical unit identifier in a VarOrEnumPattern node.

Type: Token

init()

public init()

Description: Constructs a default VarOrEnumPattern object.

init(Tokens)

public init(identifier: Token)

Description: Constructs a VarOrEnumPattern object.

Parameters:

Throws:

class VarPattern

public class VarPattern <: Pattern {
    public init()
    public init(identifier: Token)
}

Description: Specifies a binding pattern node.

This class is represented by a valid identifier, for example, i in for (i in 1..10).

Parent Type:

prop identifier

public mut prop identifier: Token

Description: Obtains or sets the lexical unit identifier in a VarPattern node.

Type: Token

init()

public init()

Description: Constructs a default VarPattern object.

init(Tokens)

public init(identifier: Token)

Description: Constructs a VarPattern object.

Parameters:

Throws:

class Visitor

public abstract class Visitor

Description: Specifies an abstract class that defines default visit functions for accessing different types of AST nodes.

Note:

  • The visit functions can be used together with traverse to access and modify nodes. All visit functions have empty implementations by default. Specific visit methods can be implemented as required.
  • This class needs to be inherited and allows subclasses to redefine access functions.

func breakTraverse()

public func breakTraverse(): Unit

Description: Rewrites the visit function and calls this function to terminate subnodes traversal.

class WhileExpr

public class WhileExpr <: Expr {
    public init()
    public init(inputs: Tokens)
}

Description: Specifies a while expression.

while is the keyword, followed by a pair of parentheses, which may have an expression or a deconstruction match of the let declaration enclosed in them, and then followed by a Block node.

Parent Type:

prop block

public mut prop block: Block

Description: Obtains or sets the block node in WhileExpr.

Type: Block

prop condition

public mut prop condition: Expr

Description: Obtains or sets the condition expression in the keyword WhileExpr.

Type: Expr

prop keyword

public mut prop keyword: Token

Description: Obtains or sets the keyword while in a WhileExpr node.

Type: Token

Throws:

prop lParen

public mut prop lParen: Token

Description: Obtains or sets the left parenthesis "(" following the keyword while in WhileExpr.

Type: Token

Throws:

prop rParen

public mut prop rParen: Token

Description: Obtains or sets the right parenthesis ")" following the keyword while in WhileExpr.

Type: Token

Throws:

init()

public init()

Description: Constructs a default WhileExpr object.

init(Tokens)

public init(inputs: Tokens)

Description: Constructs a WhileExpr object.

Parameters:

Throws:

class WildcardExpr

public class WildcardExpr <: Expr {
    public init()
    public init(keyword: Tokens)
}

Description: Specifies a wildcard expression node.

Parent Type:

prop keyword

public mut prop keyword: Token

Description: Obtains the keyword underscore (_) in WildcardExpr.

Type: Token

Throws:

  • ASTException: If Token is not the keyword underscore (_), this exception is thrown.

init()

public init()

Description: Constructs a default WildcardExpr object.

init(Tokens)

public init(keyword: Tokens)

Description: Constructs a WildcardExpr object.

Parameters:

Throws:

class WildcardPattern

public class WildcardPattern <: Pattern {
    public init()
    public init(keyword: Tokens)
}

Description: Specifies a wildcard pattern node.

This class is represented by an underscore (_) and can match any value.

Parent Type:

prop wildcard

public mut prop wildcard: Token

Description: Obtains or sets the lexical unit of the operator underscore (_) in a WildcardPattern node.

Type: Token

Throws:

  • ASTException: If Token is not the operator underscore (_), this exception is thrown.

init()

public init()

Description: Constructs a default WildcardPattern object.

init(Tokens)

public init(keyword: Tokens)

Description: Constructs a WildcardPattern object.

Parameters:

Throws: