In This Article

ParserState Class

Represents an object that tracks the current state of a ILLParser.

public class ParserState : IParserState
Inheritance:
object object
Implements:
IParserState

Constructors

ParserState(ILLParser, ITokenReader, IAstNodeBuilder, ITextSnapshot)

Initializes a new instance of the ParserState class.

public ParserState(ILLParser parser, ITokenReader tokenReader, IAstNodeBuilder astNodeBuilder, ITextSnapshot snapshot)
Parameter Type Description
parser ILLParser

The ILLParser for which this state is tracking data.

tokenReader ITokenReader

The ITokenReader that is used to read tokens during the parsing operation.

astNodeBuilder IAstNodeBuilder

The IAstNodeBuilder to use for constructing AST node results

snapshot ITextSnapshot

The ITextSnapshot used to initiate the parsing operation, if known.

Properties

AstNodeBuilder

Gets the IAstNodeBuilder to use for constructing AST node results.

public IAstNodeBuilder AstNodeBuilder { get; }

Property Value

IAstNodeBuilder:

The IAstNodeBuilder to use for constructing AST node results.

CustomData

Gets or sets custom data that can be altered during a parsing operation.

public object CustomData { get; set; }

Property Value

object:

Custom data that can be altered during a parsing operation.

ParseErrors

Gets the collection of IParseError objects that will be returned in the IParseData parsing result.

public IEnumerable<IParseError> ParseErrors { get; }

Property Value

IEnumerable<IParseError>:

The collection of IParseError objects that will be returned in the IParseData parsing result.

Parser

Gets the ILLParser for which this state is tracking data.

public ILLParser Parser { get; }

Property Value

ILLParser:

The ILLParser for which this state is tracking data

Snapshot

Gets the ITextSnapshot used to initiate the parsing operation, if known.

public ITextSnapshot Snapshot { get; }

Property Value

ITextSnapshot:

The ITextSnapshot used to initiate the parsing operation, if known.

TokenReader

Gets the ITokenReader that is used to read tokens during the parsing operation.

public ITokenReader TokenReader { get; }

Property Value

ITokenReader:

The ITokenReader that is used to read tokens during the parsing operation.

UntargetableParseErrorTokenIds

Gets or sets the collection of token IDs that should be avoided when determining where untargeted parse errors will appear.

public IEnumerable<int> UntargetableParseErrorTokenIds { get; set; }

Property Value

IEnumerable<int>:

The collection of token IDs that should be avoided when determining where untargeted parse errors will appear.

Remarks

If a parse error is reported without a target token, the parser will normally place the parse error at the next token. If that token is one of the IDs found in this collection, the parse error will appear after the previous token instead. This property should be set to a collection of any IDs for visually-insignificant tokens that can be passed to the parser such as a line feed, line continuation, document end, etc.

Methods

ReportError(IParseError)

Reports an IParseError.

public virtual void ReportError(IParseError parseError)
Parameter Type Description
parseError IParseError

The IParseError object that contains details about the error.

ReportError(ParseErrorLevel, string)

Reports an IParseError, using the look-ahead token for its range.

public IParseError ReportError(ParseErrorLevel level, string description)
Parameter Type Description
level ParseErrorLevel

A ParseErrorLevel indicating the error level.

description string

The description of the error, which is displayed in the user interface.

Returns

IParseError:

The IParseError that was reported.

ReportError(ParseErrorLevel, string, IToken)

Reports an IParseError, using the specified token for its range.

public IParseError ReportError(ParseErrorLevel level, string description, IToken token)
Parameter Type Description
level ParseErrorLevel

A ParseErrorLevel indicating the error level.

description string

The description of the error, which is displayed in the user interface.

token IToken

The IToken to examine for the error range. If not passed, the look-ahead token is used.

Returns

IParseError:

The IParseError that was reported.

ReportNonTerminalExpectedError(NonTerminal)

Reports an IParseError indicating that a NonTerminal was expected, but not found.

public IParseError ReportNonTerminalExpectedError(NonTerminal nonTerminal)
Parameter Type Description
nonTerminal NonTerminal

The NonTerminal that was expected.

Returns

IParseError:

The IParseError that was reported.

ReportNonTerminalExpectedError(NonTerminal, IToken)

Reports an IParseError indicating that a NonTerminal was expected, but not found.

public IParseError ReportNonTerminalExpectedError(NonTerminal nonTerminal, IToken token)
Parameter Type Description
nonTerminal NonTerminal

The NonTerminal that was expected.

token IToken

The IToken at which the error should be reported.

Returns

IParseError:

The IParseError that was reported.

ReportNonTerminalExpectedError(NonTerminal, TextPositionRange)

Reports an IParseError indicating that a NonTerminal was expected, but not found.

public IParseError ReportNonTerminalExpectedError(NonTerminal nonTerminal, TextPositionRange positionRange)
Parameter Type Description
nonTerminal NonTerminal

The NonTerminal that was expected.

positionRange TextPositionRange

The TextPositionRange over which the error should be reported.

Returns

IParseError:

The IParseError that was reported.

ReportTerminalExpectedError(Terminal)

Reports an IParseError indicating that a Terminal was expected, but not found.

public IParseError ReportTerminalExpectedError(Terminal terminal)
Parameter Type Description
terminal Terminal

The Terminal that was expected.

Returns

IParseError:

The IParseError that was reported.

ReportTerminalExpectedError(Terminal, IToken)

Reports an IParseError indicating that a Terminal was expected, but not found.

public IParseError ReportTerminalExpectedError(Terminal terminal, IToken token)
Parameter Type Description
terminal Terminal

The Terminal that was expected.

token IToken

The IToken at which the error should be reported.

Returns

IParseError:

The IParseError that was reported.

ReportTerminalExpectedError(Terminal, TextPositionRange)

Reports an IParseError indicating that a Terminal was expected, but not found.

public IParseError ReportTerminalExpectedError(Terminal terminal, TextPositionRange positionRange)
Parameter Type Description
terminal Terminal

The Terminal that was expected.

positionRange TextPositionRange

The TextPositionRange over which the error should be reported.

Returns

IParseError:

The IParseError that was reported.

Inherited Members