diff options
author | 2021-06-27 01:43:59 +0200 | |
---|---|---|
committer | 2021-06-27 02:01:19 +0200 | |
commit | b88c842ba625753ea185e6166cd967e694160798 (patch) | |
tree | 51931f892dff12d253f7697179e137bdfe705155 /org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/Problem.xtext | |
parent | Opposite reference scope (diff) | |
download | refinery-b88c842ba625753ea185e6166cd967e694160798.tar.gz refinery-b88c842ba625753ea185e6166cd967e694160798.tar.zst refinery-b88c842ba625753ea185e6166cd967e694160798.zip |
Add enum support
Diffstat (limited to 'org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/Problem.xtext')
-rw-r--r-- | org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/Problem.xtext | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/Problem.xtext b/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/Problem.xtext index 2d4eb1b9..5f8b35f3 100644 --- a/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/Problem.xtext +++ b/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/Problem.xtext | |||
@@ -4,34 +4,42 @@ import "http://www.eclipse.org/emf/2002/Ecore" as ecore | |||
4 | import "http://www.eclipse.org/viatra/solver/language/model/Problem" | 4 | import "http://www.eclipse.org/viatra/solver/language/model/Problem" |
5 | 5 | ||
6 | Problem: | 6 | Problem: |
7 | ("problem" name=ID ".")? | 7 | ("problem" name=Identifier ".")? |
8 | statements+=Statement*; | 8 | statements+=Statement*; |
9 | 9 | ||
10 | Statement: | 10 | Statement: |
11 | ClassDeclaration | PredicateDefinition | Assertion | ScopeDeclaration; | 11 | ClassDeclaration | EnumDeclaration | PredicateDefinition | Assertion | ScopeDeclaration; |
12 | 12 | ||
13 | ClassDeclaration: | 13 | ClassDeclaration: |
14 | abstract?="abstract"? "class" | 14 | abstract?="abstract"? "class" |
15 | name=ID | 15 | name=Identifier |
16 | ("extends" superTypes+=[ClassDeclaration|QualifiedName] ("," superTypes+=[ClassDeclaration|QualifiedName])*)? | 16 | ("extends" superTypes+=[Relation|QualifiedName] ("," superTypes+=[Relation|QualifiedName])*)? |
17 | ("{" (referenceDeclarations+=ReferenceDeclaration ";"?)* "}" | "."); | 17 | ("{" (referenceDeclarations+=ReferenceDeclaration ";"?)* "}" | "."); |
18 | 18 | ||
19 | EnumDeclaration: | ||
20 | "enum" | ||
21 | name=Identifier | ||
22 | ("{" (literals+=EnumLiteral ("," literals+=EnumLiteral)* ("," | ";")?)? "}" | "."); | ||
23 | |||
24 | EnumLiteral returns Node: | ||
25 | name=QuotedOrUnquotedId; | ||
26 | |||
19 | ReferenceDeclaration: | 27 | ReferenceDeclaration: |
20 | (containment?="contains" | "refers") | 28 | (containment?="contains" | "refers")? |
21 | referenceType=[ClassDeclaration|QualifiedName] | 29 | referenceType=[Relation|QualifiedName] |
22 | ("[" multiplicity=Multiplicity "]")? | 30 | ("[" multiplicity=Multiplicity "]")? |
23 | name=ID | 31 | name=Identifier |
24 | ("opposite" opposite=[ReferenceDeclaration|QualifiedName])?; | 32 | ("opposite" opposite=[ReferenceDeclaration|QualifiedName])?; |
25 | 33 | ||
26 | PredicateDefinition: | 34 | PredicateDefinition: |
27 | (error?="error" "pred"? | "pred") | 35 | (error?="error" "pred"? | "pred") |
28 | name=ID | 36 | name=Identifier |
29 | "(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")" | 37 | "(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")" |
30 | (":-" bodies+=Conjunction (";" bodies+=Conjunction)*)? | 38 | (":-" bodies+=Conjunction (";" bodies+=Conjunction)*)? |
31 | "."; | 39 | "."; |
32 | 40 | ||
33 | Parameter: | 41 | Parameter: |
34 | parameterType=[ClassDeclaration] name=ID; | 42 | parameterType=[Relation|QualifiedName]? name=Identifier; |
35 | 43 | ||
36 | Conjunction: | 44 | Conjunction: |
37 | literals+=Literal ("," literals+=Literal)*; | 45 | literals+=Literal ("," literals+=Literal)*; |
@@ -48,7 +56,7 @@ Atom: | |||
48 | "(" (arguments+=Argument ("," arguments+=Argument)*)? ")"; | 56 | "(" (arguments+=Argument ("," arguments+=Argument)*)? ")"; |
49 | 57 | ||
50 | Argument: | 58 | Argument: |
51 | variable=[Variable]; | 59 | variableOrNode=[VariableOrNode|QualifiedName]; |
52 | 60 | ||
53 | Assertion: | 61 | Assertion: |
54 | (relation=[Relation|QualifiedName] | 62 | (relation=[Relation|QualifiedName] |
@@ -91,10 +99,18 @@ ExactMultiplicity: | |||
91 | UpperBound returns ecore::EInt: | 99 | UpperBound returns ecore::EInt: |
92 | INT | "*"; | 100 | INT | "*"; |
93 | 101 | ||
102 | QuotedOrUnquotedId: | ||
103 | QUOTED_ID | Identifier; | ||
104 | |||
94 | QualifiedName: | 105 | QualifiedName: |
95 | QUOTED_ID | ID (":" ID)* (":" QUOTED_ID)?; | 106 | QUOTED_ID | Identifier (":" Identifier)* (":" QUOTED_ID)?; |
107 | |||
108 | Identifier: | ||
109 | ID | "true" | "false"; | ||
96 | 110 | ||
97 | @Override | 111 | @Override |
98 | terminal STRING: '"' ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|'"') )* '"'; | 112 | terminal STRING: |
113 | '"' ('\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\' | '"'))* '"'; | ||
99 | 114 | ||
100 | terminal QUOTED_ID: "'" ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|"'") )* "'"; | 115 | terminal QUOTED_ID: |
116 | "'" ('\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\' | "'"))* "'"; | ||