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

Represents an LLLPG rule, which is a Predicate plus a Name and optional attributes (e.g. token, private, etc.). More...


Source file:

Remarks

Represents an LLLPG rule, which is a Predicate plus a Name and optional attributes (e.g. token, private, etc.).

Public fields

LNode Basis
 A node that contains the original code of the rule, or, if the rule was created programmatically, the method prototype (e.g. #fn(int, Rule, #(#var(int, arg))), which means int Rule(int arg)). This can be null, in which case the default prototype is void Rule();, or if the rule is a starting rule or token, public void Rule();. More...
 
LNode ReturnType
 
readonly EndOfRule EndOfRule
 
Symbol Name
 
Pred Pred
 
bool IsToken
 
bool IsExternal
 
bool? IsPrivate
 
bool? FullLLk
 
int K
 
bool IsRecognizer
 
LNode TryWrapperName
 
Rule _recognizer
 

Properties

bool HasRecognizerVersion [get]
 

Public Member Functions

 Rule (LNode basis, Symbol name, Pred pred, bool isStartingRule=true)
 
Rule MakeRecognizerVersion ()
 
Rule MakeRecognizerVersion (Symbol newName)
 
Rule MakeRecognizerVersion (LNode prototype)
 
void TryWrapperNeeded ()
 
override string ToString ()
 
LNode GetMethodSignature ()
 Returns Basis if it's a method signature; otherwise constructs a default signature. More...
 
LNode CreateMethod (LNodeList methodBody)
 Creates the default method definition to wrap around the body of the rule, which has already been generated. Returns Basis with the specified new method body. If Basis is null, a simple default method signature is used, e.g. public void R() {...} where R is the rule name. More...
 

Static Public Member Functions

static Alts operator| (Rule a, Pred b)
 
static Alts operator| (Pred a, Rule b)
 
static Alts operator| (Rule a, Rule b)
 
static Alts operator/ (Rule a, Pred b)
 
static Alts operator/ (Pred a, Rule b)
 
static Alts operator/ (Rule a, Rule b)
 
static Pred operator+ (Rule a, char b)
 
static Pred operator+ (char a, Rule b)
 
static Pred operator+ (Rule a, LNode b)
 
static Pred operator+ (LNode a, Rule b)
 
static implicit operator Rule (RuleRef rref)
 
static implicit operator RuleRef (Rule rule)
 

Member Function Documentation

◆ CreateMethod()

LNode Loyc.LLParserGenerator.Rule.CreateMethod ( LNodeList  methodBody)
inline

Creates the default method definition to wrap around the body of the rule, which has already been generated. Returns Basis with the specified new method body. If Basis is null, a simple default method signature is used, e.g. public void R() {...} where R is the rule name.

Parameters
methodBodyThe parsing code that was generated for this rule.
Returns
A method.

References Loyc.Syntax.LNode.Args, Loyc.LLParserGenerator.Rule.GetMethodSignature(), Loyc.Syntax.CodeSymbols.Missing, Loyc.Syntax.CodeSymbols.Return, and Loyc.Syntax.LNode.WithArgs().

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

◆ GetMethodSignature()

LNode Loyc.LLParserGenerator.Rule.GetMethodSignature ( )
inline

Member Data Documentation

◆ Basis

LNode Loyc.LLParserGenerator.Rule.Basis

A node that contains the original code of the rule, or, if the rule was created programmatically, the method prototype (e.g. #fn(int, Rule, #(#var(int, arg))), which means int Rule(int arg)). This can be null, in which case the default prototype is void Rule();, or if the rule is a starting rule or token, public void Rule();.

The Basis is also used to provide an error location.

Referenced by Loyc.LLParserGenerator.CodeGenHelperBase.CallRule(), and Loyc.LLParserGenerator.Rule.GetMethodSignature().