blob: 5f8b35f3ee00b2e0f34b45246180c0306b649e3e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
grammar org.eclipse.viatra.solver.language.Problem with org.eclipse.xtext.common.Terminals
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.eclipse.org/viatra/solver/language/model/Problem"
Problem:
("problem" name=Identifier ".")?
statements+=Statement*;
Statement:
ClassDeclaration | EnumDeclaration | PredicateDefinition | Assertion | ScopeDeclaration;
ClassDeclaration:
abstract?="abstract"? "class"
name=Identifier
("extends" superTypes+=[Relation|QualifiedName] ("," superTypes+=[Relation|QualifiedName])*)?
("{" (referenceDeclarations+=ReferenceDeclaration ";"?)* "}" | ".");
EnumDeclaration:
"enum"
name=Identifier
("{" (literals+=EnumLiteral ("," literals+=EnumLiteral)* ("," | ";")?)? "}" | ".");
EnumLiteral returns Node:
name=QuotedOrUnquotedId;
ReferenceDeclaration:
(containment?="contains" | "refers")?
referenceType=[Relation|QualifiedName]
("[" multiplicity=Multiplicity "]")?
name=Identifier
("opposite" opposite=[ReferenceDeclaration|QualifiedName])?;
PredicateDefinition:
(error?="error" "pred"? | "pred")
name=Identifier
"(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")"
(":-" bodies+=Conjunction (";" bodies+=Conjunction)*)?
".";
Parameter:
parameterType=[Relation|QualifiedName]? name=Identifier;
Conjunction:
literals+=Literal ("," literals+=Literal)*;
Literal:
Atom | NegativeLiteral;
NegativeLiteral:
"!" atom=Atom;
Atom:
relation=[Relation|QualifiedName]
transitiveClosure?="+"?
"(" (arguments+=Argument ("," arguments+=Argument)*)? ")";
Argument:
variableOrNode=[VariableOrNode|QualifiedName];
Assertion:
(relation=[Relation|QualifiedName]
"(" (arguments+=[Node|QualifiedName] ("," arguments+=[Node|QualifiedName])*)? ")"
":" value=LogicValue |
value=ShortLogicValue?
relation=[Relation|QualifiedName]
"(" (arguments+=[Node|QualifiedName] ("," arguments+=[Node|QualifiedName])*)? ")")
".";
enum LogicValue:
TRUE="true" | FALSE="false" | UNKNOWN="unknown";
enum ShortLogicValue returns LogicValue:
FALSE="!" | UNKNOWN="?";
ScopeDeclaration:
"scope" typeScopes+=TypeScope ("," typeScopes+=TypeScope)* ".";
TypeScope:
targetType=[ClassDeclaration]
(increment?="+=" | "=")
multiplicity=DefiniteMultiplicity;
Multiplicity:
UnboundedMultiplicity | DefiniteMultiplicity;
DefiniteMultiplicity returns Multiplicity:
RangeMultiplicity | ExactMultiplicity;
UnboundedMultiplicity:
{UnboundedMultiplicity};
RangeMultiplicity:
lowerBound=INT ".." upperBound=UpperBound;
ExactMultiplicity:
exactValue=INT;
UpperBound returns ecore::EInt:
INT | "*";
QuotedOrUnquotedId:
QUOTED_ID | Identifier;
QualifiedName:
QUOTED_ID | Identifier (":" Identifier)* (":" QUOTED_ID)?;
Identifier:
ID | "true" | "false";
@Override
terminal STRING:
'"' ('\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\' | '"'))* '"';
terminal QUOTED_ID:
"'" ('\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\' | "'"))* "'";
|