kwasm.format.text.token

Kwasm.format.text.token

package kwasm.format.text.token

Classes

Name Description
class FloatLiteral

From the docs.


float    ::= p:num                                                 => p
p:num '.' q:frac                                      => p + q
p:num ('E' | 'e') s:sign e:num                        => p * 10^(s * e)
p:num '.' q:frac ('E' | 'e') s:sign e:num             => (p + q) * 10^(s * e)
hexfloat ::= '0x' p:hexnum                                         => p
'0x' p:hexnum '.' q:hexfrac                           => p + q
'0x' p:hexnum  ('P' | 'p') s:sign e:num               => p * 2^(s * e)
'0x' p:hexnum '.' q:hexfrac ('P' | 'p') s:sign e:num  => (p + q) * 2^(s * e)

And:


fN       ::= s:sign z:fNMag                                      => s * z
fNMag    ::= z:float                                             => float_N(z) (if != inf)
z:hexfloat                                          => float_N(z) (if != inf)
'inf'                                               => inf
'nan'                                               => NaN
'nan:0x' n:hexnum                                   => NaN (if 1 <= n < 2^(sig(N))

class Identifier

From the docs:

Indices can be given in both numeric and symbolic form. Symbolic identifiers that stand in lieu of indices start with $, followed by any sequence of printable ASCII characters that does not contain a space, quotation mark, comma, semicolon, or bracket.


id     ::= '$' idchar+
idchar ::= '0', '1', ..., '9'
'A', 'B', ..., 'Z'
'a', 'b', ..., 'z'
'!', '#', '$', '%', '&', ''', '*', '+', '-', '.', '/'
':', '<', '=', '>', '?', '@', '', '^', '_', '`', '|', '~'

sealed class IntegerLiteral

From the docs:

The allowed syntax for integer literals depends on size and signedness. Moreover, their value must lie within the range of the respective type


sign       ::= empty => +
'+' => +
'-' => -
uN         ::= n:num         => n (if n < 2^N)
'0x' n:hexnum => n (if n < 2^N)
sN         ::= plusminus:sign n:num => plusminus * n (if -2^(N-1) <= plusminus n < 2^(N-1))
plusminus:sign n:hexnum => plusminus * n (same conditions as above)


Uninterpreted integers can be written as either signed or unsigned, and are normalized to
unsigned in the abstract syntax.

</code></pre><p>iN         ::= n:uN => n
    i:sN => n (if i = signed(n))</p><pre><code class="language-"></code></pre>
data class Keyword

Represents a text-format wasm keyword.

From the docs:


keyword    ::= ('a'|...|'z') idchar*

sealed class Paren

Representations of Open/Close Parentheses in source WebAssembly.

data class RawToken

Special Token implementation, used by the actual tokens to build instances of themselves against.

data class Reserved

Represents a reserved word.

From the docs:


reserved ::= idchar+

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.

interface Token

A base type for all valid text-format WebAssembly tokens.

Subpackages

Name Description
package kwasm.format.text.token.util

Methods

findFloatLiteral

fun RawToken.findFloatLiteral(): TokenMatchResult?

Receiver

Name Description
RawToken

ReturnValue

Name Description
TokenMatchResult?

isFloatLiteral

fun RawToken.isFloatLiteral(): Boolean

Receiver

Name Description
RawToken

ReturnValue

Name Description
Boolean

toFloatLiteral

fun RawToken.toFloatLiteral(): FloatLiteral

Receiver

Name Description
RawToken

ReturnValue

Name Description
FloatLiteral

findIdentifier

fun RawToken.findIdentifier(): TokenMatchResult?

Receiver

Name Description
RawToken

ReturnValue

Name Description
TokenMatchResult?

isIdentifier

fun RawToken.isIdentifier(): Boolean

Receiver

Name Description
RawToken

ReturnValue

Name Description
Boolean

toIdentifier

fun RawToken.toIdentifier(): Identifier

Receiver

Name Description
RawToken

ReturnValue

Name Description
Identifier

findIntegerLiteral

fun RawToken.findIntegerLiteral(): TokenMatchResult?

Receiver

Name Description
RawToken

ReturnValue

Name Description
TokenMatchResult?

isIntegerLiteral

fun RawToken.isIntegerLiteral(): Boolean

Receiver

Name Description
RawToken

ReturnValue

Name Description
Boolean

toIntegerLiteral

fun RawToken.toIntegerLiteral(): IntegerLiteral<*>

Receiver

Name Description
RawToken

ReturnValue

Name Description
IntegerLiteral<*>

findKeyword

fun RawToken.findKeyword(): TokenMatchResult?

Receiver

Name Description
RawToken

ReturnValue

Name Description
TokenMatchResult?

isKeyword

fun RawToken.isKeyword(): Boolean

Receiver

Name Description
RawToken

ReturnValue

Name Description
Boolean

toKeyword

fun RawToken.toKeyword(): Keyword

Receiver

Name Description
RawToken

ReturnValue

Name Description
Keyword

findParen

fun RawToken.findParen(): TokenMatchResult?

Receiver

Name Description
RawToken

ReturnValue

Name Description
TokenMatchResult?

isOpenParen

fun RawToken.isOpenParen(): Boolean

Receiver

Name Description
RawToken

ReturnValue

Name Description
Boolean

isClosedParen

fun RawToken.isClosedParen(): Boolean

Receiver

Name Description
RawToken

ReturnValue

Name Description
Boolean

toParen

fun RawToken.toParen(): Paren

Receiver

Name Description
RawToken

ReturnValue

Name Description
Paren

findReserved

fun RawToken.findReserved(): TokenMatchResult?

Receiver

Name Description
RawToken

ReturnValue

Name Description
TokenMatchResult?

isReserved

fun RawToken.isReserved(): Boolean

Receiver

Name Description
RawToken

ReturnValue

Name Description
Boolean

toReserved

fun RawToken.toReserved(): Reserved

Receiver

Name Description
RawToken

ReturnValue

Name Description
Reserved

findStringLiteral

fun RawToken.findStringLiteral(): TokenMatchResult?

Receiver

Name Description
RawToken

ReturnValue

Name Description
TokenMatchResult?

isStringLiteral

fun RawToken.isStringLiteral(): Boolean

Receiver

Name Description
RawToken

ReturnValue

Name Description
Boolean

toStringLiteral

fun RawToken.toStringLiteral(): StringLiteral

Receiver

Name Description
RawToken

ReturnValue

Name Description
StringLiteral