Class TokenizerRuntime
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
contentstringSource content to tokenize.
whiteSpacesIEnumerable<char>Whitespace characters to skip when requested.
symbolsIEnumerable<string>Symbols to match when token readers do not consume input.
tokenReadersIEnumerable<RuntimeTryReadToken>Custom token readers.
stringTransformersIEnumerable<RuntimeStringTransformer>Custom string transformers.
Properties
DefineString
Gets the most recently defined string value.
public string DefineString { get; }
Property Value
Position
Gets the current tokenizer position.
public RuntimeTokenizerPosition Position { get; }
Property Value
Methods
DiscardPosition()
Discards the last saved position.
public void DiscardPosition()
PeekToken()
Peeks the next token without consuming it.
public string? PeekToken()
Returns
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
symbolstringSymbol expected at current location.
throwExceptionIfErrorboolIndicates whether a mismatch throws.
Returns
ReadToken(bool)
Reads the next token.
public string? ReadToken(bool ignoreWhiteSpace = true)
Parameters
Returns
Reset()
Resets tokenizer state.
public void Reset()