Beispiel #1
0
        public void EmitEquation(TextWriter where, InvariantQuery <APC> invariantDB)
        {
            string head = parent.Head(); // bn(... )

            StringBuilder bodyAsString = new StringBuilder();

            foreach (string s in to.FormalParameters)
            {
                string actualParameter = 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 (parent.Condition != null)
            { // no successors, so I just write down the parameters,
                bodyAsString.Append(BenigniMain.FormalParametersAsString(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 (parent.Condition != null)  // Is there a condition on the rewriting rule?
            {
                result = String.Format("{0} | {1} -> 1", result, 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);
        }
Beispiel #2
0
 private static string Initial(EquationBlock entry)
 {
     return(SanitizeString(String.Format(INITIAL, entry.Head())));
 }