aboutsummaryrefslogtreecommitdiffstats
path: root/Application/org.eclipse.viatra.solver.language/src/org/eclipse/viatra/solver/language/SolverLanguage.xtext
diff options
context:
space:
mode:
Diffstat (limited to 'Application/org.eclipse.viatra.solver.language/src/org/eclipse/viatra/solver/language/SolverLanguage.xtext')
-rw-r--r--Application/org.eclipse.viatra.solver.language/src/org/eclipse/viatra/solver/language/SolverLanguage.xtext154
1 files changed, 154 insertions, 0 deletions
diff --git a/Application/org.eclipse.viatra.solver.language/src/org/eclipse/viatra/solver/language/SolverLanguage.xtext b/Application/org.eclipse.viatra.solver.language/src/org/eclipse/viatra/solver/language/SolverLanguage.xtext
new file mode 100644
index 00000000..17a329ad
--- /dev/null
+++ b/Application/org.eclipse.viatra.solver.language/src/org/eclipse/viatra/solver/language/SolverLanguage.xtext
@@ -0,0 +1,154 @@
1grammar org.eclipse.viatra.solver.language.SolverLanguage with org.eclipse.xtext.common.Terminals
2import "http://www.eclipse.org/emf/2002/Ecore" as ecore
3generate solverLanguage "http://www.eclipse.org/viatra/solver/language/SolverLanguage"
4
5Problem:
6 statements+=Statement*;
7Statement: Interpretation | Predicate;
8
9@Override terminal STRING returns ecore::EString: '"' ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|'"') )* '"';
10REALLiteral returns ecore::EBigDecimal: '-'? INT '.' INT;
11INTLiteral returns ecore::EInt: '-'? INT;
12BooleanValue: {BooleanTrue} 'true' | 'false' {BooleanFalse};
13TruthValue: {True} 'true' | {False} 'false' | {Unknown} 'unknown' | {Error} 'error' ;
14
15
16///////////////////
17// Core grammar
18///////////////////
19Interpretation: BasicInterpretation | DefaultInterpretation | CDInterpretation;
20
21BasicInterpretation: symbol=Symbol '(' objects+=ComplexObject* ')' ':' value = TruthValue;
22
23Symbol: ModelSymbol | PartialitySymbol | DataSymbol;
24
25ModelSymbol: name = ID;
26
27PartialitySymbol: ExistSymbol | EqualsSymbol;
28ExistSymbol:'exists'{ExistSymbol};
29EqualsSymbol:'equals' {EqualsSymbol};
30
31DataSymbol: BooleanSymbol | IntegerSymbol | RealSymbol | StringSymbol;
32BooleanSymbol:'bool' {BooleanSymbol};
33IntegerSymbol:'int' {IntegerSymbol};
34RealSymbol: 'real' {RealSymbol};
35StringSymbol:'string' {StringSymbol};
36
37ComplexObject: Object | AllInstances | AllObjects;
38
39Object: NamedObject | UnnamedObject | DataObject;
40NamedObject: "'" name = ID "'";
41UnnamedObject: name = ID;
42DataObject: BooleanObject | IntObject | RealObject | StringObject;
43BooleanObject: value = BooleanValue;
44IntObject: value = INTLiteral;
45RealObject: value = REALLiteral;
46StringObject: value = STRING;
47
48///////////////////
49// Predicte grammar
50///////////////////
51Predicate: PredicateSymbol | ErrorPredicate;
52PredicateSymbol:
53 'predicate' symbol = ModelSymbol '(' parameters += Parameter* ')' ':' ('false' | (bodies += PatternBody ('|' bodies += PatternBody)*)) '.'
54;
55ErrorPredicate:
56 {ErrorPredicate} 'error' (name = ID)? ('(' parameters += Parameter* ')') ':' ('false' | (bodies += PatternBody ('|' bodies += PatternBody)*)) '.'
57;
58
59Parameter: variable = Variable (':' type = Symbol)?;
60PatternBody: {PatternBody} ('true' | constraints += Constraint*) ;
61Polarity: {Positive} '+' | {Negative} '-';
62Constraint: (polarity = Polarity)? symbol = ModelSymbol (
63 ( '(' params += Literal* ')') | (closureType = ClosureType '(' params += Literal params += Literal ')'));
64
65ClosureType: {ReflexiveClosure} '*' | {IrreflexiveClosure} '+';
66Literal: Variable | DataObject;
67Variable: name = ID;
68
69///////////////////
70// Complex Interpretation grammar
71///////////////////
72
73AllInstances: ':' symbol = Symbol;
74AllObjects: {AllObjects} '*';
75
76///////////////////
77// Defaul Interpretation grammar
78///////////////////
79DefaultInterpretation: 'default' interpretation = BasicInterpretation;
80
81///////////////////
82// Advanced Class-Diagram interpretations
83///////////////////
84CDInterpretation: ClassInterpretation | EnumInterpretation| GlobalRelationInterpretation;
85ClassInterpretation:
86 abstract?='abstract' 'class' symbol = ModelSymbol ('extends' supertypes += ModelSymbol+)?'{'
87 fielt += FieldRelationInterpretation*
88 '}'
89;
90EnumInterpretation: 'enum' Symbol = ModelSymbol '{' objects+=NamedObject+ '}';
91FieldRelationInterpretation: containment ?= 'containment' symbol = ModelSymbol ':' multiplicity = MultiplicityDefinition? target = Symbol;
92GlobalRelationInterpretation: containment ?= 'containment' 'relation' symbol = ModelSymbol ':' sourceMultiplicity = MultiplicityDefinition? source = Symbol targetMultiplicity = MultiplicityDefinition? target = Symbol;
93MultiplicityDefinition: lower = INT '..' (upper = INT | unlimitedUpper?='*');
94
95////SymbolIntroduction : Type | GlobalRelation | Predicate;
96////Symbol: Type | Relation | Predicate | Variable | Element;
97//
98//////////////////////
99//// Types
100//////////////////////
101//
102//Type: TypeDeclaration | /*TypeDefinition |*/ TypeEnumeration;
103//
104//TypeDeclaration:
105// abstract?= 'abstract' 'class' name = ID ('extends' supertypes += [Type] (',' supertypes += [Type])) '{'
106// fieldDeclarations += FieldRelationDeclaration*
107// '}'
108//;
109//TypeEnumeration:
110// 'enum' name = ID 'extends' supertypes += [Type] (',' supertypes += [Type]) '{'
111// (elements += Element)*
112// '}'
113//;
114//Element:
115// name = ID
116//;
117//
118//////////////////////
119//// Relations
120//////////////////////
121//
122//Relation: FieldRelationDeclaration | GlobalRelationDeclaration | RelationEnumeration;
123//GlobalRelation returns Relation: GlobalRelationDeclaration | /*RelationDefinition |*/ RelationEnumeration;
124//
125//FieldRelationDeclaration:
126// containment?='containment' target = [Type] name = ID
127//;
128//
129//GlobalRelationDeclaration:
130// containment?='containment' 'relation' name = ID '(' source = [Type] ',' target = [Type] ')'
131//;
132//
133//RelationEnumeration:
134// 'relation' name = ID '{' links += Link* '}'
135//;
136//
137//Link: '(' source = Element ',' target = Element ')';
138//
139//
140//
141//
142//
143//
144//Model:
145// 'model' '{'
146// atoms += Atom (',' atoms += Atom )
147// '}'
148//;
149//Atom: referredSymbol = [Symbol] '(' (params += Element (',' params += Element)*)? ')';
150//
151//ScopeDeclaration:
152// 'scope'
153//;
154//