Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Added RestrictionType to the ElementTypeRestriction, to be able to

decide which kind of TypeList it holds (Can't decide whether a TypeId
denotes an EdgeType or a VertexType while parsing).


- ElementSetRestriction now holds an expression. The evaluation will
have to restrict that to sets of edges and vertices.
  • Loading branch information...
commit c2dc6e1986176ef0bbfda32c4c5ceacc9bd89e06 1 parent 27380e5
Jon authored
View
5 src/de/uni_koblenz/jgralab/greql2/GreqlSchema.tg
@@ -29,6 +29,7 @@ GraphClass GreqlSyntaxGraph;
EnumDomain IncDirection (IN, OUT, BOTH);
EnumDomain IterationType (STAR, PLUS);
EnumDomain QuantificationType (FORALL, EXISTS, EXISTSONE);
+EnumDomain RestrictionType (EDGE, VERTEX, BOTH);
RecordDomain SourcePosition (offset:Integer, length: Integer);
// A common superclass for all vertices of GReQL2-vertices
@@ -51,7 +52,7 @@ VertexClass EdgeSetExpression: ElementSetExpression;
VertexClass EdgeSubgraphDefinition: SubgraphDefinition;
abstract VertexClass ElementRestriction: Greql2Vertex;
VertexClass ElementSetRestriction: ElementRestriction;
-VertexClass ElementTypeRestriction: ElementRestriction;
+VertexClass ElementTypeRestriction: ElementRestriction {restrType: RestrictionType};
VertexClass ExponentiatedPathDescription: PathDescription;
VertexClass ForwardElementSet: PathExpression;
VertexClass FunctionApplication: Expression;
@@ -138,7 +139,6 @@ BinaryEdgeClass IsConditionOf: Greql2Aggregation from Expression role condition
BinaryEdgeClass IsConstraintOf: Greql2Aggregation from Expression role constraint (0,*) (1,1) to Declaration (0,*) (1,1);
BinaryEdgeClass IsConstrainedExpressionOf: Greql2Aggregation from Expression role constrainedExpression (1,1) (1,1) to SubgraphExpression (0,*) (1,1);
BinaryEdgeClass IsDeclaredVarOf: Greql2Aggregation from Variable role declaredVariable (1,*) (1,1) to SimpleDeclaration role variableDeclaration (0,1) (1,1);
-BinaryEdgeClass IsDeclarationOf: Greql2Aggregation from SimpleDeclaration role declaredElement (1,*) (1,1) to ElementSetRestriction (1,*) (1,1);
BinaryEdgeClass IsDefinitionOf: Greql2Aggregation from Definition role definition (1,*) (1,1) to DefinitionExpression (1,*) (1,1);
BinaryEdgeClass IsEdgeDirectionOf: Greql2Aggregation from EdgeDirection role direction (1,1) (1,1) to PrimaryPathDescription (1,*) (1,1);
BinaryEdgeClass IsIncDirectionOf: Greql2Aggregation from IncidenceDirection role direction (1,1) (1,1) to SimpleIncidencePathDescription (1,*) (1,1);
@@ -149,6 +149,7 @@ BinaryEdgeClass IsIncRestrOf: Greql2Aggregation from IncidenceRestriction role i
BinaryEdgeClass IsExponentOf: Greql2Aggregation from IntLiteral role exponent (1,1) (1,1) to ExponentiatedPathDescription (0,*) (1,1);
BinaryEdgeClass IsExponentiatedPathOf: IsPathDescriptionOf from PathDescription role exponentiatedPath (1,1) (1,1) to ExponentiatedPathDescription (0,*) (1,1);
BinaryEdgeClass IsExprOf:Greql2Aggregation from Expression role expr (1,1) (1,1) to Definition (0,*) (1,1);
+BinaryEdgeClass IsExpressionOfRestriction: Greql2Aggregation from Expression role expression (1,1) (1,1) to ElementSetRestriction (0,*) (1,1);
BinaryEdgeClass IsFalseExprOf: Greql2Aggregation from Expression role falseExpr (1,1) (1,1) to ConditionalExpression (0,*) (1,1);
BinaryEdgeClass IsFirstValueOf: Greql2Aggregation from Expression role firstValue (1,1) (1,1) to ListRangeConstruction (0,*) (1,1);
BinaryEdgeClass IsFunctionIdOf: Greql2Aggregation from FunctionId role functionId (1,1) (1,1) to FunctionApplication role functionApplication (1,*) (1,1);
View
19 src/de/uni_koblenz/jgralab/greql2/parser/GreqlParser.java
@@ -1730,7 +1730,7 @@ private ElementRestriction parseElementRestriction() {
// Starting with E can only mean EdgeTypeList (if a colon follows)
// or an ElementSet (e. g. restricting to all Edges)
if (tryMatch(TokenTypes.COLON)) {
- return parseTypeRestriction();
+ return parseTypeRestriction(RestrictionType.EDGE);
} else {
return parseElementSetRestriction();
}
@@ -1740,11 +1740,11 @@ private ElementRestriction parseElementRestriction() {
match();
// Starting with V can mean VertexTypeList (if a colon follows)...
if (tryMatch(TokenTypes.COLON)) {
- return parseTypeRestriction();
+ return parseTypeRestriction(RestrictionType.VERTEX);
// Or a VertexAndEdgeTypeList (if an E follows)...
} else if (tryMatch(TokenTypes.E)) {
match(TokenTypes.COLON);
- return parseTypeRestriction();
+ return parseTypeRestriction(RestrictionType.BOTH);
} else {
// Or an ElementSet
return parseElementSetRestriction();
@@ -1755,23 +1755,24 @@ private ElementRestriction parseElementRestriction() {
}
private ElementRestriction parseElementSetRestriction() {
- List<VertexPosition<SimpleDeclaration>> declarationList = parseDeclarationList();
- if (declarationList != null && declarationList.size() > 0) {
+ Expression expr = parseExpression();
+ if (expr != null) {
ElementSetRestriction setRestriction = graph
.createElementSetRestriction();
- for (VertexPosition<SimpleDeclaration> declaration : declarationList) {
- graph.createIsDeclarationOf(declaration.node, setRestriction);
- }
+ graph.createIsExpressionOfRestriction(expr, setRestriction);
return setRestriction;
+ } else {
+ fail("No Expression found in ElementSetRestriction");
}
return null;
}
- private ElementRestriction parseTypeRestriction() {
+ private ElementRestriction parseTypeRestriction(RestrictionType rType) {
List<VertexPosition<TypeId>> typeList = parseTypeExpressionList();
if (typeList != null && typeList.size() > 0) {
ElementTypeRestriction typeRestriction = graph
.createElementTypeRestriction();
+ typeRestriction.set_restrType(rType);
for (VertexPosition<TypeId> type : typeList) {
graph.createIsTypeIdOfRestriction(type.node, typeRestriction);
}
Please sign in to comment.
Something went wrong with that request. Please try again.