예제 #1
0
 protected void CheckBaseObjectTypeIsKnown(SequenceCheckingEnvironment env, String baseObjectType, String whichArgument)
 {
     if (TypesHelper.GetObjectType(baseObjectType, env.Model) == null && TypesHelper.GetTransientObjectType(baseObjectType, env.Model) == null)
     {
         throw new SequenceParserException(Symbol + whichArgument, "object type or transient object type", baseObjectType);
     }
 }
        public override string Type(SequenceCheckingEnvironment env)
        {
            if (DestVar.Type == "")
            {
                return("");
            }

            InheritanceType inheritanceType = TypesHelper.GetInheritanceType(DestVar.Type, env.Model);
            AttributeType   attributeType   = inheritanceType.GetAttributeType(AttributeName);

            if (attributeType == null)
            {
                return(""); // error, will be reported by Check, just ensure we don't crash here
            }
            string ContainerType = TypesHelper.AttributeTypeToXgrsType(attributeType);

            if (DestVar.Type.StartsWith("map"))
            {
                return(TypesHelper.ExtractDst(DestVar.Type) ?? "");
            }
            else
            {
                return(TypesHelper.ExtractSrc(DestVar.Type) ?? "");
            }
        }
예제 #3
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env);

            if (DestVar.Type == "")
            {
                return; // we can't check source and destination types if the variable is untyped, only runtime-check possible
            }
            if (TypesHelper.ExtractSrc(DestVar.Type) == null || TypesHelper.ExtractDst(DestVar.Type) == null || TypesHelper.ExtractDst(DestVar.Type) == "SetValueType")
            {
                throw new SequenceParserException(Symbol, "map<S,T> or array<T> or deque<T>", DestVar.Type);
            }
            if (DestVar.Type.StartsWith("array"))
            {
                if (!TypesHelper.IsSameOrSubtype(KeyExpression.Type(env), "int", env.Model))
                {
                    throw new SequenceParserException(Symbol, "int", KeyExpression.Type(env));
                }
            }
            else if (DestVar.Type.StartsWith("deque"))
            {
                if (!TypesHelper.IsSameOrSubtype(KeyExpression.Type(env), "int", env.Model))
                {
                    throw new SequenceParserException(Symbol, "int", KeyExpression.Type(env));
                }
            }
            else
            {
                if (!TypesHelper.IsSameOrSubtype(KeyExpression.Type(env), TypesHelper.ExtractSrc(DestVar.Type), env.Model))
                {
                    throw new SequenceParserException(Symbol, TypesHelper.ExtractSrc(DestVar.Type), KeyExpression.Type(env));
                }
            }
        }
예제 #4
0
 public override string Type(SequenceCheckingEnvironment env)
 {
     if(DestVar.Type.StartsWith("map"))
         return TypesHelper.ExtractDst(DestVar.Type) ?? "";
     else
         return TypesHelper.ExtractSrc(DestVar.Type) ?? "";
 }
예제 #5
0
        public override string Type(SequenceCheckingEnvironment env)
        {
            if(DestVar.Type == "")
                return "";

            GrGenType nodeOrEdgeType = TypesHelper.GetNodeOrEdgeType(DestVar.Type, env.Model);
            AttributeType attributeType = nodeOrEdgeType.GetAttributeType(AttributeName);
            return TypesHelper.AttributeTypeToXgrsType(attributeType);
        }
예제 #6
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env);

            GrGenType nodeOrEdgeType = TypesHelper.GetNodeOrEdgeType(GraphElementVar.Type, env.Model);
            if(GraphElementVar.Type != "" && nodeOrEdgeType == null)
                throw new SequenceParserException(Symbol, "node or edge type", GraphElementVar.Type);
            if(!TypesHelper.IsSameOrSubtype(VisitedFlagExpression.Type(env), "int", env.Model))
                throw new SequenceParserException(Symbol, "int", VisitedFlagExpression.Type(env));
        }
        public override string Type(SequenceCheckingEnvironment env)
        {
            if (DestVar.Type == "")
            {
                return("");
            }

            InheritanceType inheritanceType = TypesHelper.GetInheritanceType(DestVar.Type, env.Model);
            AttributeType   attributeType   = inheritanceType.GetAttributeType(AttributeName);

            return(TypesHelper.AttributeTypeToXgrsType(attributeType));
        }
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env);

            if (DestVar.Type == "")
            {
                return; // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible
            }
            InheritanceType inheritanceType = TypesHelper.GetInheritanceType(DestVar.Type, env.Model);

            if (inheritanceType == null)
            {
                throw new SequenceParserException(Symbol, "node or edge or object or transient object type (class)", DestVar.Type);
            }
            AttributeType attributeType = inheritanceType.GetAttributeType(AttributeName);

            if (attributeType == null)
            {
                throw new SequenceParserException(AttributeName, SequenceParserError.UnknownAttribute);
            }

            string ContainerType = TypesHelper.AttributeTypeToXgrsType(attributeType);

            if (TypesHelper.ExtractSrc(ContainerType) == null ||
                TypesHelper.ExtractDst(ContainerType) == null ||
                TypesHelper.ExtractDst(ContainerType) == "SetValueType")
            {
                throw new SequenceParserException(Symbol, "map<S,T> or array<T> or deque<T>", DestVar.Type);
            }
            if (ContainerType.StartsWith("array"))
            {
                if (!TypesHelper.IsSameOrSubtype(KeyExpression.Type(env), "int", env.Model))
                {
                    throw new SequenceParserException(Symbol, "int", KeyExpression.Type(env));
                }
            }
            else if (ContainerType.StartsWith("deque"))
            {
                if (!TypesHelper.IsSameOrSubtype(KeyExpression.Type(env), "int", env.Model))
                {
                    throw new SequenceParserException(Symbol, "int", KeyExpression.Type(env));
                }
            }
            else
            {
                if (!TypesHelper.IsSameOrSubtype(KeyExpression.Type(env), TypesHelper.ExtractSrc(ContainerType), env.Model))
                {
                    throw new SequenceParserException(Symbol, TypesHelper.ExtractSrc(ContainerType), KeyExpression.Type(env));
                }
            }
        }
예제 #9
0
        protected void CheckEdgeTypeIsKnown(SequenceCheckingEnvironment env, SequenceExpression typeExpr, String whichArgument)
        {
            if (typeExpr == null || typeExpr.Type(env) == "")
            {
                return;
            }

            string typeString = GetTypeString(env, typeExpr);

            if (TypesHelper.GetEdgeType(typeString, env.Model) == null && typeString != null)
            {
                throw new SequenceParserException(Symbol + whichArgument, "edge type or string denoting edge type", typeString);
            }
        }
예제 #10
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env);

            if(DestVar.Type == "")
                return; // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible

            GrGenType nodeOrEdgeType = TypesHelper.GetNodeOrEdgeType(DestVar.Type, env.Model);
            if(nodeOrEdgeType == null)
                throw new SequenceParserException(Symbol, "node or edge type", DestVar.Type);
            AttributeType attributeType = nodeOrEdgeType.GetAttributeType(AttributeName);
            if(attributeType == null)
                throw new SequenceParserException(AttributeName, SequenceParserError.UnknownAttribute);
        }
예제 #11
0
        protected string GetTypeString(SequenceCheckingEnvironment env, SequenceExpression typeExpr)
        {
            if (typeExpr.Type(env) == "string")
            {
                if (typeExpr is SequenceExpressionConstant)
                {
                    return((string)((SequenceExpressionConstant)typeExpr).Constant);
                }
            }
            else
            {
                return(typeExpr.Type(env));
            }

            return(null);
        }
예제 #12
0
        public override string Type(SequenceCheckingEnvironment env)
        {
            if(DestVar.Type == "")
                return "";

            GrGenType nodeOrEdgeType = TypesHelper.GetNodeOrEdgeType(DestVar.Type, env.Model);
            AttributeType attributeType = nodeOrEdgeType.GetAttributeType(AttributeName);
            if(attributeType == null)
                return ""; // error, will be reported by Check, just ensure we don't crash here

            string ContainerType = TypesHelper.AttributeTypeToXgrsType(attributeType);

            if(DestVar.Type.StartsWith("map"))
                return TypesHelper.ExtractDst(DestVar.Type) ?? "";
            else
                return TypesHelper.ExtractSrc(DestVar.Type) ?? "";
        }
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env);

            if (DestVar.Type == "")
            {
                return; // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible
            }
            InheritanceType inheritanceType = TypesHelper.GetInheritanceType(DestVar.Type, env.Model);

            if (inheritanceType == null)
            {
                throw new SequenceParserException(Symbol, "node or edge or object or transient object type (class)", DestVar.Type);
            }
            AttributeType attributeType = inheritanceType.GetAttributeType(AttributeName);

            if (attributeType == null)
            {
                throw new SequenceParserException(AttributeName, SequenceParserError.UnknownAttribute);
            }
        }
예제 #14
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env); // check children

            if(Graph.Type(env) == "")
                return; // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible

            if(Graph.Type(env) != "graph")
            {
                throw new SequenceParserException(Symbol, "graph type", Graph.Type(env));
            }
        }
예제 #15
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env); // check children

            if(!SourceVarType.StartsWith("match<"))
                throw new Exception("SequenceExpression MatchAccess can only access a variable of type match<rulename>");

            string ruleName = TypesHelper.ExtractSrc(SourceVarType);

            // throws exceptions in case the rule does not exist, or it does not contain an element of the given name
            string elementType = env.TypeOfTopLevelEntityInRule(ruleName, ElementName);

            if(elementType == "")
                throw new Exception("Internal failure, static type of element in match type not known");
        }
예제 #16
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env); // check children

            if(Subgraph.Type(env) != "")
            {
                if(Subgraph.Type(env) != "graph")
                {
                    throw new SequenceParserException(Symbol + ", first argument", "graph type", Subgraph.Type(env));
                }
            }

            if(SubgraphSet.Type(env) != "")
            {
                if(!SubgraphSet.Type(env).StartsWith("set<"))
                {
                    throw new SequenceParserException(Symbol + ", second argument", "set<graph> type", SubgraphSet.Type(env));
                }
                if(TypesHelper.ExtractSrc(SubgraphSet.Type(env)) != "graph")
                {
                    throw new SequenceParserException(Symbol + ", second argument", "set<graph> type", SubgraphSet.Type(env));
                }
            }
        }
예제 #17
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     return ObjectToBeCopied.Type(env);
 }
예제 #18
0
 public override void Check(SequenceCheckingEnvironment env)
 {
     env.CheckFunctionMethodCall(TargetExpr, this);
 }
예제 #19
0
 public override void Check(SequenceCheckingEnvironment env)
 {
     base.Check(env); // check children
 }
예제 #20
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     return "graph";
 }
예제 #21
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     return ""; // no constraints regarding the types of the expressions to choose from
 }
예제 #22
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     if(SequenceExpressionType == SequenceExpressionType.AdjacentNodes
         || SequenceExpressionType == SequenceExpressionType.AdjacentNodesViaIncoming
         || SequenceExpressionType == SequenceExpressionType.AdjacentNodesViaOutgoing)
     {
         return "set<Node>";
     }
     else // SequenceExpressionType.IncidentEdges || SequenceExpressionType.IncomingEdges || SequenceExpressionType.OutgoingEdges
     {
         return "set<Edge>";
     }
 }
예제 #23
0
 public override void Check(SequenceCheckingEnvironment env)
 {
     base.Check(env); // check children
     
     if(!TypesHelper.IsSameOrSubtype(Condition.Type(env), "boolean", env.Model))
     {
         throw new SequenceParserException(Symbol, "boolean", Condition.Type(env));
     }
 }
예제 #24
0
 public override void Check(SequenceCheckingEnvironment env)
 {
 }
예제 #25
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env); // check children

            if(EdgeType != null && EdgeType.Type(env) != "")
            {
                string typeString = null;
                if(EdgeType.Type(env) == "string")
                {
                    if(EdgeType is SequenceExpressionConstant)
                        typeString = (string)((SequenceExpressionConstant)EdgeType).Constant;
                }
                else
                {
                    typeString = EdgeType.Type(env);
                }
                EdgeType edgeType = TypesHelper.GetEdgeType(typeString, env.Model);
                if(edgeType == null && typeString != null)
                {
                    throw new SequenceParserException(Symbol + ", argument", "edge type or string denoting edge type", typeString);
                }
            }
        }
예제 #26
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     return "set<Edge>";
 }
예제 #27
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     string ruleName = TypesHelper.ExtractSrc(SourceVarType);
     return env.TypeOfTopLevelEntityInRule(ruleName, ElementName);
 }
예제 #28
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            if(UniquelyIdentifiedEntity != null)
            {
                base.Check(env); // check children

                if(!TypesHelper.IsSameOrSubtype(UniquelyIdentifiedEntity.Type(env), "Node", env.Model)
                    && !TypesHelper.IsSameOrSubtype(UniquelyIdentifiedEntity.Type(env), "Edge", env.Model)
                    && !TypesHelper.IsSameOrSubtype(UniquelyIdentifiedEntity.Type(env), "graph", env.Model))
                {
                    throw new SequenceParserException(Symbol, "node or edge or graph type", UniquelyIdentifiedEntity.Type(env));
                }
            }
        }
예제 #29
0
        public string CheckAndReturnAttributeType(SequenceCheckingEnvironment env)
        {
            base.Check(env); // check children

            if(SourceVarType == "")
                return ""; // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible

            GrGenType nodeOrEdgeType = TypesHelper.GetNodeOrEdgeType(SourceVarType, env.Model);
            if(nodeOrEdgeType == null)
            {
                throw new SequenceParserException(Symbol, "node or edge type", SourceVarType);
            }
            AttributeType attributeType = nodeOrEdgeType.GetAttributeType(AttributeName);
            if(attributeType == null)
            {
                throw new SequenceParserException(AttributeName, SequenceParserError.UnknownAttribute);
            }

            return TypesHelper.AttributeTypeToXgrsType(attributeType);
        }
예제 #30
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     return "string"; // typeof in the sequences returns the type name
 }
예제 #31
0
 public override string Type(SequenceCheckingEnvironment env)
 {
     LeftTypeStatic = Left.Type(env);
     RightTypeStatic = Right.Type(env);
     return SequenceExpressionHelper.Balance(SequenceExpressionType, LeftTypeStatic, RightTypeStatic, env.Model);
 }
예제 #32
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env); // check children

            if(Path.Type(env) == "")
                return; // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible

            if(!TypesHelper.IsSameOrSubtype(Path.Type(env), "string", env.Model))
            {
                throw new SequenceParserException(Symbol, "string type", Path.Type(env));
            }
        }
 public override string Type(SequenceCheckingEnvironment env)
 {
     return(DestVar.Type);
 }
예제 #34
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env); // check children

            if(ObjectToBeCopied.Type(env) == "")
                return; // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible

            if(!TypesHelper.IsSameOrSubtype(ObjectToBeCopied.Type(env), "graph", env.Model)
                && !ObjectToBeCopied.Type(env).StartsWith("match<")
                && (TypesHelper.ExtractSrc(ObjectToBeCopied.Type(env)) == null || TypesHelper.ExtractDst(ObjectToBeCopied.Type(env)) == null))
            {
                throw new SequenceParserException(Symbol, "graph type or match type or container type", ObjectToBeCopied.Type(env));
            }
        }
예제 #35
0
 public override void Check(SequenceCheckingEnvironment env)
 {
     CheckAndReturnAttributeType(env);
 }
예제 #36
0
 public override void Check(SequenceCheckingEnvironment env)
 {
     env.CheckFunctionCall(this);
     IsExternalFunctionCalled = env.IsFunctionCallExternal(ParamBindings);
 }
예제 #37
0
 /// <summary>
 /// Returns the type of the sequence /expression (for sequences always "boolean")
 /// </summary>
 public abstract string Type(SequenceCheckingEnvironment env);
예제 #38
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     if(ParamBindings.FunctionDef != null)
         return TypesHelper.DotNetTypeToXgrsType(ParamBindings.FunctionDef.Output);
     else // compiled sequence
         return ParamBindings.ReturnType;
 }
예제 #39
0
        public override String Type(SequenceCheckingEnvironment env)
        {
            if(SourceVarType == "")
                return ""; // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible
            
            GrGenType nodeOrEdgeType = TypesHelper.GetNodeOrEdgeType(SourceVarType, env.Model);
            AttributeType attributeType = nodeOrEdgeType.GetAttributeType(AttributeName);
            if(attributeType == null)
                return ""; // error, will be reported by Check, just ensure we don't crash here

            return TypesHelper.AttributeTypeToXgrsType(attributeType);
        }
예제 #40
0
 /// <summary>
 /// Returns the type of the sequence expression
 /// default behaviour: returns "boolean"
 /// </summary>
 public override string Type(SequenceCheckingEnvironment env)
 {
     return "boolean";
 }
예제 #41
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     if(TargetType is NodeType)
         return ((NodeType)TargetType).Name;
     if(TargetType is EdgeType)
         return ((EdgeType)TargetType).Name;
     return null; // TODO: handle the non-node and non-edge-types, too
 }
예제 #42
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env); // check children

            if(SourceNode.Type(env) != "") // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible
            {
                NodeType nodeType = TypesHelper.GetNodeType(SourceNode.Type(env), env.Model);
                if(nodeType == null)
                {
                    throw new SequenceParserException(Symbol+", first argument", "node type", SourceNode.Type(env));
                }
            }
            if(EndElement.Type(env) != "") // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible
            {
                if(SequenceExpressionType == SequenceExpressionType.IsReachableNodes || SequenceExpressionType == SequenceExpressionType.IsReachableNodesViaIncoming || SequenceExpressionType == SequenceExpressionType.IsReachableNodesViaOutgoing)
                {
                    NodeType nodeType = TypesHelper.GetNodeType(EndElement.Type(env), env.Model);
                    if(nodeType == null)
                    {
                        throw new SequenceParserException(Symbol + ", second argument", "node type", EndElement.Type(env));
                    }
                }
                else
                {
                    EdgeType edgeType = TypesHelper.GetEdgeType(EndElement.Type(env), env.Model);
                    if(edgeType == null)
                    {
                        throw new SequenceParserException(Symbol + ", second argument", "edge type", EndElement.Type(env));
                    }
                }
            }
            if(EdgeType != null && EdgeType.Type(env) != "")
            {
                string typeString = null;
                if(EdgeType.Type(env) == "string")
                {
                    if(EdgeType is SequenceExpressionConstant)
                        typeString = (string)((SequenceExpressionConstant)EdgeType).Constant;
                }
                else
                {
                    typeString = EdgeType.Type(env);
                }
                EdgeType edgeType = TypesHelper.GetEdgeType(typeString, env.Model);
                if(edgeType == null && typeString != null)
                {
                    throw new SequenceParserException(Symbol + ", third argument", "edge type or string denoting edge type", typeString);
                }
            }
            if(OppositeNodeType!=null && OppositeNodeType.Type(env)!="")
            {
                string typeString = null;
                if(OppositeNodeType.Type(env) == "string")
                {
                    if(OppositeNodeType is SequenceExpressionConstant)
                        typeString = (string)((SequenceExpressionConstant)OppositeNodeType).Constant;
                }
                else
                {
                    typeString = OppositeNodeType.Type(env);
                }
                NodeType nodeType = TypesHelper.GetNodeType(typeString, env.Model);
                if(nodeType == null && typeString != null)
                {
                    throw new SequenceParserException(Symbol + ", fourth argument", "node type or string denoting node type", typeString);
                }
            }
        }
예제 #43
0
        public override void Check(SequenceCheckingEnvironment env)
        {
            base.Check(env); // check children

            if(EdgeSet.Type(env) == "")
                return; // we can't gain access to an attribute type if the variable is untyped, only runtime-check possible

            if(!EdgeSet.Type(env).StartsWith("set<"))
            {
                throw new SequenceParserException(Symbol, "set<Edge> type", EdgeSet.Type(env));
            }
            if(TypesHelper.ExtractSrc(EdgeSet.Type(env)) != "Edge")
            {
                throw new SequenceParserException(Symbol, "set<Edge> type", EdgeSet.Type(env));
            }
        }
예제 #44
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     if(SequenceExpressionType == SequenceExpressionType.BoundedReachableNodes
         || SequenceExpressionType == SequenceExpressionType.BoundedReachableNodesViaIncoming
         || SequenceExpressionType == SequenceExpressionType.BoundedReachableNodesViaOutgoing)
     {
         return "set<Node>";
     }
     else // SequenceExpressionType.BoundedReachableEdges || SequenceExpressionType.BoundedReachableEdgesViaIncoming || SequenceExpressionType.BoundedReachableEdgesViaOutgoing
     {
         return "set<Edge>";
     }
 }
예제 #45
0
 /// <summary>
 /// Checks the sequence /expression for errors utilizing the given checking environment
 /// reports them by exception
 /// </summary>s
 public abstract void Check(SequenceCheckingEnvironment env);
 public override string Type(SequenceCheckingEnvironment env)
 {
     return("boolean");
 }
예제 #47
0
 public override String Type(SequenceCheckingEnvironment env)
 {
     return "map<Node,int>";
 }