pegged.introspection

This module contains function to inspect a Pegged grammar.

Members

Enums

InfiniteLoop
enum InfiniteLoop

InfiniteLoop.yes means a rule can loop indefinitely while consuming nothing. InfiniteLoop.no means a rule cannot loop indefinitely. InfiniteLoop.indeterminate means the algorithm could not converge.

LeftRecursive
enum LeftRecursive

Left-recursion diagnostic for a rule. A rule is left-recursive when its own name appears at the beginning of its definition or behind possibly-null-matching rules (see below for null matches). For example A <- A 'a' is left-recursive, whereas A <- 'a' A is not. *But* A <- 'a'? A is left-recursive, since if the input does not begin with 'a', then the parsing will continue by invoking A again, at the same position.

NullMatch
enum NullMatch

NullMatch.yes means a rule can succeed while consuming no input. For example e? or e*, for all expressions e. Nullmatch.no means a rule will always consume at least a token while succeeding. Nullmatch.indeterminate means the algorithm could not converge.

Recursive
enum Recursive

The different kinds of recursion for a rule. 'direct' means the rule name appears in its own definition. 'indirect' means the rule calls itself through another rule (the call chain can be long).

Functions

appendCycleIfUnique
void appendCycleIfUnique(immutable(string[])[] cycles, string[] cycle)
Undocumented in source. Be warned that the author may not have intended to support it.
grammarInfo
GrammarInfo grammarInfo(ParseTree p)

Returns for all grammar rules:

replaceInto
ParseTree replaceInto(ParseTree parent, ParseTree child)

Act on rules parse tree as produced by pegged.parser. Replace every occurence of child in parent by child's parse tree

ruleInfo
RuleInfo[string] ruleInfo(ParseTree p)
RuleInfo[string] ruleInfo(string grammar)

Returns for all grammar rules:

Structs

GrammarInfo
struct GrammarInfo

Struct holding the introspection info on a grammar.

RuleInfo
struct RuleInfo

Struct holding the introspection info on a rule.

Meta