Skip to content
Snippets Groups Projects
Commit 9dd512d9 authored by René Schöne's avatar René Schöne
Browse files

Split grammar in logical pieces.

- Possible with RelAST 0.2.1
parent 6bff6ff0
No related branches found
No related tags found
No related merge requests found
......@@ -50,20 +50,22 @@ jacocoTestReport {
}
}
task preprocess(type: JavaExec) {
group = 'Build'
main = "-jar"
args = [
def relastFiles = fileTree('src/main/jastadd/') {
include '**/*.relast' }.toList().toArray()
String[] relastArguments = [
"libs/relast.jar",
"./src/main/jastadd/main.relast",
"--grammarName=./src/main/jastadd/mainGen",
"--useJastAddNames",
"--listClass=RefList",
"--jastAddList=JastAddList",
"--file"
]
task preprocess(type: JavaExec) {
group = 'Build'
main = "-jar"
args relastArguments + relastFiles
inputs.files file("./src/main/jastadd/main.relast")
inputs.files relastFiles
outputs.files file("./src/main/jastadd/mainGen.ast"), file("./src/main/jastadd/mainGen.jadd")
}
......
// ---------------- Machine Learning Model ------------------------------
MachineLearningRoot ::= [ActivityRecognition:MachineLearningModel] [PreferenceLearning:MachineLearningModel] Activity* ChangeEvent* ;
Activity ::= <Identifier:int> <Label:String> ;
abstract ChangeEvent ::= <Identifier:int> <Timestamp:long> ChangedItem* ;
ChangedItem ::= <NewStateAsString:String> ;
rel ChangedItem.Item -> Item ;
RecognitionEvent : ChangeEvent ;
rel RecognitionEvent.Activity -> Activity ;
ManualChangeEvent : ChangeEvent ;
abstract MachineLearningModel ::= <OutputApplication:DoubleDoubleFunction> ;
abstract ItemPreference ::= ;
rel ItemPreference.Item -> Item ;
ItemPreferenceColor : ItemPreference ::= <PreferredHSB:TupleHSB> ;
ItemPreferenceDouble : ItemPreference ::= <PreferredValue:double> ;
// ---------------- Decision Tree ------------------------------
DecisionTreeRoot : MachineLearningModel ::= RootRule:DecisionTreeRule ;
abstract DecisionTreeElement ::= Preference:ItemPreference*;
abstract DecisionTreeRule : DecisionTreeElement ::= Left:DecisionTreeElement Right:DecisionTreeElement <Label:String> ;
ItemStateCheckRule : DecisionTreeRule ::= ItemStateCheck ;
abstract ItemStateCheck ::= <Comparator:ComparatorType> ;
rel ItemStateCheck.Item -> Item ;
ItemStateNumberCheck : ItemStateCheck ::= <Value:double> ;
ItemStateStringCheck : ItemStateCheck ::= <Value:String> ;
DecisionTreeLeaf : DecisionTreeElement ::= <ActivityIdentifier:int> <Label:String> ;
// ---------------- Neural Network ------------------------------
NeuralNetworkRoot : MachineLearningModel ::= InputNeuron* HiddenNeuron* OutputLayer ;
OutputLayer ::= OutputNeuron* <Combinator:DoubleArrayDoubleFunction> ;
rel OutputLayer.AffectedItem -> Item ;
abstract Neuron ::= Output:NeuronConnection* ;
NeuronConnection ::= <Weight:double> ;
rel NeuronConnection.Neuron <-> Neuron.Input* ;
InputNeuron : Neuron ;
rel InputNeuron.Item -> Item ;
HiddenNeuron : Neuron ::= <ActivationFormula:DoubleArrayDoubleFunction> ;
OutputNeuron : HiddenNeuron ::= <Label:String> ;
DummyMachineLearningModel : MachineLearningModel ::= Current:DecisionTreeLeaf ;
rel DummyMachineLearningModel.Item* -> Item ;
// --- New ECA rules ---
Rule ::= Condition* Action* ;
abstract Condition ;
ItemStateCheckCondition : Condition ::= ItemStateCheck ;
abstract Action ;
LambdaAction : Action ::= <Lambda:Action2EditConsumer> ;
TriggerRuleAction : Action ;
rel TriggerRuleAction.Rule -> Rule ;
abstract SetStateAction : Action ;
rel SetStateAction.AffectedItem -> Item ;
SetStateFromConstantStringAction : SetStateAction ::= <NewState:String> ;
SetStateFromLambdaAction : SetStateAction ::= <NewStateProvider:NewStateProvider> ;
SetStateFromTriggeringItemAction : SetStateAction ::= ;
SetStateFromItemsAction : SetStateAction ::= <Combinator:ItemsToStringFunction> ;
rel SetStateFromItemsAction.SourceItem* -> Item ;
AddDoubleToStateAction : SetStateAction ::= <Increment:double> ;
MultiplyDoubleToStateAction : SetStateAction ::= <Multiplier:double> ;
ItemObserver ::= ;
rel ItemObserver.TriggeredRule* <-> Rule.Observer* ;
......@@ -2,136 +2,12 @@
Root ::= Thing* Group* ThingType* ChannelType* ChannelCategory* ItemCategory* User* MqttRoot InfluxRoot
MachineLearningRoot Rule* ;
// ---------------- openHAB ------------------------------
abstract ModelElement ::= <ID:String> ;
abstract LabelledModelElement : ModelElement ::= <Label:String> ;
abstract DescribableModelElement : LabelledModelElement ::= <Description:String> ;
ThingType : DescribableModelElement ::= Parameter* ;
Thing : LabelledModelElement ::= Channel* ;
ChannelType : DescribableModelElement ::= <ItemType:ItemType> <ReadOnly:boolean> ;
abstract ChannelCategory ;
DefaultChannelCategory : ChannelCategory ::= <Value:DefaultChannelCategoryValue> ;
SimpleChannelCategory : ChannelCategory ::= <Value:String> ;
Channel : ModelElement ::= Link* ;
Link ::= <Item:Item> ;
Parameter : DescribableModelElement ::= <Type:ParameterValueType> [DefaultValue:ParameterDefaultValue] <Context:String> <Required:boolean> ;
ParameterDefaultValue ::= <Value:String> ;
abstract Item : LabelledModelElement ::= <_fetched_data:boolean> MetaData:ItemMetaData* [ItemObserver] ;
ItemMetaData ::= <Key:String> <Value:String> ;
abstract ItemWithBooleanState : Item ::= <_state:boolean> ;
abstract ItemWithStringState : Item ::= <_state:String> ;
abstract ItemWithDoubleState : Item ::= <_state:double> ;
ColorItem : Item ::= <_state:TupleHSB> ;
DateTimeItem : Item ::= <_state:Date> ;
ContactItem : ItemWithBooleanState ;
DimmerItem : ItemWithDoubleState ;
ImageItem : ItemWithStringState ;
LocationItem : ItemWithStringState ;
NumberItem : ItemWithDoubleState ;
PlayerItem : ItemWithStringState ;
RollerShutterItem : ItemWithBooleanState ;
StringItem : ItemWithStringState ;
SwitchItem : ItemWithBooleanState ;
DefaultItem : ItemWithStringState ;
ActivityItem : ItemWithDoubleState ;
ItemCategory ::= <Name:String> ;
Group : LabelledModelElement ::= Group* Item* [AggregationFunction:GroupAggregationFunction] ;
abstract GroupAggregationFunction ;
SimpleGroupAggregationFunction : GroupAggregationFunction ::= <FunctionName:SimpleGroupAggregationFunctionName> ;
ParameterizedGroupAggregationFunction : GroupAggregationFunction ::= <FunctionName:ParameterizedGroupAggregationFunctionName>
<Param1:String> <Param2:String> ;
// ---------------- Users ------------------------------
User : LabelledModelElement ;
rel Root.CurrentUser? -> User ;
// ---------------- Util ------------------------------
ExternalHost ::= <HostName:String> <Port:int> ;
// ---------------- MQTT ------------------------------
MqttRoot ::= Topic:MqttTopic* <IncomingPrefix:String> <OutgoingPrefix:String> [Host:ExternalHost] ;
MqttTopic ::= <Part:String> SubTopic:MqttTopic* ;
// ---------------- InfluxDB ------------------------------
InfluxRoot ::= <User:String> <Password:String> <DbName:String> [Host:ExternalHost] ;
// ---------------- Machine Learning Model ------------------------------
MachineLearningRoot ::= [ActivityRecognition:MachineLearningModel] [PreferenceLearning:MachineLearningModel] Activity* ChangeEvent* ;
Activity ::= <Identifier:int> <Label:String> ;
abstract ChangeEvent ::= <Identifier:int> <Timestamp:long> ChangedItem* ;
ChangedItem ::= <NewStateAsString:String> ;
RecognitionEvent : ChangeEvent ;
ManualChangeEvent : ChangeEvent ;
abstract MachineLearningModel ::= <OutputApplication:DoubleDoubleFunction> ;
abstract ItemPreference ::= ;
ItemPreferenceColor : ItemPreference ::= <PreferredHSB:TupleHSB> ;
ItemPreferenceDouble : ItemPreference ::= <PreferredValue:double> ;
// ---------------- Decision Tree ------------------------------
DecisionTreeRoot : MachineLearningModel ::= RootRule:DecisionTreeRule ;
abstract DecisionTreeElement ::= Preference:ItemPreference*;
abstract DecisionTreeRule : DecisionTreeElement ::= Left:DecisionTreeElement Right:DecisionTreeElement <Label:String> ;
ItemStateCheckRule : DecisionTreeRule ::= ItemStateCheck ;
abstract ItemStateCheck ::= <Comparator:ComparatorType> ;
ItemStateNumberCheck : ItemStateCheck ::= <Value:double> ;
ItemStateStringCheck : ItemStateCheck ::= <Value:String> ;
DecisionTreeLeaf : DecisionTreeElement ::= <ActivityIdentifier:int> <Label:String> ;
// ---------------- Neural Network ------------------------------
NeuralNetworkRoot : MachineLearningModel ::= InputNeuron* HiddenNeuron* OutputLayer ;
OutputLayer ::= OutputNeuron* <Combinator:DoubleArrayDoubleFunction> ;
abstract Neuron ::= Output:NeuronConnection* ;
NeuronConnection ::= <Weight:double> ;
InputNeuron : Neuron ;
HiddenNeuron : Neuron ::= <ActivationFormula:DoubleArrayDoubleFunction> ;
OutputNeuron : HiddenNeuron ::= <Label:String> ;
DummyMachineLearningModel : MachineLearningModel ::= Current:DecisionTreeLeaf ;
// --- New ECA rules ---
Rule ::= Condition* Action* ;
abstract Condition ;
ItemStateCheckCondition : Condition ::= ItemStateCheck ;
abstract Action ;
LambdaAction : Action ::= <Lambda:Action2EditConsumer> ;
TriggerRuleAction : Action ;
abstract SetStateAction : Action ;
SetStateFromConstantStringAction : SetStateAction ::= <NewState:String> ;
SetStateFromLambdaAction : SetStateAction ::= <NewStateProvider:NewStateProvider> ;
SetStateFromTriggeringItemAction : SetStateAction ::= ;
SetStateFromItemsAction : SetStateAction ::= <Combinator:ItemsToStringFunction> ;
AddDoubleToStateAction : SetStateAction ::= <Increment:double> ;
MultiplyDoubleToStateAction : SetStateAction ::= <Multiplier:double> ;
ItemObserver ::= ;
// ---------------- Relations ------------------------------
rel ThingType.ChannelType* -> ChannelType ;
rel Thing.Type -> ThingType ;
rel Channel.Type -> ChannelType ;
rel ChannelType.ChannelCategory -> ChannelCategory ;
rel Item.Topic <-> MqttTopic.Item ;
rel Item.Category? -> ItemCategory ;
rel ItemStateCheck.Item -> Item ;
rel NeuronConnection.Neuron <-> Neuron.Input* ;
rel InputNeuron.Item -> Item ;
rel OutputLayer.AffectedItem -> Item ;
rel ItemPreference.Item -> Item ;
rel Item.Controlling* <-> Item.ControlledBy* ;
rel Root.CurrentUser? -> User ;
rel ChangedItem.Item -> Item ;
rel RecognitionEvent.Activity -> Activity ;
rel DummyMachineLearningModel.Item* -> Item ;
rel TriggerRuleAction.Rule -> Rule ;
rel SetStateAction.AffectedItem -> Item ;
rel SetStateFromItemsAction.SourceItem* -> Item ;
rel ItemObserver.TriggeredRule* <-> Rule.Observer* ;
// ---------------- MQTT ------------------------------
MqttRoot ::= Topic:MqttTopic* <IncomingPrefix:String> <OutgoingPrefix:String> [Host:ExternalHost] ;
MqttTopic ::= <Part:String> SubTopic:MqttTopic* ;
rel Item.Topic <-> MqttTopic.Item ;
// ---------------- openHAB ------------------------------
abstract ModelElement ::= <ID:String> ;
abstract LabelledModelElement : ModelElement ::= <Label:String> ;
abstract DescribableModelElement : LabelledModelElement ::= <Description:String> ;
ThingType : DescribableModelElement ::= Parameter* ;
rel ThingType.ChannelType* -> ChannelType ;
Thing : LabelledModelElement ::= Channel* ;
rel Thing.Type -> ThingType ;
ChannelType : DescribableModelElement ::= <ItemType:ItemType> <ReadOnly:boolean> ;
rel ChannelType.ChannelCategory -> ChannelCategory ;
abstract ChannelCategory ;
DefaultChannelCategory : ChannelCategory ::= <Value:DefaultChannelCategoryValue> ;
SimpleChannelCategory : ChannelCategory ::= <Value:String> ;
Channel : ModelElement ::= Link* ;
rel Channel.Type -> ChannelType ;
Link ::= <Item:Item> ;
Parameter : DescribableModelElement ::= <Type:ParameterValueType> [DefaultValue:ParameterDefaultValue] <Context:String> <Required:boolean> ;
ParameterDefaultValue ::= <Value:String> ;
abstract Item : LabelledModelElement ::= <_fetched_data:boolean> MetaData:ItemMetaData* [ItemObserver] ;
rel Item.Category? -> ItemCategory ;
rel Item.Controlling* <-> Item.ControlledBy* ;
abstract ItemWithBooleanState : Item ::= <_state:boolean> ;
abstract ItemWithStringState : Item ::= <_state:String> ;
abstract ItemWithDoubleState : Item ::= <_state:double> ;
ColorItem : Item ::= <_state:TupleHSB> ;
DateTimeItem : Item ::= <_state:Date> ;
ContactItem : ItemWithBooleanState ;
DimmerItem : ItemWithDoubleState ;
ImageItem : ItemWithStringState ;
LocationItem : ItemWithStringState ;
NumberItem : ItemWithDoubleState ;
PlayerItem : ItemWithStringState ;
RollerShutterItem : ItemWithBooleanState ;
StringItem : ItemWithStringState ;
SwitchItem : ItemWithBooleanState ;
DefaultItem : ItemWithStringState ;
ActivityItem : ItemWithDoubleState ;
ItemMetaData ::= <Key:String> <Value:String> ;
ItemCategory ::= <Name:String> ;
Group : LabelledModelElement ::= Group* Item* [AggregationFunction:GroupAggregationFunction] ;
abstract GroupAggregationFunction ;
SimpleGroupAggregationFunction : GroupAggregationFunction ::= <FunctionName:SimpleGroupAggregationFunctionName> ;
ParameterizedGroupAggregationFunction : GroupAggregationFunction ::= <FunctionName:ParameterizedGroupAggregationFunctionName>
<Param1:String> <Param2:String> ;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment