ESCToken

Extends: RefCounted

Description

Represents a token generated by the ASHES scanner to be parsed by the ASHES parser.

This class contains any information required by the parser but also carries with it associated information useful for debugging and tracing purposes.

Members

Methods


init

func init(tokenType: int, lexeme: String, literal: Variant, source: String, line: int, filename: String) -> void

Initialization method. Must be called after instantiation.

Parameters

Name

Type

Description

Required?

tokenType

int

a value from ESCTokenType.TokenType

yes

lexeme

String

text corresponding to the scanned token

yes

literal

Variant

if the token represents a literal value, this is that value; can be null

yes

source

String

the source code (script) containing the token, if available

yes

line

int

the line in the source containing the token, if available

yes

filename

String

the path of the file containing the token, if available

yes

Returns

Returns nothing.


set_source

func set_source(value: String) -> void

Sets the source of the token. This is typically the entire script file as a string.

Parameters

Name

Type

Description

Required?

value

String

Full script source used to resolve this token.

yes

Returns

Returns nothing.


get_source

func get_source() -> String

The source of the token.

Parameters

None.

Returns

Returns the source of the token. (String)


get_type

func get_type() -> int

The type of token this is; will be a value from ESCTokenType.TokenType.

Parameters

None.

Returns

Returns the type of token this is; will be a value from ESCTokenType.TokenType. (int)


get_literal

func get_literal() -> Variant

The literal value of the token, if it exists.

Parameters

None.

Returns

Returns the literal value of the token, if it exists. (Variant)


get_lexeme

func get_lexeme() -> String

The lexeme of the token; this is typically the text corresponding to the token.

Parameters

None.

Returns

Returns the lexeme of the token; this is typically the text corresponding to the token. (String)


get_line

func get_line() -> int

The line number of the token.

Parameters

None.

Returns

Returns the line number of the token. (int)


get_filename

func get_filename() -> String

The path of the file containing the token.

Parameters

None.

Returns

Returns the path of the file containing the token. (String)