aboutsummaryrefslogtreecommitdiffstats
path: root/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguage.xtext
blob: 3d82413f2e52a8c3bc5d0bb8be3a0ad404361934 (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
grammar hu.bme.mit.inf.dslreasoner.faulttree.components.CftLanguage with org.eclipse.xtext.common.Terminals

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.eclipse.org/viatra/query/patternlanguage/emf/PatternLanguage" as vql

generate cftLanguage "http://www.bme.hu/mit/inf/dslreasoner/faulttree/components/CftLanguage"

CftModel:
	"package" packageName=QualifiedName ";"?
	imports+=ImportDeclaration*
	(componentDefinitions+=ComponentDefinition | transformationDefinitions+=TransformationDefinition)*;

ImportDeclaration:
	"import" importedNamespace=QualifiedNameWithWildcard ";"?;

ComponentDefinition:
	"cft" name=ID "{"
	(("in" inputEvents+=InputEvent* ";")? & ("out" outputEvents+=[EventDeclaration]* ";")?)
	(eventDefinitions+=EventDefinition ";")*
	"}";

EventDeclaration:
	InputEvent | EventDefinition;

InputEvent:
	name=ID multiple?="[]"?;

EventDefinition:
	BasicEventDefinition | GateDefinition;

BasicEventDefinition:
	name=ID "lambda" "=" rate=DOULBE;

GateDefinition:
	AndGate | OrGate;

AndGate:
	name=ID "and" inputEvents+=[EventDeclaration]*;

OrGate:
	name=ID "or" inputEvents+=[EventDeclaration]*;

TransformationDefinition:
	"transformation" name=ID "{"
	mappingDefinitions+=MappingDefinition*
	"}";

MappingDefinition:
	topLevel?="toplevel"? "mapping" pattern=[vql::Pattern|QualifiedName]
	"(" parameters+=MappingParameter ("," parameters+=MappingParameter)* ")"
	(componentInstance=ComponentInstance)? ("{"
		((lookupDefinitions+=LookupDefinition | assignments+=Assignment) ";")*
	"}")?;

MappingParameter:
	name=ID;

LookupDefinition:
	"lookup" mapping=[MappingDefinition]
	"(" arguments+=[MappingParameter] ("," arguments+=[MappingParameter])* ")"
	"as" name=ID;

Variable:
	ComponentInstance | LookupDefinition;

Assignment:
	input=EventReference (multiple?="+=" | ":=") output=EventReference;

EventReference:
	component=[Variable] "." event=[EventDeclaration];

ComponentInstance:
	"=>" componentType=[ComponentDefinition|QualifiedName] name=ID?;

QualifiedName returns ecore::EString:
	ID ("." ID)*;

QualifiedNameWithWildcard returns ecore::EString:
	QualifiedName ("." "*")?;

terminal DOULBE returns ecore::EDouble:
	('0'..'9')+ ("." ('0'..'9')+ | ("." ('0'..'9')+)? ("e" | "E") ("+" | "-")? ('0'..'9')+);