FloatLiteral

FloatLiteral

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))

Fields

Name Description
var magnitude: Int
val value: Number
val context: ParseContext?

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

Constructors

<init>

constructor(sequence: CharSequence, magnitude: Int, context: ParseContext?)

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))

Parameters

Name Description
sequence: CharSequence
magnitude: Int
context: ParseContext?

Methods

isNaN

fun isNaN(): Boolean

ReturnValue

Name Description
Boolean

isInfinite

fun isInfinite(): Boolean

ReturnValue

Name Description
Boolean

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