Table of Contents

Struct TokenizerResult

Namespace
Farkle.Parser.Tokenizers
Assembly
Farkle.dll

Represents a Tokenizer<TChar>'s successful or failed result.

public readonly struct TokenizerResult
Inherited Members

Remarks

Besides success and failure, the third possible outcome happens when the tokenizer needs more input to make a decision. In this case the TryGetNextToken(ref ParserInputReader<TChar>, ITokenSemanticProvider<TChar>, out TokenizerResult) method will return false.

Properties

Data

The token's semantic value in case of success or an object describing the error in case of failure. In the latter case the value is not null.

public object? Data { get; }

Property Value

object

IsSuccess

Whether the TokenizerResult represents success.

public bool IsSuccess { get; }

Property Value

bool

Position

Contains the position of the first character of the token.

public TextPosition Position { get; }

Property Value

TextPosition

Symbol

The TokenSymbolHandle that identifies the symbol of token.

public TokenSymbolHandle Symbol { get; }

Property Value

TokenSymbolHandle

Remarks

If IsSuccess is false, this property will have a value of default.

Methods

CreateError(object)

Creates a TokenizerResult signifying success.

public static TokenizerResult CreateError(object error)

Parameters

error object

An object describing the error.

Returns

TokenizerResult

Exceptions

ArgumentNullException

error is null.

CreateSuccess(TokenSymbolHandle, object?, TextPosition)

Creates a TokenizerResult signifying success.

public static TokenizerResult CreateSuccess(TokenSymbolHandle symbol, object? data, TextPosition position)

Parameters

symbol TokenSymbolHandle

The token's symbol.

data object

The token's semantic value.

position TextPosition

The token's position.

Returns

TokenizerResult