public int?PrecedenceOf(ProductionRule production) { if (production.OverridePrecedence.HasValue) { return(PrecedenceOf(production.OverridePrecedence)); } for (var i = production.Ingredients.Length - 1; i >= 0; --i) { var precedence = PrecedenceOf(production.Ingredients[i]); if (precedence is not null) { return(precedence); } } return(null); }
public Associativity AssociativityOf(ProductionRule production) { if (production.OverridePrecedence.HasValue) { return(AssociativityOf(production.OverridePrecedence)); } for (var i = production.Ingredients.Length - 1; i >= 0; --i) { var assoc = AssociativityOf(production.Ingredients[i]); if (assoc != Associativity.Default) { return(assoc); } } return(Associativity.Default); }
public Item(ProductionRule production, int dotPos, Symbol follow) { Production = production; DotPos = dotPos; Follow = follow; }
private bool Equals(ProductionRule other) { return(Product.Equals(other.Product) && Ingredients.SequenceEqual(other.Ingredients) && OverridePrecedence.Equals(other.OverridePrecedence)); }
public static ParseAction MakeReduce(ProductionRule productionUsed) { return(new(ParseActionType.Reduce, productionUsed)); }