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
IsSuccess
Whether the TokenizerResult represents success.
public bool IsSuccess { get; }
Property Value
Position
Contains the position of the first character of the token.
public TextPosition Position { get; }
Property Value
Symbol
The TokenSymbolHandle that identifies the symbol of token.
public TokenSymbolHandle Symbol { get; }
Property Value
Remarks
Methods
CreateError(object)
Creates a TokenizerResult signifying success.
public static TokenizerResult CreateError(object error)
Parameters
error
objectAn object describing the error.
Returns
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
TokenSymbolHandleThe token's symbol.
data
objectThe token's semantic value.
position
TextPositionThe token's position.