TokenKindExtensions Class

Helper functions for TokenKind

public static class TokenKindExtensions

Methods

NameDescription
IsDateTime(TokenKind)Checks if the specified kind is a datetime.
IsFloat(TokenKind)Checks if the specified kind is a float.
IsHidden(TokenKind, bool)Returns true if the specified token kind is considered as hidden (comments, whitespaces or newline)
IsInteger(TokenKind)Checks if the specified kind is an integer
IsString(TokenKind)Checks if the specified kind is a string.
IsToken(TokenKind)Checks if the specified kind is a token for which TokenKindExtensions.ToText will return not null
IsTrivia(TokenKind)Checks if the specified kind is a trivia.
ToText(TokenKind)Gets a textual representation of a token kind or null if not applicable (e.g TokenKind.Integer)

IsDateTime(TokenKind)

TokenKindExtensions.cs

Checks if the specified kind is a datetime.

public static bool IsDateTime(this TokenKind kind)

Parameters

kind TokenKind
A token kind

Returns

bool true if the specified kind is a datetime.

IsFloat(TokenKind)

TokenKindExtensions.cs

Checks if the specified kind is a float.

public static bool IsFloat(this TokenKind kind)

Parameters

kind TokenKind
A token kind

Returns

bool true if the specified kind is a float.

IsHidden(TokenKind, bool)

TokenKindExtensions.cs

Returns true if the specified token kind is considered as hidden (comments, whitespaces or newline)

public static bool IsHidden(this TokenKind tokenKind, bool hideNewLine = true)

Parameters

tokenKind TokenKind
The token kind.
hideNewLine bool
Makes the newline hidden by default. Default is true.

Returns

bool true if the specified token kind is considered as hidden; false otherwise

IsInteger(TokenKind)

TokenKindExtensions.cs

Checks if the specified kind is an integer

public static bool IsInteger(this TokenKind kind)

Parameters

kind TokenKind
A token kind

Returns

bool true if the specified kind is an integer.

IsString(TokenKind)

TokenKindExtensions.cs

Checks if the specified kind is a string.

public static bool IsString(this TokenKind kind)

Parameters

kind TokenKind
A token kind

Returns

bool true if the specified kind is a string

IsToken(TokenKind)

TokenKindExtensions.cs

Checks if the specified kind is a token for which TokenKindExtensions.ToText will return not null

public static bool IsToken(this TokenKind kind)

Parameters

kind TokenKind
A token kind

Returns

bool true if the specified kind is a simple token

IsTrivia(TokenKind)

TokenKindExtensions.cs

Checks if the specified kind is a trivia.

public static bool IsTrivia(this TokenKind kind)

Parameters

kind TokenKind
A token kind

Returns

bool true if the specified kind is a trivia

ToText(TokenKind)

TokenKindExtensions.cs

Gets a textual representation of a token kind or null if not applicable (e.g TokenKind.Integer)

public static string? ToText(this TokenKind kind)

Parameters

kind TokenKind
A token kind

Returns

string? A textual representation of a token kind or null if not applicable (e.g TokenKind.Integer)