blob: 81c18d0de05ba31e47ad5a3380e265b56ffde6e8 (
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
|
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:
statements+=Statement*;
Statement:
ClassDeclaration | PredicateDefinition | Assertion | ScopeDeclaration;
ClassDeclaration:
abstract?="abstract"? "class"
name=ID
("extends" (superTypes+=[ClassDeclaration] |
"[" (superTypes+=[ClassDeclaration] ("," superTypes+=[ClassDeclaration])*)? "]") |
referenceDeclarations+=ReferenceDeclaration)?
("," referenceDeclarations+=ReferenceDeclaration)*
".";
ReferenceDeclaration:
(containment?="contains" | "refers")
referenceType=[ClassDeclaration]
"[" multiplicity=Multiplicity "]"
name=ID
("opposite" opposite=[ReferenceDeclaration|QualifiedName])?;
PredicateDefinition:
(error?="error" "pred"? | "pred")
name=ID
"(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")"
(":=" bodies+=Conjunction (";" bodies+=Conjunction)*)?
".";
Parameter:
parameterType=[ClassDeclaration] name=ID;
Conjunction:
literals+=Literal ("," literals+=Literal)*;
Literal:
Atom | NegativeLiteral;
NegativeLiteral:
"!" atom=Atom;
Atom:
relation=[Relation|QualifiedName]
transitiveClosure?="+"?
"(" (arguments+=[Variable] ("," arguments+=[Variable])*)? ")";
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=Multiplicity;
Multiplicity:
RangeMultiplicity | ExactMultiplicity;
RangeMultiplicity:
lowerBound=INT ".." upperBound=UpperBound;
ExactMultiplicity:
exactValue=INT;
UpperBound returns ecore::EInt:
INT | "*";
QualifiedName:
ID ("::" ID)*;
|