Skip to content

Commit

Permalink
- Added RestrictionType to the ElementTypeRestriction, to be able to
Browse files Browse the repository at this point in the history
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
Jon committed Feb 16, 2012
1 parent 27380e5 commit c2dc6e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/de/uni_koblenz/jgralab/greql2/GreqlSchema.tg
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
19 changes: 10 additions & 9 deletions src/de/uni_koblenz/jgralab/greql2/parser/GreqlParser.java
Expand Up @@ -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();
}
Expand All @@ -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();
Expand All @@ -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);
}
Expand Down

0 comments on commit c2dc6e1

Please sign in to comment.