/// <summary>
        /// Performs the semantic analysis of the statement
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(Utils.INamable instance)
        {
            bool retVal = base.SemanticAnalysis(instance);

            if (retVal)
            {
                ListExpression.SemanticAnalysis(instance);
                Types.Collection collectionType = ListExpression.GetExpressionType() as Types.Collection;
                if (collectionType != null)
                {
                    IteratorVariable.Type = collectionType.Type;
                }

                Value.SemanticAnalysis(instance);
                Types.Type valueType = Value.GetExpressionType();
                if (valueType != null)
                {
                    if (!valueType.Match(collectionType.Type))
                    {
                        AddError("Type of " + Value + " does not match collection type " + collectionType);
                    }
                }
                else
                {
                    AddError("Cannot determine type of " + Value);
                }

                if (Condition != null)
                {
                    Condition.SemanticAnalysis(instance);
                }
            }

            return(retVal);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Provides the predefined item, based on its name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public Utils.INamable getPredefinedItem(string name)
        {
            Utils.INamable namable = null;

            PredefinedItems.TryGetValue(name, out namable);

            return(namable);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Performs the semantic analysis of the statement
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <returns>true if semantical analysis should be performed</returns>
        public virtual bool SemanticAnalysis(Utils.INamable instance = null)
        {
            bool retVal = !SemanticalAnalysisDone;

            SemanticalAnalysisDone = true;

            return(retVal);
        }
        /// <summary>
        /// Provides the possible references types for this expression (used in semantic analysis)
        /// </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>
        /// <param name="last">indicates that this is the last element in a dereference chain</param>
        /// <returns></returns>
        public virtual ReturnValue getReferenceTypes(Utils.INamable instance, Filter.AcceptableChoice expectation, bool last)
        {
            ReturnValue retVal = new ReturnValue(this);

            SemanticAnalysis(instance, Filter.AllMatches);
            retVal.Add(GetExpressionType());

            return(retVal);
        }
Exemplo n.º 5
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)
            {
                Value = new Values.StringValue(EFSSystem.StringType, Image);
            }

            return(retVal);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Performs the semantic analysis of the statement
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(Utils.INamable instance)
        {
            bool retVal = base.SemanticAnalysis(instance);

            if (retVal)
            {
                Call.SemanticAnalysis(instance);
            }

            return(retVal);
        }
        /// <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 virtual bool SemanticAnalysis(Utils.INamable instance, Filter.AcceptableChoice expectation)
        {
            bool retVal = !SemanticAnalysisDone;

            if (retVal)
            {
                SemanticAnalysisDone = true;
            }

            return(retVal);
        }
Exemplo n.º 8
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)
            {
                IteratorExpression.SemanticAnalysis(instance, Filter.AllMatches);
            }

            return(retVal);
        }
Exemplo n.º 9
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);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Performs the semantic analysis of the statement
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(Utils.INamable instance)
        {
            bool retVal = base.SemanticAnalysis(instance);

            if (retVal)
            {
                VariableIdentification.SemanticAnalysis(instance, Filter.IsLeftSide);
                Expression.SemanticAnalysis(instance, Filter.IsRightSide);
            }

            return(retVal);
        }
        /// <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)
            {
                Left.SemanticAnalysis(instance, Filter.IsRightSide);
                Right.SemanticAnalysis(instance, Filter.IsRightSide);
            }

            return(retVal);
        }
        /// <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)
            {
                AccumulatorVariable.Type = IteratorExpression.GetExpressionType();

                Accumulator.SemanticAnalysis(instance, Filter.AllMatches);
            }

            return(retVal);
        }
        /// <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)
            {
                if (Condition != null)
                {
                    Condition.SemanticAnalysis(instance, expectation);
                }
            }

            return(retVal);
        }
        /// <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)
            {
                Structure.SemanticAnalysis(instance, Filter.IsStructure);
                foreach (Expression expr in Associations.Values)
                {
                    expr.SemanticAnalysis(instance, Filter.IsRightSide);
                }
            }

            return(retVal);
        }
Exemplo n.º 15
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)
            {
                Value = Type.getValue(Image);
                if (Value == null)
                {
                    AddError("Cannot evaluate " + ToString() + " as a number");
                }
            }

            return(retVal);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Provides the possible references for this term (only available during semantic analysis)
        /// </summary>
        /// <param name="instance">the instance on which this element should be found.</param>
        /// <param name="expectation">the expectation on the element found</param>
        /// <param name="last">indicates that this is the last element in a dereference chain</param>
        /// <returns></returns>
        public ReturnValue getReferences(Utils.INamable instance, Filter.AcceptableChoice expectation, bool last)
        {
            ReturnValue retVal = null;

            if (Designator != null)
            {
                retVal = Designator.getReferences(instance, expectation, last);
            }
            else if (LiteralValue != null)
            {
                retVal = LiteralValue.getReferences(instance, expectation, last);
            }

            return(retVal);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Performs the semantic analysis of the statement
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(Utils.INamable instance)
        {
            bool retVal = base.SemanticAnalysis(instance);

            if (retVal)
            {
                Value.SemanticAnalysis(instance);
                ListExpression.SemanticAnalysis(instance, Filter.IsLeftSide);
                if (ReplaceElement != null)
                {
                    ReplaceElement.SemanticAnalysis(instance);
                }
            }

            return(retVal);
        }
        /// <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);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Finds all namable which match the full name provided
        /// </summary>
        /// <param name="fullname">The full name used to search the namable</param>
        public Utils.INamable findByFullName(string fullname)
        {
            Utils.INamable retVal = null;

            foreach (Dictionary dictionary in Dictionaries)
            {
                retVal = dictionary.findByFullName(fullname);
                if (retVal != null)
                {
                    // TODO : only finds the first occurence of the namable in all opened dictionaries.
                    break;
                }
            }

            return(retVal);
        }
Exemplo n.º 20
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)
            {
                Called.SemanticAnalysis(instance, Filter.IsCallable);
                foreach (Expression actual in AllParameters)
                {
                    actual.SemanticAnalysis(instance, Filter.IsActualParameter);
                }

                ParameterAssociation = createParameterAssociation(Called.Ref as ICallable);
            }

            return(retVal);
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Provides the possible references for this dereference expression (only available during semantic analysis)
        /// </summary>
        /// <param name="instance">the instance on which this element should be found.</param>
        /// <param name="expectation">the expectation on the element found</param>
        /// <param name="last">indicates that this is the last element in a dereference chain</param>
        /// <returns></returns>
        public override ReturnValue getReferences(Utils.INamable instance, Filter.AcceptableChoice expectation, bool last)
        {
            ReturnValue retVal = ReturnValue.Empty;

            if (Term != null)
            {
                retVal = Term.getReferences(instance, expectation, last);
            }
            else
            {
                if (UnaryOp == null)
                {
                    retVal = Expression.getReferences(instance, expectation, last);
                }
            }

            return(retVal);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Adds a new value in the set of return values
        /// </summary>
        /// <param name="value">The value to add</param>
        /// <param name="previous">The previous element in the chain</param>
        public void Add(Utils.INamable value, ReturnValueElement previous = null)
        {
            if (value != null)
            {
                bool found = false;
                foreach (ReturnValueElement elem in Values)
                {
                    if (elem.Value == value)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    Values.Add(new ReturnValueElement(value, previous));
                }
            }
        }
        /// <summary>
        /// Performs the semantic analysis of the statement
        /// </summary>
        /// <param name="instance">the reference instance on which this element should analysed</param>
        /// <returns>True if semantic analysis should be continued</returns>
        public override bool SemanticAnalysis(Utils.INamable instance)
        {
            bool retVal = base.SemanticAnalysis(instance);

            if (retVal)
            {
                ListExpression.SemanticAnalysis(instance);
                Types.Collection collectionType = ListExpression.GetExpressionType() as Types.Collection;
                if (collectionType != null)
                {
                    IteratorVariable.Type = collectionType.Type;
                }

                if (Condition != null)
                {
                    Condition.SemanticAnalysis(instance);
                }
            }

            return(retVal);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Provides the graph associated to the namable
        /// </summary>
        /// <param name="namable"></param>
        /// <returns></returns>
        public static Graph createGraph(Utils.INamable namable, Parameter parameter)
        {
            Graph retVal = null;

            Functions.Function function = namable as Functions.Function;
            if (function != null)
            {
                retVal = function.createGraphForParameter(new Interpreter.InterpretationContext(), parameter);
            }

            if (retVal == null)
            {
                Values.IValue value = namable as Values.IValue;
                if (value != null)
                {
                    retVal = createGraph(Function.getDoubleValue(value), parameter);
                }
            }

            return(retVal);
        }
Exemplo n.º 26
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)
            {
                Types.Type elementType = null;

                foreach (Expression expr in ListElements)
                {
                    expr.SemanticAnalysis(instance, expectation);
                    Types.Type current = expr.GetExpressionType();
                    if (elementType == null)
                    {
                        elementType = current;
                    }
                    else
                    {
                        if (current != elementType)
                        {
                            AddError("Cannot mix types " + current.ToString() + " and " + elementType.ToString() + "in collection");
                        }
                    }
                }

                if (elementType != null)
                {
                    ExpressionType           = (Types.Collection)Generated.acceptor.getFactory().createCollection();
                    ExpressionType.Type      = elementType;
                    ExpressionType.Name      = "ListOf_" + elementType.FullName;
                    ExpressionType.Enclosing = Root.EFSSystem;
                }
                else
                {
                    ExpressionType = new Types.GenericCollection(EFSSystem);
                }
            }

            return(retVal);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Provides the possible references types for this expression (used in semantic analysis)
        /// </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>
        /// <param name="last">indicates that this is the last element in a dereference chain</param>
        /// <returns></returns>
        public ReturnValue getReferenceTypes(Utils.INamable instance, Filter.AcceptableChoice expectation, bool last)
        {
            ReturnValue retVal = null;

            if (Designator != null)
            {
                retVal = new ReturnValue();

                foreach (ReturnValueElement element in Designator.getReferences(instance, expectation, last).Values)
                {
                    if (element.Value is Types.Type)
                    {
                        retVal.Add(element.Value);
                    }
                }
            }
            else if (LiteralValue != null)
            {
                retVal = LiteralValue.getReferenceTypes(instance, expectation, true);
            }

            return(retVal);
        }
Exemplo n.º 28
0
 /// <summary>
 /// Performs the semantic analysis of the expression
 /// </summary>
 /// <param name="instance">the reference instance on which this element should analysed</param>
 /// <returns>True if semantic analysis should be continued</returns>
 public bool SemanticAnalysis(Utils.INamable instance = null)
 {
     return(SemanticAnalysis(instance, Filter.AllMatches));
 }
Exemplo n.º 29
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="value"></param>
 /// <param name="previous"></param>
 public ReturnValueElement(Utils.INamable value, ReturnValueElement previous = null)
 {
     PreviousElement = previous;
     Value           = value;
 }
Exemplo n.º 30
0
 /// <summary>
 /// Provides the possible references for this expression (only available during semantic analysis)
 /// </summary>
 /// <param name="instance">the instance on which this element should be found.</param>
 /// <param name="expectation">the expectation on the element found</param>
 /// <param name="last">indicates that this is the last element in a dereference chain</param>
 /// <returns></returns>
 public virtual ReturnValue getReferences(Utils.INamable instance, Filter.AcceptableChoice expectation, bool last)
 {
     return(ReturnValue.Empty);
 }