TomlLexer Class

Provides incremental lexical tokenization for TOML text.

public sealed class TomlLexer

Properties

NameDescription
CurrentGets the current token.
CurrentSpanGets the source span associated with the current token.
ErrorsGets diagnostics produced by the lexer.
HasErrorsGets a value indicating whether lexer diagnostics include errors.
ModeGets or sets the lexer mode.
SourceNameGets the source name associated with this lexer.

Gets the current token.

public TomlToken Current { get; }

Property value

TomlToken

CurrentSpan

TomlLexer.cs

Gets the source span associated with the current token.

public TomlSourceSpan CurrentSpan { get; }

Property value

TomlSourceSpan

Gets diagnostics produced by the lexer.

public IEnumerable<DiagnosticMessage> Errors { get; }

HasErrors

TomlLexer.cs

Gets a value indicating whether lexer diagnostics include errors.

public bool HasErrors { get; }

Property value

bool

Gets or sets the lexer mode.

public TomlLexerMode Mode { get; set; }

Property value

TomlLexerMode

SourceName

TomlLexer.cs

Gets the source name associated with this lexer.

public string SourceName { get; }

Property value

string

Methods

NameDescription
Create(TextReader, TomlLexerOptions, string?)Creates a lexer over TOML text from a TextReader.
Create(TextReader, string?)Creates a lexer over TOML text from a TextReader.
Create(string, TomlLexerOptions, string?)Creates a lexer over TOML text.
Create(string, string?)Creates a lexer over TOML text.
GetText(TomlToken)Gets the raw source text represented by a token.
MoveNext()Advances to the next token.

Create overloads

Create(TextReader, TomlLexerOptions, string?)

TomlLexer.cs

Creates a lexer over TOML text from a TextReader.

public static TomlLexer Create(TextReader reader, TomlLexerOptions lexerOptions, string? sourceName = null)
Parameters
reader TextReader
The text reader.
lexerOptions TomlLexerOptions
Options controlling lexer behavior.
sourceName string?
An optional source name used in diagnostics.
Returns

TomlLexer A lexer instance positioned before the first token.

Exceptions
ArgumentNullException
reader is null.
ArgumentNullException
lexerOptions is null.

Create(TextReader, string?)

TomlLexer.cs

Creates a lexer over TOML text from a TextReader.

public static TomlLexer Create(TextReader reader, string? sourceName = null)
Parameters
reader TextReader
The text reader.
sourceName string?
An optional source name used in diagnostics.
Returns

TomlLexer A lexer instance positioned before the first token.

Exceptions
ArgumentNullException
reader is null.

Create(string, TomlLexerOptions, string?)

TomlLexer.cs

Creates a lexer over TOML text.

public static TomlLexer Create(string toml, TomlLexerOptions lexerOptions, string? sourceName = null)
Parameters
toml string
The TOML payload.
lexerOptions TomlLexerOptions
Options controlling lexer behavior.
sourceName string?
An optional source name used in diagnostics.
Returns

TomlLexer A lexer instance positioned before the first token.

Exceptions
ArgumentNullException
toml is null.
ArgumentNullException
lexerOptions is null.

Create(string, string?)

TomlLexer.cs

Creates a lexer over TOML text.

public static TomlLexer Create(string toml, string? sourceName = null)
Parameters
toml string
The TOML payload.
sourceName string?
An optional source name used in diagnostics.
Returns

TomlLexer A lexer instance positioned before the first token.

Exceptions
ArgumentNullException
toml is null.

GetText(TomlToken)

TomlLexer.cs

Gets the raw source text represented by a token.

public string? GetText(in TomlToken token)

Parameters

token TomlToken
The token.

Returns

string? The token text, or null if out of range.

MoveNext()

TomlLexer.cs

Advances to the next token.

public bool MoveNext()

Returns

bool true when a token is available; otherwise false.