Class ParseDiagnostic

Namespace
LogicalOptimizer
Assembly
LogicalOptimizer.Core.dll

Structured, machine-readable description of a parse failure, produced by TryParse(string, out AstNode?, out ParseDiagnostic?) and carried by FormulaParseException. It reports where the error is (Position, Length), a stable Code, the tokens that would have been valid (Expected), and a caret Snippet for display.

public sealed class ParseDiagnostic
Inheritance
ParseDiagnostic
Inherited Members

Properties

Code

Stable machine-readable error classification.

public ParseErrorCode Code { get; }

Property Value

ParseErrorCode

Expected

Token descriptions that would have been valid at this position (may be empty).

public IReadOnlyList<string> Expected { get; }

Property Value

IReadOnlyList<string>

Length

Length of the offending span; 0 at end of input (rendered as a single caret).

public int Length { get; }

Property Value

int

Message

Human-readable message (also the Message when thrown).

public string Message { get; }

Property Value

string

Position

Zero-based index into Source where the offending span begins.

public int Position { get; }

Property Value

int

Snippet

A two-line caret snippet: the source, then a line pointing at the offending span with ^. Useful for terminals, logs and error UIs.

public string Snippet { get; }

Property Value

string

Source

The source text this diagnostic refers to (empty when unavailable).

public string Source { get; }

Property Value

string

Methods

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.