コード例 #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.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();
            }
        }
コード例 #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)
        {
            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");
            }
        }
コード例 #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)
        {
            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);
                    }
                }
            });
        }
コード例 #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.Indent(2, () =>
            {
                foreach (Step step in Steps)
                {
                    step.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });
        }
コード例 #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 virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.Comment(this);
     explanation.Write(Name);
     if (!String.IsNullOrEmpty(getValue()))
     {
         explanation.WriteLine(" : " + getValue());
     }
     else
     {
         explanation.WriteLine();
     }
 }
コード例 #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)
        {
            if (string.IsNullOrEmpty(Comment))
            {
                if (Type != null)
                {
                    explanation.Comment(Type);
                }
            }
            else
            {
                explanation.Comment(this);
            }

            explanation.Write(Name);
            explanation.Write(" : ");
            explanation.Write(TypeName);
            if (Value != null)
            {
                explanation.Write(" = ");
                explanation.Write(Value.LiteralName);
            }
            explanation.WriteLine();
        }
コード例 #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)
        {
            explanation.Comment(this);

            string typeName = TypeName;

            if (Type != null)
            {
                typeName = Type.FullName;
            }

            explanation.Write("FIELD ");
            explanation.Write(Name);
            explanation.Write(" : ");
            explanation.WriteLine(typeName);
        }
コード例 #8
0
ファイル: Procedure.cs プロジェクト: fakoor/ERTMSFormalSpecs
        /// <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 ");
        }
コード例 #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.Comment(this);

            bool first     = true;
            bool condition = false;

            foreach (RuleCondition ruleCondition in RuleConditions)
            {
                if (!first)
                {
                    explanation.WriteLine("ELSE");
                }
                ruleCondition.GetExplain(explanation, explainSubElements);
                first     = false;
                condition = condition || ruleCondition.PreConditions.Count > 0;
            }

            if (condition)
            {
                explanation.WriteLine("END IF");
            }
        }
コード例 #10
0
ファイル: SubStep.cs プロジェクト: fakoor/ERTMSFormalSpecs
        /// <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();
                }
            });
        }
コード例 #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)
        {
            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");
        }
コード例 #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 virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.Comment(this);
     explanation.Expression(this);
 }
コード例 #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 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");
            }
        }
コード例 #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 virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            if (string.IsNullOrEmpty(Comment))
            {
                if (Type != null)
                {
                    explanation.Comment(Type);
                }
            }
            else
            {
                explanation.Comment(this);
            }

            explanation.Write(Name);
            explanation.Write(" : ");
            explanation.Write(TypeName);
            if (Value != null)
            {
                explanation.Write(" = ");
                explanation.Write(Value.LiteralName);
            }
            explanation.WriteLine();
        }
コード例 #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 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);
                    }
                }
            });
        }
コード例 #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 virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            string typeName = TypeName;
            if (Type != null)
            {
                typeName = Type.FullName;
            }

            explanation.Write("FIELD ");
            explanation.Write(Name);
            explanation.Write(" : ");
            explanation.WriteLine(typeName);
        }
コード例 #17
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(Name);
     if (!String.IsNullOrEmpty(getValue()))
     {
         explanation.WriteLine(" : " + getValue());
     }
     else
     {
         explanation.WriteLine();
     }
 }
コード例 #18
0
ファイル: NameSpace.cs プロジェクト: fakoor/ERTMSFormalSpecs
 /// <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("NAMESPACE ");
     explanation.WriteLine(Name);
 }
コード例 #19
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("NAMESPACE ");
     explanation.WriteLine(Name);
 }
コード例 #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 virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.Comment(this);
 }
コード例 #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 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 ");
        }
コード例 #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 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();
            }
        }
コード例 #23
0
ファイル: Rule.cs プロジェクト: JamesOakey/ERTMSFormalSpecs
        /// <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);

            bool first = true;
            bool condition = false;
            foreach (RuleCondition ruleCondition in RuleConditions)
            {
                if (!first)
                {
                    explanation.WriteLine("ELSE");
                }
                ruleCondition.GetExplain(explanation, explainSubElements);
                first = false;
                condition = condition || ruleCondition.PreConditions.Count > 0;
            }

            if (condition)
            {
                explanation.WriteLine("END IF");
            }
        }
コード例 #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 virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            explanation.Indent(2, () =>
            {
                foreach (Step step in Steps)
                {
                    step.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });
        }
コード例 #25
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();
                }
            });
        }