Enhanced C#
Language of your choice: library documentation
Public fields | Properties | Public Member Functions | Static Public Member Functions | List of all members
Loyc.LLParserGenerator.Pred Class Referenceabstract

Represents part of a grammar for the LLParserGenerator. More...


Source files:
Inheritance diagram for Loyc.LLParserGenerator.Pred:
Loyc.ICloneable< Pred > Loyc.IHasLocation Loyc.LLParserGenerator.Alts Loyc.LLParserGenerator.DefaultErrorBranch Loyc.LLParserGenerator.EndOfRule Loyc.LLParserGenerator.Gate Loyc.LLParserGenerator.RuleRef Loyc.LLParserGenerator.Seq Loyc.LLParserGenerator.TerminalPred Loyc.LLParserGenerator.ZeroWidthPred

Remarks

Represents part of a grammar for the LLParserGenerator.

This class is the root of a class hierarchy which contains

Each Pred object can be used only once in a grammar, because Preds contain context- sensitive state such as the Next field, which are used during grammar analysis. A Pred must be Clone()d if one wants to use it multiple times.

Public fields

Symbol VarLabel
 
bool VarIsList
 
Func< LNode, LNodeResultSaver
 A function that saves the result produced by the matching code of this predicate (null if the result is not saved). For example, if the parser generator is given the predicate @[ x='a'..'z' ], the default matching code will be @(Match('a', 'z')), and ResultSaver will be set to a function that receives this matching code and returns @(x = Match('a', 'z')) in response. More...
 

Properties

LNode Basis [get, protected set]
 
abstract bool IsNullable [get]
 Returns true if this predicate can match an empty input. More...
 
object? Location [get]
 
- Properties inherited from Loyc.IHasLocation
object Location [get]
 

Public Member Functions

 Pred (LNode basis)
 
LNode AutoSaveResult (LNode matchingCode)
 
virtual Pred Clone ()
 Deep-clones a predicate tree. Terminal sets and Nodes referenced by the tree are not cloned; the clone's value of Next will be null. The same Pred cannot appear in two places in a tree, so you must clone before re-use. More...
 
string ToStringWithPosition ()
 
virtual string ChooseGotoLabel ()
 Optional. If this predicate represents the matching code for a branch of an Alts and this code is reached through a goto statement, this method is used to select a label name. Supported by RuleRef. More...
 
abstract void Call (PredVisitor visitor)
 
- Public Member Functions inherited from Loyc.ICloneable< Pred >
Clone ()
 

Static Public Member Functions

static Seq operator+ (char a, Pred b)
 
static Seq operator+ (Pred a, char b)
 
static Seq operator+ (Pred a, Pred b)
 
static Pred operator| (char a, Pred b)
 
static Pred operator| (Pred a, char b)
 
static Pred operator| (Pred a, Pred b)
 
static Pred operator/ (Pred a, Pred b)
 
static Pred operator+ (Pred a)
 
static Pred Or (Pred a, Pred b, bool slashJoined)
 
static Pred Or (Pred a, Pred b, bool slashJoined, LNode basis, BranchMode aMode=BranchMode.None, BranchMode bMode=BranchMode.None, IMessageSink sink=null)
 
static Alts Star (Pred contents, bool? greedy=null)
 
static Alts Opt (Pred contents, bool? greedy=null)
 
static Seq Plus (Pred contents, bool? greedy=null)
 
static TerminalPred Range (char lo, char hi)
 
static TerminalPred Set (IPGTerminalSet set)
 
static TerminalPred Set (string set)
 
static TerminalPred Set (params LNode[] s)
 
static TerminalPred Not (params LNode[] s)
 
static TerminalPred Char (char c)
 
static TerminalPred Chars (params char[] c)
 
static Seq Seq (string s, LNode basis=null)
 
static Rule Rule (string name, Pred pred, bool isStartingRule=false, bool isToken=false, int maximumK=-1)
 
static Pred operator+ (LNode pre, Pred p)
 
static Pred operator+ (Pred p, LNode post)
 
static LNode MergeActions (LNode action, LNode action2)
 
static AndPred And (object test)
 
static AndPred AndNot (object test)
 
static Pred Set (string varName, Pred pred)
 
static Pred SetVar (string varName, Pred pred)
 
static Pred AddSet (string varName, Pred pred)
 
static Pred Op (string varName, Symbol @operator, Pred pred)
 

Member Function Documentation

◆ ChooseGotoLabel()

virtual string Loyc.LLParserGenerator.Pred.ChooseGotoLabel ( )
inlinevirtual

Optional. If this predicate represents the matching code for a branch of an Alts and this code is reached through a goto statement, this method is used to select a label name. Supported by RuleRef.

Returns
A label name, or null if the predicate did not choose one.

Reimplemented in Loyc.LLParserGenerator.Seq, and Loyc.LLParserGenerator.RuleRef.

Referenced by Loyc.LLParserGenerator.Seq.ChooseGotoLabel().

◆ Clone()

virtual Pred Loyc.LLParserGenerator.Pred.Clone ( )
inlinevirtual

Deep-clones a predicate tree. Terminal sets and Nodes referenced by the tree are not cloned; the clone's value of Next will be null. The same Pred cannot appear in two places in a tree, so you must clone before re-use.

Reimplemented in Loyc.LLParserGenerator.AndPred, Loyc.LLParserGenerator.Gate, Loyc.LLParserGenerator.Alts, and Loyc.LLParserGenerator.Seq.

Referenced by Loyc.LLParserGenerator.Seq.Clone(), Loyc.LLParserGenerator.Gate.Clone(), and Loyc.LLParserGenerator.AndPred.Clone().

Member Data Documentation

◆ ResultSaver

Func<LNode, LNode> Loyc.LLParserGenerator.Pred.ResultSaver

A function that saves the result produced by the matching code of this predicate (null if the result is not saved). For example, if the parser generator is given the predicate @[ x='a'..'z' ], the default matching code will be @(Match('a', 'z')), and ResultSaver will be set to a function that receives this matching code and returns @(x = Match('a', 'z')) in response.

Property Documentation

◆ IsNullable

abstract bool Loyc.LLParserGenerator.Pred.IsNullable
get

Returns true if this predicate can match an empty input.