예제 #1
0
파일: Cfg.cs 프로젝트: ph3rin/sacc
 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);
 }
예제 #2
0
파일: Cfg.cs 프로젝트: ph3rin/sacc
 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);
 }
예제 #3
0
파일: Item.cs 프로젝트: ph3rin/sacc
 public Item(ProductionRule production, int dotPos, Symbol follow)
 {
     Production = production;
     DotPos     = dotPos;
     Follow     = follow;
 }
예제 #4
0
 private bool Equals(ProductionRule other)
 {
     return(Product.Equals(other.Product) && Ingredients.SequenceEqual(other.Ingredients) &&
            OverridePrecedence.Equals(other.OverridePrecedence));
 }
예제 #5
0
 public static ParseAction MakeReduce(ProductionRule productionUsed)
 {
     return(new(ParseActionType.Reduce, productionUsed));
 }