/// <summary>
        /// Checks an expression associated to a model element
        /// </summary>
        /// <param name="model">The model element on which the expression is defined</param>
        /// <param name="expression">The expression to check</param>
        /// <returns>the expression parse tree</returns>
        private Interpreter.Expression checkExpression(ModelElement model, string expression)
        {
            Interpreter.Expression retVal = null;

            Interpreter.Parser parser = model.EFSSystem.Parser;
            try
            {
                retVal = parser.Expression(model, expression);

                if (retVal != null)
                {
                    retVal.checkExpression();
                    Types.Type type = retVal.GetExpressionType();
                    if (type == null)
                    {
                        model.AddError("Cannot determine expression type (5) for " + retVal.ToString());
                    }
                }
                else
                {
                    model.AddError("Cannot parse expression");
                }
            }
            catch (Exception exception)
            {
                model.AddException(exception);
            }
            return(retVal);
        }
Esempio n. 2
0
 /// <summary>
 /// Parses the statement provided
 /// </summary>
 /// <param name="root">the root element for which this statement is created</param>
 /// <param name="expression"></param>
 /// <returns></returns>
 public Interpreter.Statement.Statement ParseStatement(ModelElement root, string expression)
 {
     try
     {
         return(Parser.Statement(root, expression));
     }
     catch (Interpreter.ParseErrorException exception)
     {
         root.AddException(exception);
         return(null);
     }
 }
        /// <summary>
        /// Checks a statement associated to a model element
        /// </summary>
        /// <param name="model">The model element on which the expression is defined</param>
        /// <param name="expression">The expression to check</param>
        /// <returns>the expression parse tree</returns>
        private Interpreter.Statement.Statement checkStatement(ModelElement model, string expression)
        {
            Interpreter.Statement.Statement retVal = null;

            Interpreter.Parser parser = model.EFSSystem.Parser;
            try
            {
                retVal = parser.Statement(model, expression);
                retVal.CheckStatement();
            }
            catch (Exception exception)
            {
                model.AddException(exception);
            }
            return(retVal);
        }
        /// <summary>
        /// Checks a statement associated to a model element
        /// </summary>
        /// <param name="model">The model element on which the expression is defined</param>
        /// <param name="expression">The expression to check</param>
        /// <returns>the expression parse tree</returns>
        private Interpreter.Statement.Statement checkStatement(ModelElement model, string expression)
        {
            Interpreter.Statement.Statement retVal = null;

            Interpreter.Parser parser = model.EFSSystem.Parser;
            try
            {
                retVal = parser.Statement(model, expression);
                retVal.CheckStatement();
            }
            catch (Exception exception)
            {
                model.AddException(exception);
            }
            return retVal;
        }
        /// <summary>
        /// Checks an expression associated to a model element
        /// </summary>
        /// <param name="model">The model element on which the expression is defined</param>
        /// <param name="expression">The expression to check</param>
        /// <returns>the expression parse tree</returns>
        private Interpreter.Expression checkExpression(ModelElement model, string expression)
        {
            Interpreter.Expression retVal = null;

            Interpreter.Parser parser = model.EFSSystem.Parser;
            try
            {
                retVal = parser.Expression(model, expression);

                if (retVal != null)
                {
                    retVal.checkExpression();
                    Types.Type type = retVal.GetExpressionType();
                    if (type == null)
                    {
                        model.AddError("Cannot determine expression type (5) for " + retVal.ToString());
                    }
                }
                else
                {
                    model.AddError("Cannot parse expression");
                }
            }
            catch (Exception exception)
            {
                model.AddException(exception);
            }
            return retVal;
        }
        /// <summary>
        ///     Checks a statement associated to a model element
        /// </summary>
        /// <param name="model">The model element on which the expression is defined</param>
        /// <param name="expression">The expression to check</param>
        /// <returns>the expression parse tree</returns>
        private Statement checkStatement(ModelElement model, string expression)
        {
            Statement retVal = null;

            // Only check statements for model elements which are not updated
            if (!ParentHasBeenUpdated(model))
            {
                Parser parser = model.EFSSystem.Parser;
                try
                {
                    retVal = parser.Statement(model, expression);
                    if (retVal != null)
                    {
                        retVal.CheckStatement();
                    }
                    else
                    {
                        model.AddError("Cannot parse statement");
                    }
                }
                catch (Exception exception)
                {
                    model.AddException(exception);
                }
            }

            return retVal;
        }
        /// <summary>
        ///     Checks an expression associated to a model element
        /// </summary>
        /// <param name="model">The model element on which the expression is defined</param>
        /// <param name="expression">The expression to check</param>
        /// <returns>the expression parse tree</returns>
        private Expression checkExpression(ModelElement model, string expression)
        {
            Expression retVal = null;

            // Only check expressions for which the model is not updated
            if (!ParentHasBeenUpdated(model))
            {
                Parser parser = model.EFSSystem.Parser;
                try
                {
                    retVal = parser.Expression(model, expression);

                    if (retVal != null)
                    {
                        retVal.CheckExpression();
                        Type type = retVal.GetExpressionType();
                        if (type == null)
                        {
                            model.AddError("Cannot determine expression type (5) for " + retVal.ToString());
                        }
                    }
                    else
                    {
                        model.AddError("Cannot parse expression");
                    }
                }
                catch (Exception exception)
                {
                    model.AddException(exception);
                }
            }

            return retVal;
        }
        /// <summary>
        ///     Checks an expression associated to a model element
        /// </summary>
        /// <param name="model">The model element on which the expression is defined</param>
        /// <param name="expression">The expression to check</param>
        /// <returns>the expression parse tree</returns>
        public Expression CheckExpression(ModelElement model, string expression)
        {
            Expression retVal = null;

            // Only check expressions for which the model is not updated
            if (!ParentHasBeenUpdated(model))
            {
                Parser parser = new Parser();
                try
                {
                    retVal = parser.Expression(model, expression);

                    if (retVal != null)
                    {
                        retVal.CheckExpression();
                        Type type = retVal.GetExpressionType();
                        if (type == null)
                        {
                            model.AddError("Cannot determine expression type (5) for " + retVal);
                        }
                        DerefExpression derefExpression = retVal as DerefExpression;
                        if (derefExpression != null && !derefExpression.IsValidExpressionComponent())
                        {
                            model.AddError("Invalid expression");
                        }
                    }
                    else
                    {
                        model.AddError("Cannot parse expression");
                    }
                }
                catch (Exception exception)
                {
                    model.AddException(exception);
                }
            }

            return retVal;
        }