Esempio n. 1
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Write("FOLDER ");
            explanation.WriteLine(Name);

            if (explainSubElements)
            {
                explanation.Indent(2, () =>
                {
                    foreach (Folder folder in Folders)
                    {
                        folder.GetExplain(explanation, explainSubElements);
                    }
                });
            }

            explanation.Indent(2, () =>
            {
                foreach (Translation translation in Translations)
                {
                    translation.GetExplain(explanation, explainSubElements);
                }
            });
            explanation.Write("END FOLDER ");
            explanation.WriteLine(Name);
        }
Esempio n. 2
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
        {
            explanation.Write(Called);
            explanation.Write("(");
            explanation.ExplainList(ActualParameters, explainSubElements, ", ",
                                    element => element.GetExplain(explanation));

            if (NamedActualParameters.Count > 0)
            {
                explanation.Indent(2, () =>
                {
                    if (ActualParameters.Count > 0)
                    {
                        explanation.Write(", ");
                    }
                    explanation.ExplainList(NamedActualParameters, explainSubElements, ", ", pair =>
                    {
                        if (AllParameters.Count > 1)
                        {
                            explanation.WriteLine();
                        }
                        explanation.Write(pair.Key);
                        explanation.Write(" => ");
                        explanation.Write(pair.Value);
                    });
                });
            }
            explanation.Write(")");
        }
Esempio n. 3
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            if (!string.IsNullOrEmpty(getCondition()))
            {
                explanation.Write("IF ");
                if (ConditionTree != null)
                {
                    ConditionTree.GetExplain(explanation);
                }
                else
                {
                    explanation.Write(getCondition());
                }
                explanation.WriteLine(" THEN");
                explanation.Indent(2, () => explanation.Expression(this));
                explanation.WriteLine("END IF");
            }
            else
            {
                explanation.Expression(this);
                explanation.WriteLine();
            }
        }
Esempio n. 4
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);
            explanation.Write("PROCEDURE ");
            explanation.Write(Name);

            if (FormalParameters.Count > 0)
            {
                bool first = true;
                explanation.Write("(");
                if (FormalParameters.Count > 1)
                {
                    explanation.WriteLine();
                }

                explanation.Indent(4, () =>
                {
                    foreach (Parameter parameter in FormalParameters)
                    {
                        if (!first)
                        {
                            explanation.WriteLine(",");
                        }
                        explanation.Write(parameter.Name);
                        explanation.Write(" : ");
                        explanation.Write(parameter.TypeName);
                        first = false;
                    }
                });
                explanation.WriteLine(")");
            }
            else
            {
                explanation.WriteLine("()");
            }

            explanation.Indent(2, () =>
            {
                foreach (Rule rule in Rules)
                {
                    rule.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });

            explanation.WriteLine("END PROCEDURE ");
        }
Esempio n. 5
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            if (!IsAbstract)
            {
                explanation.Write("STRUCTURE ");
            }
            else
            {
                explanation.Write("INTERFACE ");
            }
            explanation.WriteLine(Name);

            explanation.Indent(2, () =>
            {
                foreach (Structure structure in Interfaces)
                {
                    if (structure != null)
                    {
                        explanation.Write("IMPLEMENTS ");
                        explanation.WriteLine(structure.Name);
                    }
                }

                foreach (StructureElement element in Elements)
                {
                    explanation.Write(element, explainSubElements);
                }

                if (!IsAbstract)
                {
                    foreach (Procedure procedure in Procedures)
                    {
                        explanation.Write(procedure, explainSubElements);
                    }

                    foreach (StateMachine stateMachine in StateMachines)
                    {
                        explanation.Write(stateMachine, explainSubElements);
                    }

                    foreach (Rule rule in Rules)
                    {
                        explanation.Write(rule, explainSubElements);
                    }
                }
            });

            if (!IsAbstract)
            {
                explanation.WriteLine("END STRUCTURE");
            }
            else
            {
                explanation.WriteLine("END INTERFACE");
            }
        }
Esempio n. 6
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            int indent = 0;

            if (PreConditions.Count > 0)
            {
                indent = 2;
                explanation.Write("IF ");
                if (PreConditions.Count > 1)
                {
                    // Prepare the space for the following ANDs
                    explanation.Write("   ");
                }

                bool first = true;
                foreach (PreCondition preCondition in PreConditions)
                {
                    if (!first)
                    {
                        explanation.WriteLine();
                        explanation.Write("   AND ");
                    }
                    preCondition.GetExplain(explanation, explainSubElements);
                    first = false;
                }
                explanation.WriteLine();
                explanation.WriteLine("THEN");
            }
            else
            {
                explanation.WriteLine();
            }

            explanation.Indent(indent, () =>
            {
                if (Name.CompareTo(EnclosingRule.Name) != 0)
                {
                    explanation.Comment(Name);
                }

                foreach (Action action in Actions)
                {
                    explanation.Write();
                    action.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }

                if (explainSubElements)
                {
                    foreach (Rule subRule in SubRules)
                    {
                        subRule.GetExplain(explanation, explainSubElements);
                    }
                }
            });
        }
Esempio n. 7
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            if (PreConditions.Count > 0)
            {
                explanation.Write("IF ");
                if (PreConditions.Count > 1)
                {
                    // Prepare the space for the following ANDs
                    explanation.Write("   ");
                }

                bool first = true;
                foreach (PreCondition preCondition in PreConditions)
                {
                    if (!first)
                    {
                        explanation.WriteLine();
                        explanation.Write("   AND ");
                    }

                    preCondition.GetExplain(explanation, explainSubElements);
                    first = false;
                }
                explanation.WriteLine(" THEN");

                explanation.Indent(2, () =>
                {
                    explanation.Header(this);
                    explanation.Expression(this);
                });
            }
            else
            {
                explanation.WriteLine();
                explanation.Indent(2, () =>
                {
                    explanation.Header(this);
                    explanation.Expression(this);
                });
            }
        }
Esempio n. 8
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            explanation.Indent(2, () =>
            {
                foreach (Step step in Steps)
                {
                    step.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });
        }
Esempio n. 9
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.WriteLine("SOURCE TEXT ");
     explanation.WriteLine(Name);
     explanation.Indent(2, () =>
     {
         foreach (SourceTextComment comment in Comments)
         {
             explanation.Write("COMMENT");
             explanation.WriteLine(comment.Name);
         }
     });
 }
Esempio n. 10
0
        protected void InsertElement(ITypedElement element, TextualExplanation text)
        {
            text.Write(element.Name);
            text.Write(" => ");
            Structure structure = element.Type as Structure;

            if (structure != null)
            {
                text.WriteLine(StripUseless(structure.FullName, WritingContext()) + "{");
                text.Indent(4, () =>
                {
                    bool first = true;
                    foreach (StructureElement subElement in structure.Elements)
                    {
                        if (!first)
                        {
                            text.WriteLine(",");
                        }
                        InsertElement(subElement, text);
                        first = false;
                    }
                });
                text.WriteLine();
                text.Write("}");
            }
            else
            {
                IValue value = null;
                if (string.IsNullOrEmpty(element.Default))
                {
                    // No default value for element, get the one of the type
                    if (element.Type != null && element.Type.DefaultValue != null)
                    {
                        value = element.Type.DefaultValue;
                    }
                }
                else
                {
                    if (element.Type != null)
                    {
                        value = element.Type.getValue(element.Default);
                    }
                }

                if (value != null)
                {
                    text.Write(StripUseless(value.FullName, WritingContext()));
                }
            }
        }
Esempio n. 11
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     if (ListElements.Count > 0)
     {
         explanation.Write("[");
         explanation.Indent(2,
                            () => explanation.ExplainList(ListElements, explainSubElements, ", ",
                                                          element => element.GetExplain(explanation, explainSubElements)));
         explanation.Write("]");
     }
     else
     {
         explanation.Write("[]");
     }
 }
Esempio n. 12
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            base.GetExplain(explanation, explainSubElements);

            explanation.Write("ENUMERATION ");
            explanation.WriteLine(Name);

            explanation.Indent(2, () =>
            {
                foreach (EnumValue enumValue in Values)
                {
                    explanation.Write(enumValue, explainSubElements);
                }
            });
        }
Esempio n. 13
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(Name);

            explanation.Indent(2, () =>
            {
                foreach (Action action in Actions)
                {
                    action.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });

            explanation.WriteLine("IMPLIES");

            explanation.Indent(2, () =>
            {
                foreach (Expectation expectation in Expectations)
                {
                    expectation.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });
        }
Esempio n. 14
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.Write(Structure);
     explanation.WriteLine();
     explanation.Write("{");
     explanation.Indent(2, () => explanation.ExplainList(Associations, explainSubElements, ", ", element =>
     {
         explanation.WriteLine();
         explanation.Write(element.Key);
         explanation.Write(" => ");
         explanation.Write(element.Value);
     }));
     explanation.WriteLine();
     explanation.Write("}");
 }
Esempio n. 15
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            base.GetExplain(explanation, explainSubElements);

            explanation.Write("STATE MACHINE ");
            explanation.WriteLine(Name);
            explanation.Indent(2, () =>
            {
                foreach (State state in States)
                {
                    explanation.Write(state, false);
                }
                foreach (Rule rule in Rules)
                {
                    explanation.Write(rule, explainSubElements);
                }
            });
        }
Esempio n. 16
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            base.GetExplain(explanation, explainSubElements);

            explanation.Write("RANGE ");
            explanation.Write(Name);
            explanation.Write(" FROM ");
            explanation.Write(MinValue);
            explanation.Write(" TO ");
            explanation.WriteLine(MaxValue);

            explanation.Indent(2, () =>
            {
                foreach (EnumValue enumValue in SpecialValues)
                {
                    explanation.Write(enumValue, explainSubElements);
                }
            });
        }
Esempio n. 17
0
 protected void CreateCallableParameters(TextualExplanation text, ICallable callable)
 {
     if (callable.FormalParameters.Count > 0)
     {
         if (callable.FormalParameters.Count == 1)
         {
             Parameter formalParameter = callable.FormalParameters[0] as Parameter;
             if (formalParameter != null)
             {
                 text.Write("( " + formalParameter.Name + " => " + formalParameter.Type.Default + " )");
             }
         }
         else
         {
             text.WriteLine("(");
             text.Indent(4, () =>
             {
                 bool first = true;
                 foreach (Parameter parameter in callable.FormalParameters)
                 {
                     if (!first)
                     {
                         text.WriteLine(",");
                     }
                     text.Write(parameter.Name + " => " + parameter.Type.Default);
                     first = false;
                 }
             });
             text.WriteLine();
             text.Write(")");
         }
     }
     else
     {
         text.Write("()");
     }
 }
Esempio n. 18
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Write("FOLDER ");
            explanation.WriteLine(Name);

            if (explainSubElements)
            {
                explanation.Indent(2, () =>
                {
                    foreach (Folder folder in Folders)
                    {
                        folder.GetExplain(explanation, explainSubElements);
                    }
                });
            }

            explanation.Indent(2, () =>
            {
                foreach (Translation translation in Translations)
                {
                    translation.GetExplain(explanation, explainSubElements);
                }
            });
            explanation.Write("END FOLDER ");
            explanation.WriteLine(Name);
        }
        protected void InsertElement(ITypedElement element, TextualExplanation text)
        {
            text.Write(element.Name);
            text.Write(" => ");
            Structure structure = element.Type as Structure;
            if (structure != null)
            {
                text.WriteLine(StripUseless(structure.FullName, WritingContext()) + "{");
                text.Indent(4, () =>
                {
                    bool first = true;
                    foreach (StructureElement subElement in structure.Elements)
                    {
                        if (!first)
                        {
                            text.WriteLine(",");
                        }
                        InsertElement(subElement, text);
                        first = false;
                    }
                });
                text.WriteLine();
                text.Write("}");
            }
            else
            {
                IValue value = null;
                if (string.IsNullOrEmpty(element.Default))
                {
                    // No default value for element, get the one of the type
                    if (element.Type != null && element.Type.DefaultValue != null)
                    {
                        value = element.Type.DefaultValue;
                    }
                }
                else
                {
                    if (element.Type != null)
                    {
                        value = element.Type.getValue(element.Default);
                    }
                }

                if (value != null)
                {
                    text.Write(StripUseless(value.FullName, WritingContext()));
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            base.GetExplain(explanation, explainSubElements);
            explanation.Write("RANGE ");
            explanation.Write(Name);
            explanation.Write(" FROM ");
            explanation.Write(MinValue);
            explanation.Write(" TO ");
            explanation.WriteLine(MaxValue);

            explanation.Indent(2, () =>
            {
                foreach (EnumValue enumValue in SpecialValues)
                {
                    enumValue.GetExplain(explanation, explainSubElements);
                }
            });
        }
Esempio n. 21
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);
            explanation.Write("FUNCTION ");
            explanation.Write(Name);
            explanation.Write(" (");
            if (FormalParameters.Count > 0)
            {
                explanation.Indent(2, () =>
                {
                    bool first = true;
                    foreach (Parameter parameter in FormalParameters)
                    {
                        if (first)
                        {
                            explanation.WriteLine();
                            first = false;
                        }
                        else
                        {
                            explanation.WriteLine(",");
                        }
                        parameter.GetExplain(explanation, true);
                    }
                });
            }
            explanation.WriteLine(")");
            explanation.Write("RETURNS ");
            explanation.WriteLine(TypeName);

            {
                bool first = true;
                foreach (Case cas in Cases)
                {
                    if (!first)
                    {
                        explanation.Write("ELSE ");
                    }
                    cas.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                    first = false;
                }
            }
            explanation.Write("END FUNCTION");
        }
Esempio n. 22
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            if (!IsAbstract)
            {
                explanation.Write("STRUCTURE ");
            }
            else
            {
                explanation.Write("INTERFACE ");
            }
            explanation.WriteLine(Name);

            explanation.Indent(2, () =>
            {
                foreach (Structure structure in Interfaces)
                {
                    if (structure != null)
                    {
                        explanation.Write("IMPLEMENTS ");
                        explanation.WriteLine(structure.Name);
                    }
                }

                foreach (StructureElement element in Elements)
                {
                    element.GetExplain(explanation, explainSubElements);
                }

                if (!IsAbstract)
                {
                    foreach (Procedure procedure in Procedures)
                    {
                        procedure.GetExplain(explanation, explainSubElements);
                    }

                    foreach (StateMachine stateMachine in StateMachines)
                    {
                        stateMachine.GetExplain(explanation, explainSubElements);
                    }

                    foreach (Rule rule in Rules)
                    {
                        rule.GetExplain(explanation, explainSubElements);
                    }
                }
            });

            if (!IsAbstract)
            {
                explanation.WriteLine("END STRUCTURE");
            }
            else
            {
                explanation.WriteLine("END INTERFACE");
            }
        }
Esempio n. 23
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            base.GetExplain(explanation, explainSubElements);

            explanation.Write("ENUMERATION ");
            explanation.WriteLine(Name);

            explanation.Indent(2, () =>
            {
                foreach (EnumValue enumValue in Values)
                {
                    explanation.Write(enumValue, explainSubElements);
                }
            });
        }
Esempio n. 24
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
        {
            Called.GetExplain(explanation);
            explanation.Write("(");
            explanation.ExplainList(ActualParameters, explainSubElements, ", ",
                element => element.GetExplain(explanation));

            if (NamedActualParameters.Count > 0)
            {
                explanation.Indent(2, () =>
                {
                    if (ActualParameters.Count > 0)
                    {
                        explanation.Write(", ");
                    }
                    explanation.ExplainList(NamedActualParameters, explainSubElements, ", ", pair =>
                    {
                        if (AllParameters.Count > 1)
                        {
                            explanation.WriteLine();
                        }
                        pair.Key.GetExplain(explanation);
                        explanation.Write(" => ");
                        pair.Value.GetExplain(explanation);
                    });
                });
            }
            explanation.Write(")");
        }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     base.GetExplain(explanation, explainSubElements);
     explanation.Write("STATE MACHINE ");
     explanation.WriteLine(Name);
     explanation.Indent(2, () =>
     {
         foreach (State state in States)
         {
             state.GetExplain(explanation, false);
         }
         foreach (Rule rule in Rules)
         {
             rule.GetExplain(explanation, explainSubElements);
         }
     });
 }
Esempio n. 26
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            if (!string.IsNullOrEmpty(getCondition()))
            {
                explanation.Write("IF ");
                if (ConditionTree != null)
                {
                    ConditionTree.GetExplain(explanation);
                }
                else
                {
                    explanation.Write(getCondition());
                }
                explanation.WriteLine(" THEN");
                explanation.Indent(2, () => explanation.Expression(this));
                explanation.WriteLine("END IF");

            }
            else
            {
                explanation.Expression(this);
                explanation.WriteLine();
            }
        }
Esempio n. 27
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(Name);

            explanation.Indent(2, () =>
            {
                foreach (Action action in Actions)
                {
                    action.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });

            explanation.WriteLine("IMPLIES");

            explanation.Indent(2, () =>
            {
                foreach (Expectation expectation in Expectations)
                {
                    expectation.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });
        }
Esempio n. 28
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.WriteLine("SOURCE TEXT ");
     explanation.WriteLine(Name);
     explanation.Indent(2, () =>
     {
         foreach (SourceTextComment comment in this.Comments)
         {
             explanation.Write("COMMENT");
             explanation.WriteLine(comment.Name);
         }
     });
 }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     if (ListElements.Count > 0)
     {
         explanation.Write("[");
         explanation.Indent(2,
             () => explanation.ExplainList(ListElements, explainSubElements, ", ",
                 element => element.GetExplain(explanation, explainSubElements)));
         explanation.Write("]");
     }
     else
     {
         explanation.Write("[]");
     }
 }
Esempio n. 30
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            if (PreConditions.Count > 0)
            {
                explanation.Write("IF ");
                if (PreConditions.Count > 1)
                {
                    // Prepare the space for the following ANDs
                    explanation.Write("   ");
                }

                bool first = true;
                foreach (PreCondition preCondition in PreConditions)
                {
                    if (!first)
                    {
                        explanation.WriteLine();
                        explanation.Write("   AND ");
                    }

                    preCondition.GetExplain(explanation, explainSubElements);
                    first = false;
                }
                explanation.WriteLine(" THEN");

                explanation.Indent(2, () =>
                {
                    explanation.Header(this);
                    explanation.Expression(this);
                });
            }
            else
            {
                explanation.WriteLine();
                explanation.Indent(2, () =>
                {
                    explanation.Header(this);
                    explanation.Expression(this);
                });
            }
        }
 protected void CreateCallableParameters(TextualExplanation text, ICallable callable)
 {
     if (callable.FormalParameters.Count > 0)
     {
         if (callable.FormalParameters.Count == 1)
         {
             Parameter formalParameter = callable.FormalParameters[0] as Parameter;
             if(formalParameter != null)
             {
                 text.Write("( " + formalParameter.Name + " => " + formalParameter.Type.Default + " )");
             }
         }
         else
         {
             text.WriteLine("(");
             text.Indent(4, () =>
             {
                 bool first = true;
                 foreach (Parameter parameter in callable.FormalParameters)
                 {
                     if (!first)
                     {
                         text.WriteLine(",");
                     }
                     text.Write(parameter.Name + " => " + parameter.Type.Default);
                     first = false;
                 }
             });
             text.WriteLine();
             text.Write(")");
         }
     }
     else
     {
         text.Write("()");
     }
 }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     Structure.GetExplain(explanation);
     explanation.Write("{");
     explanation.Indent(2, () => explanation.ExplainList(Associations, explainSubElements, ", ", element =>
     {
         explanation.WriteLine();
         element.Key.GetExplain(explanation);
         explanation.Write(" => ");
         element.Value.GetExplain(explanation);
     }));
     explanation.WriteLine();
     explanation.Write("}");
 }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            int indent = 0;

            if (PreConditions.Count > 0)
            {
                indent = 2;
                explanation.Write("IF ");
                if (PreConditions.Count > 1)
                {
                    // Prepare the space for the following ANDs
                    explanation.Write("   ");
                }

                bool first = true;
                foreach (PreCondition preCondition in PreConditions)
                {
                    if (!first)
                    {
                        explanation.WriteLine();
                        explanation.Write("   AND ");
                    }
                    preCondition.GetExplain(explanation, explainSubElements);
                    first = false;
                }
                explanation.WriteLine();
                explanation.WriteLine("THEN");
            }
            else
            {
                explanation.WriteLine();
            }

            explanation.Indent(indent, () =>
            {
                if (Name.CompareTo(EnclosingRule.Name) != 0)
                {
                    explanation.Comment(Name);
                }

                foreach (Action action in Actions)
                {
                    explanation.Write();
                    action.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }

                if (explainSubElements)
                {
                    foreach (Rule subRule in SubRules)
                    {
                        subRule.GetExplain(explanation, explainSubElements);
                    }
                }
            });
        }
Esempio n. 34
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            explanation.Indent(2, () =>
            {
                foreach (Step step in Steps)
                {
                    step.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });
        }
Esempio n. 35
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);
            explanation.Write("PROCEDURE ");
            explanation.Write(Name);

            if (FormalParameters.Count > 0)
            {
                bool first = true;
                explanation.Write("(");
                if (FormalParameters.Count > 1)
                {
                    explanation.WriteLine();
                }

                explanation.Indent(4, () =>
                {
                    foreach (Parameter parameter in FormalParameters)
                    {
                        if (!first)
                        {
                            explanation.WriteLine(",");
                        }
                        explanation.Write(parameter.Name);
                        explanation.Write(" : ");
                        explanation.Write(parameter.TypeName);
                        first = false;
                    }
                });
                explanation.WriteLine(")");
            }
            else
            {
                explanation.WriteLine("()");
            }

            explanation.Indent(2, () =>
            {
                foreach (Rule rule in Rules)
                {
                    rule.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });

            explanation.WriteLine("END PROCEDURE ");
        }