Esempio n. 1
0
 public void EmitEquations(TextWriter where, InvariantQuery <APC> invariantDB)
 {
     foreach (EquationBody body in this.bodies)
     {
         body.EmitEquation(where, invariantDB);
     }
 }
Esempio n. 2
0
        public void EmitEquation(TextWriter where, InvariantQuery <APC> invariantDB)
        {
            string head = this.parent.Head(); // bn(... )

            StringBuilder bodyAsString = new StringBuilder();

            foreach (string s in this.to.FormalParameters)
            {
                string actualParameter = this.renamings[s];

                if (actualParameter == null)
                {
                    actualParameter = s; // if it is not there, it means that it is not renamed, i.e. it is the identity
                }
                bodyAsString.Append(actualParameter + BenigniMain.SEPPARAM);
            }

            if (bodyAsString.Length > BenigniMain.SEPPARAM.Length)
            {
                bodyAsString.Remove(bodyAsString.Length - BenigniMain.SEPPARAM.Length, BenigniMain.SEPPARAM.Length); // remove the last ", "
            }
            else if (this.parent.Condition != null)
            { // no successors, so I just write down the parameters,
                bodyAsString.Append(BenigniMain.FormalParametersAsString(this.parent.FormalParameters));
            }
            else
            {
                bodyAsString.Append(BenigniMain.EMPTY);
            }

            string succ = BenigniMain.BLOCKPREFIX + this.To.Block.Index;

            string result = String.Format("{0} {1} {2}( {3} ) ", head, BenigniMain.TRANS, succ, bodyAsString.ToString());

            string postState = invariantDB(this.To.Block.First);

            if (this.parent.Condition != null) // Is there a condition on the rewriting rule?
            {
                result = String.Format("{0} | {1} -> 1", result, this.parent.Condition);

                if (postState != null && postState.Length > 0)
                {
                    result += string.Format(", {0}", postState);
                }
            }
            else if (postState != null && postState.Length > 0)
            {
                result = String.Format("{0} | {1}", result, postState);
            }

            result = BenigniMain.SanitizeString(result);

            // Here we output the equation
            where.WriteLine(result);
        }
Esempio n. 3
0
        public static void EmitTheEquations(EquationBlock entryPoint, List <EquationBlock> equations, TextWriter where, InvariantQuery <APC> invariantDB)
        {
            Set <string> vars = new Set <string>();

            foreach (EquationBlock b in equations)
            {
                vars.AddRange(b.FormalParameters);
            }
            List <string> allVars = new List <string>(vars);

            allVars.Sort();

            where.WriteLine(Vars(allVars));

            where.WriteLine(Initial(entryPoint));


            where.WriteLine(BEGIN_RULES);
            foreach (EquationBlock b in equations)
            {
                b.EmitEquations(where, invariantDB);
            }
            where.WriteLine(END_RULES);
        }