StringLiteral

StringLiteral

open class StringLiteral

A String literal.

From the docs:


string ::= ‘"’ (b*:stringelem)* ‘"’ => concat((b*)) (if |concat((b)*)| < 2^32)

The JVM will crash if the string is 4 billion characters, so no need to perform the check.

Fields

Name Description
val value: String
open context: ParseContext?

Location of where the token was found in the .wast file.

Constructors

<init>

constructor(sequence: CharSequence, context: ParseContext?)

A String literal.

From the docs:


string ::= ‘"’ (b*:stringelem)* ‘"’ => concat((b*)) (if |concat((b)*)| < 2^32)

The JVM will crash if the string is 4 billion characters, so no need to perform the check.

Parameters

Name Description
sequence: CharSequence
context: ParseContext?

Methods

equals

open fun equals(other: Any?): Boolean

Parameters

Name Description
other: Any?

ReturnValue

Name Description
Boolean

hashCode

open fun hashCode(): Int

ReturnValue

Name Description
Int

Extensions

isKeyword

fun Token.isKeyword(keywordValue: String): Boolean

Determines whether or not the Token is a Keyword matching the provided keywordValue.

Receiver

Name Description
Token

Parameters

Name Description
keywordValue: String

ReturnValue

Name Description
Boolean

asKeywordMatching

fun Token.asKeywordMatching(value: String): Keyword?

Casts the Token into a Keyword and returns it if its Keyword.value is value. Returns null if either condition is unmet.

Receiver

Name Description
Token

Parameters

Name Description
value: String

ReturnValue

Name Description
Keyword?

asKeywordMatching

fun Token.asKeywordMatching(regex: Regex): Pair<Keyword, MatchResult>?

Casts the Token into a Keyword and returns it, along with the match, if its Keyword.value matches regexp.

Returns null if neither condition is met.

Receiver

Name Description
Token

Parameters

Name Description
regex: Regex

ReturnValue

Name Description
Pair<Keyword, MatchResult>?

assertIsKeyword

fun Token.assertIsKeyword(keywordValue: String)

Asserts that the Token is a Keyword matching the provided keywordValue.

Receiver

Name Description
Token

Parameters

Name Description
keywordValue: String

ReturnValue

Name Description
Unit