ParsingContext

class ParsingContext(val tokens: List<Token>, typeMap: Map<ParserNodeDeclaration<*>, DescribedType<*>>, val branchSeeker: BranchSeeker? = null)

This object contains the information that is passed to expectations, and is global over a single parser run.

Constructors

Link copied to clipboard
constructor(tokens: List<Token>, typeMap: Map<ParserNodeDeclaration<*>, DescribedType<*>>, branchSeeker: BranchSeeker? = null)

Properties

Link copied to clipboard

The BranchSeeker instance associated with this parsing context.

Link copied to clipboard

The list of tokens that should be parsed

Functions

Link copied to clipboard
fun <T> applyExpectations(startAt: Int, expectations: List<Expectation<T, *>>): ExpectationResult<T>

Apply each expectation of this list to the given context, starting at the given index.

Link copied to clipboard
fun <T> enterBranch(branchTitle: String, branch: () -> ExpectationResult<T>): ExpectationResult<T>

If debugging is enabled, execute a set of expectations "within" a special node. Otherwise, directly executed the provided branch.

Link copied to clipboard
operator fun <T> get(declaration: ParserNodeDeclaration<T>): DescribedType<T>?

Retrieve the provided node declaration, or null if no such declaration could be found.