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

Represents a zero-width assertion: either user-defined code to check a condition, or a predicate that scans ahead in the input and then backtracks to the starting point. More...


Source files:
Inheritance diagram for Loyc.LLParserGenerator.AndPred:
Loyc.LLParserGenerator.ZeroWidthPred Loyc.LLParserGenerator.Pred Loyc.ICloneable< Pred > Loyc.IHasLocation

Remarks

Represents a zero-width assertion: either user-defined code to check a condition, or a predicate that scans ahead in the input and then backtracks to the starting point.

Public fields

new bool Not = false
 Inverts the condition if Not==true, so that if the Pred matches, the AndPred does not match, and vice versa. More...
 
bool Local
 A local and-predicate cannot be hoisted into calling rules. More...
 
object Pred
 The predicate to match and backtrack. Must be of type LNode or Pred. More...
 
string CheckErrorMessage
 Error string passed to Check() in the generated code if the predicate is not matched. CodeGenHelperBase.GenerateAndPredCheck suppresses generation of Check() call when this is an empty string. More...
 
bool? Prematched
 
- Public fields inherited from Loyc.LLParserGenerator.Pred
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

bool PredUsesLA [get]
 Returns true if Pred contains $LA. More...
 
override bool IsNullable [get]
 
- Properties inherited from Loyc.LLParserGenerator.ZeroWidthPred
override bool IsNullable [get]
 
- Properties inherited from Loyc.LLParserGenerator.Pred
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

 AndPred (LNode basis, object pred, bool not, bool local)
 
override 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...
 
override string ToString ()
 
bool Equals (AndPred other)
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
override void Call (PredVisitor visitor)
 
- Public Member Functions inherited from Loyc.LLParserGenerator.ZeroWidthPred
 ZeroWidthPred (LNode basis)
 
- Public Member Functions inherited from Loyc.LLParserGenerator.Pred
 Pred (LNode basis)
 
LNode AutoSaveResult (LNode matchingCode)
 
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...
 
- Public Member Functions inherited from Loyc.ICloneable< Pred >
Clone ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Loyc.LLParserGenerator.Pred
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

◆ Clone()

override Pred Loyc.LLParserGenerator.AndPred.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 from Loyc.LLParserGenerator.Pred.

References Loyc.LLParserGenerator.Pred.Clone().

Member Data Documentation

◆ CheckErrorMessage

string Loyc.LLParserGenerator.AndPred.CheckErrorMessage

Error string passed to Check() in the generated code if the predicate is not matched. CodeGenHelperBase.GenerateAndPredCheck suppresses generation of Check() call when this is an empty string.

Initial value: null. User code can set this property by attaching a string as an attribute to an and-predicate (as of Jan 2017 this can only be done for semantic predicates as there is no syntax for attaching attributes to syntactic predicates).

Referenced by Loyc.LLParserGenerator.CodeGenHelperBase.GenerateAndPredCheck().

◆ Local

bool Loyc.LLParserGenerator.AndPred.Local

A local and-predicate cannot be hoisted into calling rules.

◆ Not

new bool Loyc.LLParserGenerator.AndPred.Not = false

Inverts the condition if Not==true, so that if the Pred matches, the AndPred does not match, and vice versa.

Referenced by Loyc.LLParserGenerator.CodeGenHelperBase.GenerateAndPredCheck().

◆ Pred

object Loyc.LLParserGenerator.AndPred.Pred

The predicate to match and backtrack. Must be of type LNode or Pred.

Referenced by Loyc.LLParserGenerator.CodeGenHelperBase.GenerateAndPredCheck().

Property Documentation

◆ PredUsesLA

bool Loyc.LLParserGenerator.AndPred.PredUsesLA
get

Returns true if Pred contains $LA.