SemanticAnalysis() публичный Метод

Performs the semantic analysis of the expression
public SemanticAnalysis ( BaseFilter expectation ) : bool
expectation BaseFilter
Результат bool
Пример #1
0
        /// <summary>
        /// Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                Expression.SemanticAnalysis(instance, Filter.AllMatches);
            }

            return(retVal);
        }
Пример #2
0
 /// <summary>
 /// Performs the semantic analysis of the term
 /// </summary>
 /// <param name="instance">the reference instance on which this element should analysed</param>
 /// <param name="expectation">Indicates the kind of element we are looking for</paraparam>
 /// <param name="lastElement">Indicates that this element is the last one in a dereference chain</param>
 /// <returns>True if semantic analysis should be continued</returns>
 public void SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation, bool lastElement)
 {
     if (Designator != null)
     {
         Designator.SemanticAnalysis(instance, expectation, lastElement);
     }
     else if (LiteralValue != null)
     {
         LiteralValue.SemanticAnalysis(instance, expectation);
     }
 }
Пример #3
0
 /// <summary>
 ///     Performs the semantic analysis of the term
 /// </summary>
 /// <param name="instance">the reference instance on which this element should analysed</param>
 /// <param name="expectation">Indicates the kind of element we are looking for</param>
 /// <param name="lastElement">Indicates that this element is the last one in a dereference chain</param>
 /// <returns>True if semantic analysis should be continued</returns>
 public void SemanticAnalysis(INamable instance, BaseFilter expectation, bool lastElement)
 {
     if (Designator != null)
     {
         Designator.SemanticAnalysis(instance, expectation, lastElement);
         StaticUsage = Designator.StaticUsage;
     }
     else if (LiteralValue != null)
     {
         LiteralValue.SemanticAnalysis(instance, expectation);
         StaticUsage = LiteralValue.StaticUsage;
     }
 }
        /// <summary>
        /// Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <paraparam name="expectation">Indicates the kind of element we are looking for</paraparam>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                InitialValue.SemanticAnalysis(instance, Filter.IsRightSide);
                Expression.SemanticAnalysis(instance, Filter.AllMatches);
                Condition.SemanticAnalysis(instance, Filter.AllMatches);

                LastIteration.Type    = InitialValue.GetExpressionType();
                CurrentIteration.Type = InitialValue.GetExpressionType();
            }

            return(retVal);
        }
        /// <summary>
        ///     Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <param name="expectation">Indicates the kind of element we are looking for</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(INamable instance, BaseFilter expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                // InitialValue
                if (InitialValue != null)
                {
                    InitialValue.SemanticAnalysis(instance, IsRightSide.INSTANCE);
                    StaticUsage.AddUsages(InitialValue.StaticUsage, Usage.ModeEnum.Read);

                    LastIteration.Type    = InitialValue.GetExpressionType();
                    CurrentIteration.Type = InitialValue.GetExpressionType();
                    StaticUsage.AddUsage(InitialValue.GetExpressionType(), Root, Usage.ModeEnum.Type);
                }
                else
                {
                    AddError("Initial value not provided", RuleChecksEnum.SemanticAnalysisError);
                }

                // Expression
                if (Expression != null)
                {
                    Expression.SemanticAnalysis(instance, AllMatches.INSTANCE);
                    StaticUsage.AddUsages(Expression.StaticUsage, Usage.ModeEnum.Read);
                }
                else
                {
                    Root.AddError("Accumulator expression value not provided");
                }

                // Condition
                if (Condition != null)
                {
                    Condition.SemanticAnalysis(instance, AllMatches.INSTANCE);
                    StaticUsage.AddUsages(Condition.StaticUsage, Usage.ModeEnum.Read);
                }
                else
                {
                    Root.AddError("Stop condition not provided");
                }
            }

            return(retVal);
        }
Пример #6
0
        /// <summary>
        /// Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <param name="expectation">Indicates the kind of element we are looking for</paraparam>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                if (Term != null)
                {
                    Term.SemanticAnalysis(instance, expectation, true);
                }
                else if (Expression != null)
                {
                    Expression.SemanticAnalysis(instance, expectation);
                }
            }

            return(retVal);
        }
Пример #7
0
        /// <summary>
        ///     Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <param name="expectation">Indicates the kind of element we are looking for</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(INamable instance, BaseFilter expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                // Binding expression
                if (BindingExpression != null)
                {
                    BindingExpression.SemanticAnalysis(instance, IsRightSide.INSTANCE);
                    StaticUsage.AddUsages(BindingExpression.StaticUsage, Usage.ModeEnum.Read);

                    Type bindingExpressionType = BindingExpression.GetExpressionType();
                    if (bindingExpressionType != null)
                    {
                        StaticUsage.AddUsage(bindingExpressionType, Root, Usage.ModeEnum.Type);
                        BoundVariable.Type = bindingExpressionType;
                    }
                    else
                    {
                        AddError("Cannot determine binding expression type for " + ToString(), RuleChecksEnum.SemanticAnalysisError);
                    }
                }
                else
                {
                    AddError("Binding expression not provided", RuleChecksEnum.SemanticAnalysisError);
                }


                // The evaluated expression
                if (Expression != null)
                {
                    Expression.SemanticAnalysis(instance, expectation);
                    StaticUsage.AddUsages(Expression.StaticUsage, Usage.ModeEnum.Read);
                }
                else
                {
                    AddError("Value expression not provided", RuleChecksEnum.SemanticAnalysisError);
                }
            }

            return(retVal);
        }
Пример #8
0
        /// <summary>
        ///     Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <param name="expectation">Indicates the kind of element we are looking for</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(INamable instance, BaseFilter expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                if (Expression != null)
                {
                    Expression.SemanticAnalysis(instance, AllMatches.INSTANCE);
                    StaticUsage.AddUsages(Expression.StaticUsage, null);
                }
                else
                {
                    AddError("Function body not provided", RuleChecksEnum.SemanticAnalysisError);
                }
            }

            return(retVal);
        }
Пример #9
0
        /// <summary>
        ///     Performs the semantic analysis of the expression
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <param name="expectation">Indicates the kind of element we are looking for</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(INamable instance, BaseFilter expectation)
        {
            bool retVal = base.SemanticAnalysis(instance, expectation);

            if (retVal)
            {
                if (Term != null)
                {
                    Term.SemanticAnalysis(instance, expectation, true);
                    StaticUsage = Term.StaticUsage;
                }
                else if (Expression != null)
                {
                    Expression.SemanticAnalysis(instance, expectation);
                    StaticUsage = Expression.StaticUsage;
                }
            }

            return(retVal);
        }
Пример #10
0
        /// <summary>
        /// Provides the parse tree according to the expression provided
        /// </summary>
        /// <param name="root">the element for which this expression should be parsed</param>
        /// <param name="expression"></param>
        /// <returns></returns>
        public Expression Expression(ModelElement root, string expression)
        {
            Expression retVal = null;

            try
            {
                Generated.ControllersManager.NamableController.DesactivateNotification();
                Root   = root;
                Buffer = expression.ToCharArray();
                retVal = Expression(0);

                skipWhiteSpaces();
                if (Index != Buffer.Length)
                {
                    retVal = null;
                    if (Index < Buffer.Length)
                    {
                        Root.AddError("End of expression expected, but found " + Buffer[Index]);
                    }
                    else
                    {
                        Root.AddError("End of expression expected, but found EOF");
                    }
                }
                if (retVal != null)
                {
                    retVal.SemanticAnalysis(Filter.IsVariableOrValue);
                }
            }
            finally
            {
                Generated.ControllersManager.NamableController.ActivateNotification();
            }

            return(retVal);
        }