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 | 75 |
1 files changed, 47 insertions, 28 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 index 3d82413f..61ab3359 100644 --- 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 | |||
@@ -2,7 +2,8 @@ grammar hu.bme.mit.inf.dslreasoner.faulttree.components.CftLanguage with org.ecl | |||
2 | 2 | ||
3 | import "http://www.eclipse.org/emf/2002/Ecore" as ecore | 3 | import "http://www.eclipse.org/emf/2002/Ecore" as ecore |
4 | import "http://www.eclipse.org/viatra/query/patternlanguage/emf/PatternLanguage" as vql | 4 | import "http://www.eclipse.org/viatra/query/patternlanguage/emf/PatternLanguage" as vql |
5 | 5 | import "http://www.bme.hu/mit/inf/dslreasoner/faulttree/model/ft" as ft | |
6 | import "http://www.bme.hu/mit/inf/dslreasoner/faulttree/model/cft" as cft | ||
6 | generate cftLanguage "http://www.bme.hu/mit/inf/dslreasoner/faulttree/components/CftLanguage" | 7 | generate cftLanguage "http://www.bme.hu/mit/inf/dslreasoner/faulttree/components/CftLanguage" |
7 | 8 | ||
8 | CftModel: | 9 | CftModel: |
@@ -13,35 +14,44 @@ CftModel: | |||
13 | ImportDeclaration: | 14 | ImportDeclaration: |
14 | "import" importedNamespace=QualifiedNameWithWildcard ";"?; | 15 | "import" importedNamespace=QualifiedNameWithWildcard ";"?; |
15 | 16 | ||
16 | ComponentDefinition: | 17 | ComponentDefinition returns cft::ComponentDefinition: |
17 | "cft" name=ID "{" | 18 | "cft" name=ValidId "{" |
18 | (("in" inputEvents+=InputEvent* ";")? & ("out" outputEvents+=[EventDeclaration]* ";")?) | 19 | (("in" inputEvents+=InputEvent* ";")? & ("out" outputEvents+=[cft::EventDeclaration|ValidId]* ";")?) |
19 | (eventDefinitions+=EventDefinition ";")* | 20 | (eventDefinitions+=EventDefinition ";")* |
20 | "}"; | 21 | "}"; |
21 | 22 | ||
22 | EventDeclaration: | 23 | InputEvent returns cft::IntputEvent: |
23 | InputEvent | EventDefinition; | 24 | name=ValidId multiple?="[]"?; |
24 | |||
25 | InputEvent: | ||
26 | name=ID multiple?="[]"?; | ||
27 | 25 | ||
28 | EventDefinition: | 26 | EventDefinition returns cft::EventDefinition: |
29 | BasicEventDefinition | GateDefinition; | 27 | BasicEventDefinition | GateDefinition; |
30 | 28 | ||
31 | BasicEventDefinition: | 29 | BasicEventDefinition returns cft::BasicEventDefinition: |
32 | name=ID "lambda" "=" rate=DOULBE; | 30 | name=ValidId distribution=Distribution; |
31 | |||
32 | Distribution returns ft::Distribution: | ||
33 | ConstantDistribution | ExponentialDistribution; | ||
34 | |||
35 | ConstantDistribution returns ft::ConstantDistribution: | ||
36 | "p" "=" p=Double; | ||
37 | |||
38 | ExponentialDistribution returns ft::ExponentialDistribution: | ||
39 | "lambda" "=" lambda=Double; | ||
33 | 40 | ||
34 | GateDefinition: | 41 | GateDefinition returns cft::GateDefinition: |
35 | AndGate | OrGate; | 42 | AndGateDefinition | OrGateDefinition | KOfMGateDefinition; |
36 | 43 | ||
37 | AndGate: | 44 | AndGateDefinition returns cft::AndGateDefinition: |
38 | name=ID "and" inputEvents+=[EventDeclaration]*; | 45 | name=ValidId "and" inputEvents+=[cft::EventDeclaration|ValidId]*; |
39 | 46 | ||
40 | OrGate: | 47 | OrGateDefinition returns cft::OrGateDefinition: |
41 | name=ID "or" inputEvents+=[EventDeclaration]*; | 48 | name=ValidId "or" inputEvents+=[cft::EventDeclaration|ValidId]*; |
49 | |||
50 | KOfMGateDefinition returns cft::KOfMGateDefinition: | ||
51 | name=ValidId k=INT ("of" m=INT | m=OF_INT) inputEvents+=[cft::EventDeclaration|ValidId]*; | ||
42 | 52 | ||
43 | TransformationDefinition: | 53 | TransformationDefinition: |
44 | "transformation" name=ID "{" | 54 | "transformation" name=ValidId "{" |
45 | mappingDefinitions+=MappingDefinition* | 55 | mappingDefinitions+=MappingDefinition* |
46 | "}"; | 56 | "}"; |
47 | 57 | ||
@@ -49,16 +59,16 @@ MappingDefinition: | |||
49 | topLevel?="toplevel"? "mapping" pattern=[vql::Pattern|QualifiedName] | 59 | topLevel?="toplevel"? "mapping" pattern=[vql::Pattern|QualifiedName] |
50 | "(" parameters+=MappingParameter ("," parameters+=MappingParameter)* ")" | 60 | "(" parameters+=MappingParameter ("," parameters+=MappingParameter)* ")" |
51 | (componentInstance=ComponentInstance)? ("{" | 61 | (componentInstance=ComponentInstance)? ("{" |
52 | ((lookupDefinitions+=LookupDefinition | assignments+=Assignment) ";")* | 62 | ((lookupDefinitions+=LookupDefinition | assignments+=Assignment) ";")* |
53 | "}")?; | 63 | "}")?; |
54 | 64 | ||
55 | MappingParameter: | 65 | MappingParameter: |
56 | name=ID; | 66 | name=ValidId; |
57 | 67 | ||
58 | LookupDefinition: | 68 | LookupDefinition: |
59 | "lookup" mapping=[MappingDefinition] | 69 | "lookup" mapping=[MappingDefinition|QualifiedName] |
60 | "(" arguments+=[MappingParameter] ("," arguments+=[MappingParameter])* ")" | 70 | "(" arguments+=[MappingParameter|ValidId] ("," arguments+=[MappingParameter|ValidId])* ")" |
61 | "as" name=ID; | 71 | "as" name=ValidId; |
62 | 72 | ||
63 | Variable: | 73 | Variable: |
64 | ComponentInstance | LookupDefinition; | 74 | ComponentInstance | LookupDefinition; |
@@ -67,16 +77,25 @@ Assignment: | |||
67 | input=EventReference (multiple?="+=" | ":=") output=EventReference; | 77 | input=EventReference (multiple?="+=" | ":=") output=EventReference; |
68 | 78 | ||
69 | EventReference: | 79 | EventReference: |
70 | component=[Variable] "." event=[EventDeclaration]; | 80 | component=[Variable|ValidId] "." event=[cft::EventDeclaration|ValidId]; |
71 | 81 | ||
72 | ComponentInstance: | 82 | ComponentInstance: |
73 | "=>" componentType=[ComponentDefinition|QualifiedName] name=ID?; | 83 | "=>" componentType=[cft::ComponentDefinition|QualifiedName] name=ID?; |
74 | 84 | ||
75 | QualifiedName returns ecore::EString: | 85 | QualifiedName returns ecore::EString: |
76 | ID ("." ID)*; | 86 | ValidId ("." ValidId)*; |
77 | 87 | ||
78 | QualifiedNameWithWildcard returns ecore::EString: | 88 | QualifiedNameWithWildcard returns ecore::EString: |
79 | QualifiedName ("." "*")?; | 89 | QualifiedName ("." "*")?; |
80 | 90 | ||
81 | terminal DOULBE returns ecore::EDouble: | 91 | ValidId: |
92 | ID | OF_INT; | ||
93 | |||
94 | Double returns ecore::EDouble: | ||
95 | INT | T_DOUBLE; | ||
96 | |||
97 | terminal OF_INT returns ecore::EInt: | ||
98 | "o" "f" ('0'..'9')+; | ||
99 | |||
100 | terminal T_DOUBLE: | ||
82 | ('0'..'9')+ ("." ('0'..'9')+ | ("." ('0'..'9')+)? ("e" | "E") ("+" | "-")? ('0'..'9')+); | 101 | ('0'..'9')+ ("." ('0'..'9')+ | ("." ('0'..'9')+)? ("e" | "E") ("+" | "-")? ('0'..'9')+); |