kwasm.format.text.token.util

Kwasm.format.text.token.util

package kwasm.format.text.token.util

Classes

Name Description
class Frac

From the docs.


frac       ::= empty                               => 0
d:digit q:frac                      => (d + q) / 10
d:digit '' p:digit q:frac          => (d + (p + q) / 10) / 10
hexfrac    ::= empty                               => 0
h:hexdigit q:hexfrac                => (h + q) / 16
h:hexdigit '' p:hexdigit q:hexfrac => (h + (p + q) / 16) / 16

class Num

From the docs.

All integers can be written in either decimal or hexadecimal notation. In both cases, digits can optionally be separated by underscores.


digit      ::= '0' => 0, '1' => 1, ... '9' => 9
hexdigit   ::= d:digit => d
'A' => 10, 'B' => 11, ... 'F' => 15
'a' => 10, 'b' => 11, ... 'f' => 15
num        ::= d:digit => d
n:num ''? d:digit => n * 10 + d
hexnum     ::= h:hexdigit => h
n:hexnum ''? h:hexdigit => n * 16 + h

data class StringChar

Represents a single character as a unicode codepoint, and its original length in a wast file as part of a string literal.

data class CanonincalNaN

From the docs.

data class TokenMatchResult

Return value of RawToken's find[Token] extension methods.

Fields

Name Description
const STRINGCHAR_PATTERN: String

Pattern to check for valid StringChar elements. From the docs:


stringchar ::= c:char                  => c (if c ≥ U+20 ∧ c ≠ U+7F ∧ c ≠ ‘"’ ∧ c ≠ ‘∖’)
'∖t'                    => U+09
'∖n'                    => U+0A
'∖r'                    => U+0D
'∖"'                    => U+22
'∖''                    => U+27
'∖'                    => U+5C
'∖u{' n:hexnum '}'      => U+(n) (if n < 0xD800 ∨ 0xE000 ≤ n < 0x110000)

const STRINGELEM_PATTERN: String

From the docs:


stringelem ::= s:stringchar                => s as StringChar
'∖' n:hexdigit m:hexdigit   => StringChar(16 * n + m, 3)

Methods

parseLongSign

fun CharSequence.parseLongSign(): Pair<Int, Long>

Parses a sign (+ or -) from the beginning of the receiving CharSequence, and returns the sign value and intended offset for parsing the remainder of the value.

Receiver

Name Description
CharSequence

ReturnValue

Name Description
Pair<Int, Long>

parseDigit

fun CharSequence.parseDigit(index: Int, context: ParseContext?): Byte

Parses a digit (as a Byte) from the receiving CharSequence at the given index.

Receiver

Name Description
CharSequence

Parameters

Name Description
index: Int
context: ParseContext?

ReturnValue

Name Description
Byte

parseStringElem

fun CharSequence.parseStringElem(index: Int, inoutVal: StringChar, context: ParseContext?): StringChar

Parses a stringelem from the receiving CharSequence at the given index as a StringChar.

From the docs:


stringelem ::= s:stringchar                => s as StringChar
'∖' n:hexdigit m:hexdigit   => StringChar(16 * n + m, 3)

Receiver

Name Description
CharSequence

Parameters

Name Description
index: Int
inoutVal: StringChar
context: ParseContext?

ReturnValue

Name Description
StringChar

parseStringChar

fun CharSequence.parseStringChar(index: Int, inoutVal: StringChar, context: ParseContext?): StringChar

Parses a StringChar from the receiving CharSequence at the given index.

From the docs:


stringchar ::= c:char                  => c (if c ≥ U+20 ∧ c ≠ U+7F ∧ c ≠ ‘"’ ∧ c ≠ ‘∖’)
'∖t'                    => U+09
'∖n'                    => U+0A
'∖r'                    => U+0D
'∖"'                    => U+22
'∖''                    => U+27
'∖'                    => U+5C
'∖u{' n:hexnum '}'      => U+(n) (if n < 0xD800 ∨ 0xE000 ≤ n < 0x110000)

Receiver

Name Description
CharSequence

Parameters

Name Description
index: Int
inoutVal: StringChar
context: ParseContext?

ReturnValue

Name Description
StringChar

parseDigit

fun IntArray.parseDigit(index: Int, context: ParseContext?): Byte

Receiver

Name Description
IntArray

Parameters

Name Description
index: Int
context: ParseContext?

ReturnValue

Name Description
Byte

parseStringElem

fun IntArray.parseStringElem(index: Int, inoutVal: StringChar, context: ParseContext?): StringChar

Receiver

Name Description
IntArray

Parameters

Name Description
index: Int
inoutVal: StringChar
context: ParseContext?

ReturnValue

Name Description
StringChar

parseStringChar

fun IntArray.parseStringChar(index: Int, inoutVal: StringChar, context: ParseContext?): StringChar

Receiver

Name Description
IntArray

Parameters

Name Description
index: Int
inoutVal: StringChar
context: ParseContext?

ReturnValue

Name Description
StringChar

parseDigit

fun Char.parseDigit(context: ParseContext?): Byte

Receiver

Name Description
Char

Parameters

Name Description
context: ParseContext?

ReturnValue

Name Description
Byte

significand

fun Int.significand(context: ParseContext?): Int

From the docs.

Receiver

Name Description
Int

Parameters

Name Description
context: ParseContext?

ReturnValue

Name Description
Int

expon

fun Int.expon(context: ParseContext?): Int

From the docs.

Receiver

Name Description
Int

Parameters

Name Description
context: ParseContext?

ReturnValue

Name Description
Int

canon

fun Int.canon(context: ParseContext?): Long

From the docs.

Receiver

Name Description
Int

Parameters

Name Description
context: ParseContext?

ReturnValue

Name Description
Long