package org.spoofax.jsglr2.actions;

import org.spoofax.jsglr2.characters.ICharacters;
import org.spoofax.jsglr2.parsetable.IProduction;
import org.spoofax.jsglr2.parsetable.ProductionType;

public class Reduce extends Action implements IReduce {

    private final IProduction production;
    private final ProductionType productionType;
    private final int arity;

    public Reduce(ICharacters characters, IProduction production, ProductionType productionType, int arity) {
        super(characters);

        this.production = production;
        this.productionType = productionType;
        this.arity = arity;

        /*
         * NOTE: according to Eduardo, the type of the action and of the production should match for types REJECT /
         * PREFER / AVOID at least. There seems to be a bug in the parse table generator.
         */
        assert !(productionType == ProductionType.REJECT || productionType == ProductionType.PREFER
            || productionType == ProductionType.AVOID) || productionType == production.productionType();

        assert !(production.productionType() == ProductionType.REJECT
            || production.productionType() == ProductionType.PREFER
            || production.productionType() == ProductionType.AVOID) || production.productionType() == productionType;
    }

    public IProduction production() {
        return production;
    }

    public ProductionType productionType() {
        return productionType;
    }

    public int arity() {
        return arity;
    }

}

@@ -829,16 +829,116 @@
 nerator.
+ If this bug is fixed the%0A         * asserts below should succeed (they are failing now).%0A         *
 %0A       
@@ -940,25 +940,16 @@
        *
-/%0A       
  assert 
@@ -1028,36 +1028,24 @@
 nType.PREFER
-%0A           
  %7C%7C producti
@@ -1042,32 +1042,43 @@
 %7C productionType
+%0A         *
  == ProductionTy
@@ -1137,24 +1137,35 @@
 Type();%0A
+         * 
 %0A       
  assert 
@@ -1156,16 +1156,19 @@
 %0A       
+  *
  assert 
@@ -1221,28 +1221,16 @@
 e.REJECT
-%0A           
  %7C%7C prod
@@ -1247,32 +1247,43 @@
 ductionType() ==
+%0A         *
  ProductionType.
@@ -1292,20 +1292,8 @@
 EFER
-%0A           
  %7C%7C 
@@ -1371,24 +1371,35 @@
 uctionType()
+%0A         *
  == producti
@@ -1398,32 +1398,44 @@
 productionType;%0A
+         */%0A
     %7D%0A%0A    publi

Disable failing asserts due to parser generator bug