Table of Contents

Class TokenizerRuntime

Namespace
Utils.Parser.Runtime
Assembly
Utils.Parser.dll

Provides reusable tokenization mechanics for parser-oriented consumers.

public sealed class TokenizerRuntime
Inheritance
TokenizerRuntime
Inherited Members
Extension Methods

Constructors

TokenizerRuntime(string, IEnumerable<char>, IEnumerable<string>, IEnumerable<RuntimeTryReadToken>, IEnumerable<RuntimeStringTransformer>)

Initializes a new instance of the TokenizerRuntime class.

public TokenizerRuntime(string content, IEnumerable<char> whiteSpaces, IEnumerable<string> symbols, IEnumerable<RuntimeTryReadToken> tokenReaders, IEnumerable<RuntimeStringTransformer> stringTransformers)

Parameters

content string

Source content to tokenize.

whiteSpaces IEnumerable<char>

Whitespace characters to skip when requested.

symbols IEnumerable<string>

Symbols to match when token readers do not consume input.

tokenReaders IEnumerable<RuntimeTryReadToken>

Custom token readers.

stringTransformers IEnumerable<RuntimeStringTransformer>

Custom string transformers.

Properties

DefineString

Gets the most recently defined string value.

public string DefineString { get; }

Property Value

string

Position

Gets the current tokenizer position.

public RuntimeTokenizerPosition Position { get; }

Property Value

RuntimeTokenizerPosition

Methods

DiscardPosition()

Discards the last saved position.

public void DiscardPosition()

PeekToken()

Peeks the next token without consuming it.

public string? PeekToken()

Returns

string

The next token, or null.

PopPosition()

Restores the last saved position.

public void PopPosition()

PushPosition()

Saves the current position.

public void PushPosition()

ReadSymbol(string, bool)

Reads a symbol at the current position.

public bool ReadSymbol(string symbol, bool throwExceptionIfError)

Parameters

symbol string

Symbol expected at current location.

throwExceptionIfError bool

Indicates whether a mismatch throws.

Returns

bool

true when symbol matched; otherwise false.

ReadToken(bool)

Reads the next token.

public string? ReadToken(bool ignoreWhiteSpace = true)

Parameters

ignoreWhiteSpace bool

When true, skips configured whitespace characters.

Returns

string

The token text, or null when end-of-content is reached.

Reset()

Resets tokenizer state.

public void Reset()