diff options
author | 2021-06-25 17:12:45 +0200 | |
---|---|---|
committer | 2021-06-25 17:12:45 +0200 | |
commit | baba88758a0ea5f671ab4a2aeacec374bed938c4 (patch) | |
tree | 1be30230a0959ce8d22986d91b1ed2460a328148 /org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/Problem.xtext | |
parent | Initial commit (diff) | |
download | refinery-baba88758a0ea5f671ab4a2aeacec374bed938c4.tar.gz refinery-baba88758a0ea5f671ab4a2aeacec374bed938c4.tar.zst refinery-baba88758a0ea5f671ab4a2aeacec374bed938c4.zip |
Add initial prototype
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 | 88 |
1 files changed, 88 insertions, 0 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 new file mode 100644 index 00000000..81c18d0d --- /dev/null +++ b/org.eclipse.viatra.solver.language.parent/org.eclipse.viatra.solver.language/src/main/java/org/eclipse/viatra/solver/language/Problem.xtext | |||
@@ -0,0 +1,88 @@ | |||
1 | grammar org.eclipse.viatra.solver.language.Problem with org.eclipse.xtext.common.Terminals | ||
2 | |||
3 | import "http://www.eclipse.org/emf/2002/Ecore" as ecore | ||
4 | import "http://www.eclipse.org/viatra/solver/language/model/Problem" | ||
5 | |||
6 | Problem: | ||
7 | statements+=Statement*; | ||
8 | |||
9 | Statement: | ||
10 | ClassDeclaration | PredicateDefinition | Assertion | ScopeDeclaration; | ||
11 | |||
12 | ClassDeclaration: | ||
13 | abstract?="abstract"? "class" | ||
14 | name=ID | ||
15 | ("extends" (superTypes+=[ClassDeclaration] | | ||
16 | "[" (superTypes+=[ClassDeclaration] ("," superTypes+=[ClassDeclaration])*)? "]") | | ||
17 | referenceDeclarations+=ReferenceDeclaration)? | ||
18 | ("," referenceDeclarations+=ReferenceDeclaration)* | ||
19 | "."; | ||
20 | |||
21 | ReferenceDeclaration: | ||
22 | (containment?="contains" | "refers") | ||
23 | referenceType=[ClassDeclaration] | ||
24 | "[" multiplicity=Multiplicity "]" | ||
25 | name=ID | ||
26 | ("opposite" opposite=[ReferenceDeclaration|QualifiedName])?; | ||
27 | |||
28 | PredicateDefinition: | ||
29 | (error?="error" "pred"? | "pred") | ||
30 | name=ID | ||
31 | "(" (parameters+=Parameter ("," parameters+=Parameter)*)? ")" | ||
32 | (":=" bodies+=Conjunction (";" bodies+=Conjunction)*)? | ||
33 | "."; | ||
34 | |||
35 | Parameter: | ||
36 | parameterType=[ClassDeclaration] name=ID; | ||
37 | |||
38 | Conjunction: | ||
39 | literals+=Literal ("," literals+=Literal)*; | ||
40 | |||
41 | Literal: | ||
42 | Atom | NegativeLiteral; | ||
43 | |||
44 | NegativeLiteral: | ||
45 | "!" atom=Atom; | ||
46 | |||
47 | Atom: | ||
48 | relation=[Relation|QualifiedName] | ||
49 | transitiveClosure?="+"? | ||
50 | "(" (arguments+=[Variable] ("," arguments+=[Variable])*)? ")"; | ||
51 | |||
52 | Assertion: | ||
53 | (relation=[Relation|QualifiedName] | ||
54 | "(" (arguments+=[Node|QualifiedName] ("," arguments+=[Node|QualifiedName])*)? ")" | ||
55 | ":" value=LogicValue | | ||
56 | value=ShortLogicValue? | ||
57 | relation=[Relation|QualifiedName] | ||
58 | "(" (arguments+=[Node|QualifiedName] ("," arguments+=[Node|QualifiedName])*)? ")") | ||
59 | "."; | ||
60 | |||
61 | enum LogicValue: | ||
62 | TRUE="true" | FALSE="false" | UNKNOWN="unknown"; | ||
63 | |||
64 | enum ShortLogicValue returns LogicValue: | ||
65 | FALSE="!" | UNKNOWN="?"; | ||
66 | |||
67 | ScopeDeclaration: | ||
68 | "scope" typeScopes+=TypeScope ("," typeScopes+=TypeScope)* "."; | ||
69 | |||
70 | TypeScope: | ||
71 | targetType=[ClassDeclaration] | ||
72 | (increment?="+=" | "=") | ||
73 | multiplicity=Multiplicity; | ||
74 | |||
75 | Multiplicity: | ||
76 | RangeMultiplicity | ExactMultiplicity; | ||
77 | |||
78 | RangeMultiplicity: | ||
79 | lowerBound=INT ".." upperBound=UpperBound; | ||
80 | |||
81 | ExactMultiplicity: | ||
82 | exactValue=INT; | ||
83 | |||
84 | UpperBound returns ecore::EInt: | ||
85 | INT | "*"; | ||
86 | |||
87 | QualifiedName: | ||
88 | ID ("::" ID)*; | ||