Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/Config.xtext')
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/Config.xtext166
1 files changed, 146 insertions, 20 deletions
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/Config.xtext b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/Config.xtext
index 2cfed9ee6..9a0499fe9 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/Config.xtext
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/Config.xtext
@@ -1,30 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Juergen Haug and Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
grammar org.eclipse.etrice.core.Config with org.eclipse.xtext.common.Terminals
generate config "http://www.eclipse.org/etrice/core/Config"
-
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import 'platform:/resource/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore' as room
-
+/*
+ * Postprocessor:
+ * getActor(Class|Instance)Config()
+ */
ConfigModel:
- actorClassConfigs+=ActorClassConfig*
- actorInstanceConfigs+=ActorInstanceConfig*
- ;
-
-
-ActorClassConfig:
- 'ActorClassConfig' actorClass = [room::ActorClass] '{'
-
- '}'
-;
+ imports+=Import*
+ configElements+=ConfigElement*;
-// ActorInstanceConfig MySS.AR1.AR2 {
-// min = 1
-// max = 5
-// }
+ConfigElement:
+ ActorClassConfig | ActorInstanceConfig;
+ /*
+ * Validation:
+ * duplicates config, attributes
+ */
+ActorClassConfig:
+ 'ActorClassConfig' actor=[room::ActorClass|FQN] '{'
+ attributes+=AttrClassConfig*
+ '}';
+
+ /*
+ * Validation:
+ * duplicates config, attributes
+ * valid instance reference
+ * Proposal:
+ * attributes
+ */
ActorInstanceConfig:
- 'ActorInstanceConfig' /* root=[room::SubSystemClass|FQN] '/' path=RefPath */ '{'
-
- '}'
-; \ No newline at end of file
+ 'ActorInstanceConfig' root=[room::SubSystemClass|FQN] '/' path=RefPath '{'
+ attributes+=AttrInstanceConfig*
+ '}';
+
+ /*
+ * Validation:
+ * correct value type
+ * Proposal:
+ * correct Literal
+ */
+AttrConfig:
+ AttrClassConfig | AttrInstanceConfig;
+
+ /*
+ * Validation:
+ * correct min, max type + available
+ * min <= value <= max
+ * if !value -> min <= attribute.defaultValue <= max
+ *
+ */
+AttrClassConfig:
+ 'attr' attribute=[room::Attribute] ('=' value=Literal)? ('{'
+ (('min' '=' min=NumberLiteral)? &
+ ('max' '=' max=NumberLiteral)?)
+ '}')?;
+
+AttrInstanceConfig:
+ 'attr' attribute=[room::Attribute] ('=' value=Literal)?;
+
+ /*
+ * Proposal:
+ * for ActorInstanceConfig
+ */
+RefPath:
+ refs+=ID ('/' refs+=ID)*;
+
+ // -------------------- from org.eclipse.etrice.core.Room.xtext ---------------
+Import:
+ 'import' (importedNamespace=ImportedFQN 'from' | 'model') importURI=STRING;
+
+ImportedFQN:
+ FQN ('.*')?;
+
+FQN:
+ ID ('.' ID)*;
+
+ // -----------------------------------------------------------------------------
+
+//enum Unit:
+// N|
+// W|
+// S = 's'|
+// KG = 'kg'|
+// M = 'm'|
+// C|
+// NM|
+// RPM|
+// V|
+// A|
+// HZ = 'Hz'|
+// KW
+//;
+
+// Value Types for Attributes
+Literal:
+ BooleanLiteral |
+ NumberLiteral |
+ StringLiteral;
+
+BooleanLiteral:
+ {BooleanLiteral} ('false' | isTrue?='true');
+
+NumberLiteral:
+ IntLiteral | RealLiteral;
+
+RealLiteral:
+ {RealLiteral} value=Real;
+
+IntLiteral:
+ {IntLiteral} value=Integer;
+
+StringLiteral:
+ {StringLiteral} value=STRING;
+
+Integer returns ecore::EInt:
+ SignedInteger | Hexadecimal;
+
+SignedInteger hidden():
+ ('+' | '-')? INT;
+
+Hexadecimal hidden():
+ HEX;
+
+Real returns ecore::EDouble:
+ Decimal | DotDecimal | DecimalDot | DecimalExp ;
+
+Decimal hidden():
+ ('+' | '-')? INT '.' INT;
+
+DotDecimal hidden():
+ ('+' | '-')? '.' INT;
+
+DecimalDot hidden():
+ ('+' | '-')? INT '.';
+
+DecimalExp hidden():
+ ('+' | '-')? INT '.' INT ID ('+' | '-')? INT;
+//DecimalPosExp hidden():
+// ('+' | '-')? INT '.' INT ID;
+terminal HEX:
+ ('0x' | '0X') ('0'..'9' | 'a'..'f' | 'A'..'F')+;

Back to the top