diff options
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguage.xtext')
-rw-r--r-- | Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguage.xtext | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguage.xtext b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguage.xtext new file mode 100644 index 00000000..3d82413f --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/src/hu/bme/mit/inf/dslreasoner/faulttree/components/CftLanguage.xtext | |||
@@ -0,0 +1,82 @@ | |||
1 | grammar hu.bme.mit.inf.dslreasoner.faulttree.components.CftLanguage 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/query/patternlanguage/emf/PatternLanguage" as vql | ||
5 | |||
6 | generate cftLanguage "http://www.bme.hu/mit/inf/dslreasoner/faulttree/components/CftLanguage" | ||
7 | |||
8 | CftModel: | ||
9 | "package" packageName=QualifiedName ";"? | ||
10 | imports+=ImportDeclaration* | ||
11 | (componentDefinitions+=ComponentDefinition | transformationDefinitions+=TransformationDefinition)*; | ||
12 | |||
13 | ImportDeclaration: | ||
14 | "import" importedNamespace=QualifiedNameWithWildcard ";"?; | ||
15 | |||
16 | ComponentDefinition: | ||
17 | "cft" name=ID "{" | ||
18 | (("in" inputEvents+=InputEvent* ";")? & ("out" outputEvents+=[EventDeclaration]* ";")?) | ||
19 | (eventDefinitions+=EventDefinition ";")* | ||
20 | "}"; | ||
21 | |||
22 | EventDeclaration: | ||
23 | InputEvent | EventDefinition; | ||
24 | |||
25 | InputEvent: | ||
26 | name=ID multiple?="[]"?; | ||
27 | |||
28 | EventDefinition: | ||
29 | BasicEventDefinition | GateDefinition; | ||
30 | |||
31 | BasicEventDefinition: | ||
32 | name=ID "lambda" "=" rate=DOULBE; | ||
33 | |||
34 | GateDefinition: | ||
35 | AndGate | OrGate; | ||
36 | |||
37 | AndGate: | ||
38 | name=ID "and" inputEvents+=[EventDeclaration]*; | ||
39 | |||
40 | OrGate: | ||
41 | name=ID "or" inputEvents+=[EventDeclaration]*; | ||
42 | |||
43 | TransformationDefinition: | ||
44 | "transformation" name=ID "{" | ||
45 | mappingDefinitions+=MappingDefinition* | ||
46 | "}"; | ||
47 | |||
48 | MappingDefinition: | ||
49 | topLevel?="toplevel"? "mapping" pattern=[vql::Pattern|QualifiedName] | ||
50 | "(" parameters+=MappingParameter ("," parameters+=MappingParameter)* ")" | ||
51 | (componentInstance=ComponentInstance)? ("{" | ||
52 | ((lookupDefinitions+=LookupDefinition | assignments+=Assignment) ";")* | ||
53 | "}")?; | ||
54 | |||
55 | MappingParameter: | ||
56 | name=ID; | ||
57 | |||
58 | LookupDefinition: | ||
59 | "lookup" mapping=[MappingDefinition] | ||
60 | "(" arguments+=[MappingParameter] ("," arguments+=[MappingParameter])* ")" | ||
61 | "as" name=ID; | ||
62 | |||
63 | Variable: | ||
64 | ComponentInstance | LookupDefinition; | ||
65 | |||
66 | Assignment: | ||
67 | input=EventReference (multiple?="+=" | ":=") output=EventReference; | ||
68 | |||
69 | EventReference: | ||
70 | component=[Variable] "." event=[EventDeclaration]; | ||
71 | |||
72 | ComponentInstance: | ||
73 | "=>" componentType=[ComponentDefinition|QualifiedName] name=ID?; | ||
74 | |||
75 | QualifiedName returns ecore::EString: | ||
76 | ID ("." ID)*; | ||
77 | |||
78 | QualifiedNameWithWildcard returns ecore::EString: | ||
79 | QualifiedName ("." "*")?; | ||
80 | |||
81 | terminal DOULBE returns ecore::EDouble: | ||
82 | ('0'..'9')+ ("." ('0'..'9')+ | ("." ('0'..'9')+)? ("e" | "E") ("+" | "-")? ('0'..'9')+); | ||