Exemplo n.º 1
0
        /// <summary>
        /// Provides an explanation of the function's behaviour
        /// </summary>
        /// <param name="indentLevel">the number of white spaces to add at the beginning of each line</param>
        /// <returns></returns>
        public string getExplain(int indentLevel)
        {
            string retVal = "";

            retVal =
                TextualExplainUtilities.Comment(Comment, indentLevel)
                + TextualExplainUtilities.Comment(TextualExplainUtilities.Iterate('-', 6 + Name.Length), indentLevel)
                + TextualExplainUtilities.Pad("{FUNCTION " + Name + "(", indentLevel);

            foreach (Parameter parameter in FormalParameters)
            {
                retVal = retVal + "\\par" + TextualExplainUtilities.Pad(parameter.Name + " : " + parameter.TypeName, indentLevel + 2);
            }

            if (FormalParameters.Count > 0)
            {
                retVal += "\\par";
            }
            retVal = retVal + ") {\\b RETURNS} { \\cf2" + TypeName + "}}\\par";

            foreach (Case cas in Cases)
            {
                retVal = retVal + "\\par"
                         + TextualExplainUtilities.Pad("{\\cf11 // " + cas.Name + "}\\cf1\\par", indentLevel + 2)
                         + cas.getExplain(indentLevel + 2);
            }

            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Provides an explanation of the rule's behaviour
        /// </summary>
        /// <param name="indentLevel">the number of white spaces to add at the beginning of each line</param>
        /// <param name="firstCondition">indicates whether this is the first condition or a following condition in a rule</param>
        /// <returns></returns>
        public string getExplain(int indentLevel, bool firstCondition, bool getExplain)
        {
            string retVal = "";

            int subIndent = 0;

            if (PreConditions.Count > 0)
            {
                subIndent = 2;
                bool first = true;
                foreach (PreCondition preCondition in PreConditions)
                {
                    if (first)
                    {
                        if (firstCondition)
                        {
                            retVal = retVal + TextualExplainUtilities.Pad("{\\b IF} " + preCondition.getExplain(true), indentLevel);
                        }
                        else
                        {
                            retVal = retVal + TextualExplainUtilities.Pad("{\\b ELSIF} " + preCondition.getExplain(true), indentLevel);
                        }
                        first = false;
                    }
                    else
                    {
                        retVal = retVal + " {\\b AND} " + preCondition.getExplain(true);
                    }
                }
                retVal = retVal + " {\\b THEN}\\par";
            }
            else
            {
                if (!firstCondition)
                {
                    subIndent = 2;
                    retVal    = retVal + TextualExplainUtilities.Pad("{\\b ELSE\\par} ", indentLevel);
                }
            }

            if (Name.CompareTo(EnclosingRule.Name) != 0)
            {
                retVal = retVal + TextualExplainUtilities.Pad("{\\cf11//" + Name + "}\\cf1\\par", indentLevel + subIndent);
            }

            if (getExplain)
            {
                foreach (Rule subRule in SubRules)
                {
                    retVal = retVal + subRule.getExplain(indentLevel + subIndent, true);
                }
            }

            foreach (Action action in Actions)
            {
                retVal = retVal + "{" + TextualExplainUtilities.Pad(action.getExplain() + "\\par}", indentLevel + subIndent);
            }

            return(retVal);
        }
Exemplo n.º 3
0
 private void insertElement(DataDictionary.Types.ITypedElement element, StringBuilder text, int indent)
 {
     text.Append(TextualExplainUtilities.Pad(element.Name + " => ", indent));
     DataDictionary.Types.Structure structure = element.Type as DataDictionary.Types.Structure;
     if (structure != null)
     {
         indent = indent + 4;
         text.Append(StripUseless(structure.FullName, EnclosingForm.Selected) + "{\n");
         bool first = true;
         foreach (DataDictionary.Types.StructureElement subElement in structure.Elements)
         {
             if (!first)
             {
                 text.Append(",\n");
             }
             insertElement(subElement, text, indent);
             first = false;
         }
         indent -= 4;
         text.Append("\n" + TextualExplainUtilities.Pad("}", indent));
     }
     else
     {
         text.Append(element.Default);
     }
 }
        /// <summary>
        /// Provides an explanation of the collection
        /// </summary>
        /// <param name="indentLevel">the number of white spaces to add at the beginning of each line</param>
        /// <returns></returns>
        public string getExplain(int indentLevel)
        {
            string retVal = "";

            retVal = TextualExplainUtilities.Pad("{" + Name + " : COLLECTION OF " + getTypeName() + "}", indentLevel);

            return(retVal);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Provides an explanation of the enumeration
        /// </summary>
        /// <param name="indentLevel">the number of white spaces to add at the beginning of each line</param>
        /// <returns></returns>
        public string getExplain(int indentLevel)
        {
            string retVal = "";

            retVal = TextualExplainUtilities.Pad("{" + Name + " : ENUMERATION}", indentLevel);

            foreach (Constants.EnumValue enumValue in Values)
            {
                retVal += "\\par" + TextualExplainUtilities.Pad("{" + enumValue.Name + "}", indentLevel + 2);
            }


            return(retVal);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Provides an explanation of the range
        /// </summary>
        /// <param name="indentLevel">the number of white spaces to add at the beginning of each line</param>
        /// <returns></returns>
        public string getExplain(int indentLevel)
        {
            string retVal = "";

            retVal = TextualExplainUtilities.Pad("{" + Name + " : RANGE FROM " + MinValue + " TO " + MaxValue + "}", indentLevel);

            foreach (Constants.EnumValue enumValue in SpecialValues)
            {
                retVal += "\\par" + TextualExplainUtilities.Pad("{" + enumValue.Name + " : " + enumValue.getValue() + "}", indentLevel + 2);
            }


            return(retVal);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Provides an explanation of the rule's behaviour
        /// </summary>
        /// <param name="indentLevel">the number of white spaces to add at the beginning of each line</param>
        /// <returns></returns>
        public string getExplain(int indentLevel)
        {
            string retVal = "";

            if (PreConditions.Count > 0)
            {
                bool first = true;
                foreach (Rules.PreCondition preCondition in PreConditions)
                {
                    if (first)
                    {
                        retVal = retVal + TextualExplainUtilities.Pad(preCondition.getExplain(true), indentLevel);
                        first  = false;
                    }
                    else
                    {
                        retVal = retVal + " {\\b AND} " + preCondition.getExplain(true);
                    }
                }
                if (!first)
                {
                    retVal = retVal + " {\\b => }\\par";
                }

                if (Expression != null)
                {
                    retVal = retVal + TextualExplainUtilities.Pad((ExpressionText != "" ? Expression.ToString() : "UndefinedExpression") + "\\par", indentLevel + 2);
                }
            }
            else
            {
                retVal = retVal + TextualExplainUtilities.Pad("{\\b => }", indentLevel);
                try
                {
                    if (Expression != null)
                    {
                        retVal = retVal + (ExpressionText != "" ? Expression.ToString() : "UndefinedExpression") + "\\par";
                    }
                }
                catch (Exception)
                {
                }
            }

            return(retVal);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Provides an explanation of the structure
        /// </summary>
        /// <param name="indentLevel">the number of white spaces to add at the beginning of each line</param>
        /// <returns></returns>
        public string getExplain(int indentLevel)
        {
            string retVal = "";

            retVal = TextualExplainUtilities.Pad("{STRUCTURE " + Name + "}", indentLevel);

            foreach (StructureElement element in Elements)
            {
                retVal += "\\par" + TextualExplainUtilities.Pad("{" + element.Name + " : " + element.TypeName + "}", indentLevel + 2);
            }

            foreach (Procedure procedure in Procedures)
            {
                retVal += "\\par" + procedure.getExplain(indentLevel + 2, false);
            }

            return(retVal);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Provides an explanation of the rule's behaviour
        /// </summary>
        /// <param name="indentLevel">the number of white spaces to add at the beginning of each line</param>
        /// <returns></returns>
        public string getExplain(int indentLevel, bool getExplain)
        {
            string retVal = "";

            retVal =
                TextualExplainUtilities.Pad("{\\cf11 // " + TextualExplainUtilities.Iterate('*', 6 + Name.Length) + "}\\cf1\\par", indentLevel)
                + TextualExplainUtilities.Pad("{\\cf11 // State " + Name + "}\\cf1\\par", indentLevel)
                + TextualExplainUtilities.Pad("{\\cf11 // " + TextualExplainUtilities.Iterate('*', 6 + Name.Length) + "}\\cf1\\par", indentLevel);

            if (getExplain)
            {
                foreach (Rules.Rule rule in StateMachine.Rules)
                {
                    retVal += "\\par" + rule.getExplain(indentLevel, true);
                }
            }

            return(retVal);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Provides an explanation of the rule's behaviour
        /// </summary>
        /// <param name="indentLevel">the number of white spaces to add at the beginning of each line</param>
        /// <returns></returns>
        public string getExplain(int indentLevel, bool getExplain)
        {
            string retVal = "";

            retVal =
                TextualExplainUtilities.Pad("{\\cf11 // " + TextualExplainUtilities.Iterate('-', 6 + Name.Length) + "}\\cf1\\par", indentLevel)
                + TextualExplainUtilities.Pad("{PROCEDURE " + Name + "(\\par", indentLevel);

            foreach (Parameter parameter in FormalParameters)
            {
                retVal = retVal + TextualExplainUtilities.Pad(parameter.Name + ":" + parameter.TypeName + ",\\par", indentLevel + 2);
            }
            retVal = retVal + ")}\\par";

            foreach (Rules.Rule rule in Rules)
            {
                retVal += "\\par" + rule.getExplain(indentLevel + 2, true);
            }

            return(retVal);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Provides an explanation of the rule's behaviour
        /// </summary>
        /// <param name="indentLevel">the number of white spaces to add at the beginning of each line</param>
        /// <returns></returns>
        public string getExplain(int indentLevel, bool explainSubRules)
        {
            string retVal = TextualExplainUtilities.Pad("{\\cf11 // " + Name + "}\\cf1\\par", indentLevel);

            bool first     = true;
            bool condition = false;

            foreach (RuleCondition ruleCondition in RuleConditions)
            {
                retVal   += ruleCondition.getExplain(indentLevel, first, explainSubRules);
                first     = false;
                condition = condition || ruleCondition.PreConditions.Count > 0;
            }

            if (condition)
            {
                retVal = retVal + TextualExplainUtilities.Pad("{\\b END IF}\\par", indentLevel);
            }

            return(retVal);
        }