Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/.classpath
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/.classpath	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/.classpath	(revision 5)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="src-gen"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/.project
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/.project	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/.project	(revision 5)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>de.ugoe.cs.swe.bnftools.ebnf.generator</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.dltk.core.scriptbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.xtend.shared.ui.xtendBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+		<nature>org.eclipse.xtend.shared.ui.xtendXPandNature</nature>
+		<nature>org.deved.antlride.core.nature</nature>
+	</natures>
+</projectDescription>
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/.settings/org.eclipse.core.resources.prefs
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/.settings/org.eclipse.core.resources.prefs	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/.settings/org.eclipse.core.resources.prefs	(revision 5)
@@ -0,0 +1,3 @@
+#Sun Aug 22 21:34:57 CEST 2010
+eclipse.preferences.version=1
+encoding/<project>=ISO-8859-1
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/META-INF/MANIFEST.MF
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/META-INF/MANIFEST.MF	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/META-INF/MANIFEST.MF	(revision 5)
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: de.ugoe.cs.swe.bnftools.ebnf.generator
+Bundle-Vendor: Software Engineering for Distributed Systems Group, University of Göttingen
+Bundle-Version: 1.0.0.qualifier
+Bundle-SymbolicName: de.ugoe.cs.swe.bnftools.ebnf.generator;singleton:=true
+Bundle-ActivationPolicy: lazy
+Require-Bundle: de.ugoe.cs.swe.bnftools.ebnf;bundle-version="1.0.0",
+ org.eclipse.xpand;visibility:=reexport,
+ org.eclipse.xtend;visibility:=reexport,
+ org.eclipse.xtext;visibility:=reexport,
+ org.eclipse.emf.mwe2.launch;resolution:=optional,
+ org.eclipse.emf.mwe.utils;visibility:=reexport,
+ org.eclipse.xtend.typesystem.emf;visibility:=reexport,
+ org.eclipse.xtend.util.stdlib;visibility:=reexport,
+ org.eclipse.emf.compare;bundle-version="1.1.0"
+Import-Package: org.apache.log4j
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/build.properties
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/build.properties	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/build.properties	(revision 5)
@@ -0,0 +1,5 @@
+source.. = src/,\
+          src-gen/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/output-samples/hello.xml
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/output-samples/hello.xml	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/output-samples/hello.xml	(revision 5)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!-- fop hello.xml -rtf hello.rtf -->
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ 
+  <fo:layout-master-set>
+    <fo:simple-page-master  master-name="A4" 
+                            page-width="210mm" page-height="297mm">
+      <fo:region-body region-name="xsl-region-body"  margin="2cm"/>
+    </fo:simple-page-master>
+  </fo:layout-master-set>
+ 
+  <fo:page-sequence  master-reference="A4">
+    <fo:flow flow-name="xsl-region-body" font-family="verdana">
+      <fo:block>Rule1 ::= foobar1</fo:block>
+      <fo:block><fo:inline id="Rule2" color="purple">Rule2</fo:inline> ::= Rule1</fo:block>
+      <fo:block>Rule3 ::= foobar2 Rule1 <fo:basic-link internal-destination="Rule2" text-decoration="underline" color="blue">Rule2</fo:basic-link></fo:block>	  
+    </fo:flow>
+  </fo:page-sequence>
+ 
+</fo:root>
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src-gen/newModel.xmi
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src-gen/newModel.xmi	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src-gen/newModel.xmi	(revision 5)
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="ASCII"?>
+<ebnf:EtsiBnf xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ebnf="http://www.ugoe.de/cs/swe/bnftools/Ebnf" xsi:schemaLocation="http://www.ugoe.de/cs/swe/bnftools/Ebnf java://de.ugoe.cs.swe.bnftools.ebnf.EbnfPackage" name="optionalruletest">
+  <rule name="a_gen_124b26c2178a0a2c9806337a77112801dc661a9e_opt">
+    <definitionList>
+      <singleDefinition>
+        <terms>
+          <termAtom>
+            <atomRuleReference>
+              <ruleref href="file:/C:/eclipse/workspaces/development.workspaces/bnftools/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/optionalRuleTest.bnf#//@rule.2"/>
+            </atomRuleReference>
+          </termAtom>
+        </terms>
+      </singleDefinition>
+      <singleDefinition/>
+    </definitionList>
+  </rule>
+  <rule name="a">
+    <definitionList>
+      <singleDefinition>
+        <terms>
+          <termAtom>
+            <atomRuleReference>
+              <ruleref href="file:/C:/eclipse/workspaces/development.workspaces/bnftools/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/optionalRuleTest.bnf#//@rule.1"/>
+            </atomRuleReference>
+          </termAtom>
+        </terms>
+        <terms>
+          <termAtom>
+            <atomRuleReference ruleref="//@rule.0"/>
+          </termAtom>
+        </terms>
+        <terms>
+          <termAtom>
+            <atomRuleReference>
+              <ruleref href="file:/C:/eclipse/workspaces/development.workspaces/bnftools/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/optionalRuleTest.bnf#//@rule.3"/>
+            </atomRuleReference>
+          </termAtom>
+        </terms>
+      </singleDefinition>
+    </definitionList>
+  </rule>
+  <rule name="b">
+    <definitionList>
+      <singleDefinition>
+        <terms>
+          <termAtom>
+            <atomStringRule literal="foo"/>
+          </termAtom>
+        </terms>
+      </singleDefinition>
+    </definitionList>
+  </rule>
+  <rule name="c">
+    <definitionList>
+      <singleDefinition>
+        <terms>
+          <termAtom>
+            <atomStringRule literal="midfoo"/>
+          </termAtom>
+        </terms>
+      </singleDefinition>
+    </definitionList>
+  </rule>
+  <rule name="d">
+    <definitionList>
+      <singleDefinition>
+        <terms>
+          <termAtom>
+            <atomStringRule literal="bar"/>
+          </termAtom>
+        </terms>
+      </singleDefinition>
+    </definitionList>
+  </rule>
+</ebnf:EtsiBnf>
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src-gen/optionalruletest.grm
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src-gen/optionalruletest.grm	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src-gen/optionalruletest.grm	(revision 5)
@@ -0,0 +1,13 @@
+"Name"		= 'optionalruletest'
+"Version"	= '1.0'
+"Author"	= 'BNFTools EBnf Gold Generator'
+"About"		= 'n/a'
+
+"Case Sensitive" = 'True' 
+"Start Symbol"   = <a>
+
+<a_gen_124b26c2178a0a2c9806337a77112801dc661a9e_opt> ::= <c> |
+<a> ::= <b> <a_gen_124b26c2178a0a2c9806337a77112801dc661a9e_opt> <d>
+<b> ::= 'foo'
+<c> ::= 'midfoo'
+<d> ::= 'bar'
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/de/ugoe/cs/swe/bnftools/ebnf/javaextensions/SimpleBNFHelper.java
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/de/ugoe/cs/swe/bnftools/ebnf/javaextensions/SimpleBNFHelper.java	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/de/ugoe/cs/swe/bnftools/ebnf/javaextensions/SimpleBNFHelper.java	(revision 5)
@@ -0,0 +1,161 @@
+package de.ugoe.cs.swe.bnftools.ebnf.javaextensions;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.emf.compare.util.ModelUtils;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList;
+import de.ugoe.cs.swe.bnftools.ebnf.Rule;
+
+public class SimpleBNFHelper {
+
+	private static HashMap<String, Rule> ruleMap = new HashMap<String, Rule>();
+//	private static HashMap<String, Integer> indexMap = new HashMap<String, Integer>();
+	
+	public final static void dump(String aString) {
+		System.out.println(aString);
+	}
+
+	// ----------------------------------------------------------------------
+
+	public final static String definitionListToString(DefinitionList defList) {
+		return "hello";
+	}
+	
+	// ----------------------------------------------------------------------
+	
+	public final static String listToString(List<EObject> defList) {
+		if (defList == null)
+			return "***Java:listToString(List<EObject>defList: defList is null!!!***";
+		if (defList.size() == 0)
+			return "***Java:listToString(List<EObject>defList: defList is empty!!!***";
+		
+		try {
+			StringBuffer strBuf = new StringBuffer();
+			for (int i = 0; i < defList.size(); i++) {
+				strBuf.append(ModelUtils.serialize(defList.get(i)));
+			}
+
+//			return strBuf.toString().replaceAll("[ \t\n\r]", "");
+			return strBuf.toString();
+		} catch (IOException e) {
+			return "***listToString(List<EObject>defList: IOException***";
+		}
+	}
+
+	// ----------------------------------------------------------------------
+	
+	public final static String eobjectToString(EObject o) {
+		try {
+			StringBuffer strBuf = new StringBuffer();
+			strBuf.append(ModelUtils.serialize(o));
+
+//			return strBuf.toString().replaceAll("[ \t\n\r]", "");
+			return strBuf.toString();
+		} catch (IOException e) {
+			return "***listToString(List<EObject>defList: IOException***";
+		}
+	}
+
+	
+	// ----------------------------------------------------------------------
+	
+	public final static String listToHash(List<EObject> defList) {
+		if (defList == null)
+			return "***Java:listToHash(List<EObject>defList: defList is null!!!***";
+		if (defList.size() == 0)
+			return "***Java:listToHash(List<EObject>defList: defList is empty!!!***";
+		
+		try {
+			StringBuffer strBuf = new StringBuffer();
+			for (int i = 0; i < defList.size(); i++) {
+				strBuf.append(ModelUtils.serialize(defList.get(i)));
+			}
+
+			String result = SHA1(strBuf.toString());
+			return SHA1(result);
+		} catch (IOException e) {
+			return "***Java:listToHash(List<EObject>defList: IOException***";
+		} catch (NoSuchAlgorithmException e) {
+			return "***Java:listToHash(List<EObject>defList: NoSuchAlgorithmException***";
+		}
+	}
+
+	// ----------------------------------------------------------------------
+	
+	public final static void storeRule(String key, Rule rule) {
+		ruleMap.put(key, rule);
+	}
+
+	// ----------------------------------------------------------------------
+	
+	public final static Boolean existsRule(String key) {
+		if (ruleMap.get(key) != null)
+			return true;
+		else
+			return false;
+	}
+	
+	// ----------------------------------------------------------------------
+
+	public final static Rule getRule(String key) {
+		return ruleMap.get(key);
+	}
+
+	// ----------------------------------------------------------------------
+
+	public final static EObject copyEObject(EObject o) {
+		return EcoreUtil.copy(o);
+	}
+
+	// ----------------------------------------------------------------------
+
+	public final static List<EObject> copyEObjectList(List<EObject> o) {
+		return (List<EObject>) EcoreUtil.copyAll(o);
+	}
+
+	// ----------------------------------------------------------------------
+
+	public final static List<DefinitionList> copyDefinitionList(List<DefinitionList> o) {
+		return (List<DefinitionList>) EcoreUtil.copyAll(o);
+	}
+	
+	// ----------------------------------------------------------------------
+
+	private static String convertToHex(byte[] data) {
+		StringBuffer buf = new StringBuffer();
+		for (int i = 0; i < data.length; i++) {
+			int halfbyte = (data[i] >>> 4) & 0x0F;
+			int two_halfs = 0;
+			do {
+				if ((0 <= halfbyte) && (halfbyte <= 9))
+					buf.append((char) ('0' + halfbyte));
+				else
+					buf.append((char) ('a' + (halfbyte - 10)));
+				halfbyte = data[i] & 0x0F;
+			} while (two_halfs++ < 1);
+		}
+		return buf.toString();
+	}
+
+	// ----------------------------------------------------------------------
+
+	private static String SHA1(String text) throws NoSuchAlgorithmException,
+			UnsupportedEncodingException {
+		MessageDigest md;
+		md = MessageDigest.getInstance("SHA-1");
+		byte[] sha1hash = new byte[40];
+		md.update(text.getBytes("iso-8859-1"), 0, text.length());
+		sha1hash = md.digest();
+		return convertToHex(sha1hash);
+	}
+
+}
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/extensions/SimpleBnf.ext
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/extensions/SimpleBnf.ext	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/extensions/SimpleBnf.ext	(revision 5)
@@ -0,0 +1,297 @@
+import ebnf;
+import emf;
+
+create List transform(List s):
+	this.addAll(s.typeSelect(EtsiBnf).createEtsiBnf())
+;
+
+create EtsiBnf createEtsiBnf(EtsiBnf bnf):
+//	corebnf.addAll(bnf.corebnf)-> //TODO: checken, ob auskommentierung sinnvoll war
+	extRule.addAll(bnf.extRule)->
+	imports.addAll(bnf.imports)->
+	mergeRule.addAll(bnf.mergeRule)->
+//	package.addAll(bnf.package)-> //TODO: checken, ob auskommentierung sinnvoll war
+	rule.addAll(bnf.rule.createRule(this))->
+	setName(bnf.name)
+;
+
+create Rule createRule(Rule r, EtsiBnf bnf):
+	setName(r.name)->
+	r.definitionList.singleDefinition.size > 0 ? setDefinitionList(r.definitionList.createDefinitionList(bnf, this)) : null->
+	setRulenumber(r.rulenumber)->
+	setRulevariant(r.rulevariant)
+;
+
+create DefinitionList createDefinitionList(DefinitionList d, EtsiBnf bnf, Rule refRule):
+	setSingleDefinition(d.singleDefinition.createSingleDefinition(bnf, refRule))
+;
+
+create SingleDefinition createSingleDefinition(SingleDefinition s, EtsiBnf bnf, Rule refRule):
+	let termsList = {}:
+	s.terms.processTerms(termsList, bnf, refRule)->
+	setTerms(termsList)
+;
+
+create SingleDefinition createSingleDefinitionLeftRepetition(SingleDefinition s, Rule repeatRule, EtsiBnf bnf, Rule refRule, String id):
+	let termsList = {}:
+	termsList.add(createRuleReferenceTerm(repeatRule, id))->
+	s.terms.processTerms(termsList, bnf, refRule)->
+	setTerms(termsList)
+;
+
+create Atom createAtom(Atom a, EtsiBnf bnf, Rule refRule):
+	a.atomStringRule != null ? setAtomStringRule(a.atomStringRule) : null->
+	a.atomRuleReference != null ? setAtomRuleReference(a.atomRuleReference) : null
+;
+
+create GroupedSequence createGroupedSequence(GroupedSequence g, EtsiBnf bnf, Rule refRule):
+	setDefinitionList(g.definitionList)
+;
+
+create OptionalSequence createOptionalSequence(OptionalSequence g, EtsiBnf bnf, Rule refRule):
+	setDefinitionList(g.definitionList)
+;
+
+create RepeatedSequence createRepeatedSequence(RepeatedSequence r, EtsiBnf bnf, Rule refRule):
+	setDefinitions(r.definitions)->
+	setMorethanonce(r.morethanonce)
+;
+
+// ----------------------------------------------------------------------------------------------------
+// non-create rules
+// ----------------------------------------------------------------------------------------------------
+
+Term processTerms(Term t, List termsList, EtsiBnf bnf, Rule refRule):
+	let newTerm = new Term:
+	t.termAtom != null ? newTerm.setTermAtom(t.termAtom.createAtom(bnf, refRule)) : null->
+	t.termAtom != null ? termsList.add(newTerm) : null->
+	t.termGroupedSequence != null ? processGroupedSequence(t.termGroupedSequence, bnf, refRule, termsList) : null->
+	t.termOptionalSequence != null ? processOptionalSequence(t.termOptionalSequence, bnf, refRule, termsList) : null->
+	t.termRepeatedSequence != null ? processRepeatedSequence(t.termRepeatedSequence, bnf, refRule, termsList) : null
+;
+
+GroupedSequence processGroupedSequence(GroupedSequence o, EtsiBnf bnf, Rule refRule, List termsList):
+	listToHash(o.definitionList).existsRule() ? insertRuleReferenceInTermsList(getReplacementRule(refRule, o, bnf), termsList) : insertRuleReferenceInTermsList(addGroupedSequenceReplacementRule(refRule, o, bnf), termsList)
+;
+
+OptionalSequence processOptionalSequence(OptionalSequence o, EtsiBnf bnf, Rule refRule, List termsList):
+	listToHash(o.definitionList).existsRule() ? insertRuleReferenceInTermsList(getReplacementRule(refRule, o, bnf), termsList) : insertRuleReferenceInTermsList(addOptionalSequenceReplacementRule(refRule, o, bnf), termsList)
+;
+
+OptionalSequence processRepeatedSequence(RepeatedSequence o, EtsiBnf bnf, Rule refRule, List termsList):
+	listToHash(o.definitions).existsRule() ? insertRuleReferenceInTermsList(getReplacementRule(refRule, o, bnf), termsList) : insertRuleReferenceInTermsList(addRepeatedSequenceReplacementRule(refRule, o, bnf), termsList)
+;
+
+Rule getReplacementRule(Rule superRule, GroupedSequence o, EtsiBnf bnf):
+	getRule(listToHash(o.definitionList))
+;
+
+Rule getReplacementRule(Rule superRule, OptionalSequence o, EtsiBnf bnf):
+	getRule(listToHash(o.definitionList))
+;
+
+Rule getReplacementRule(Rule superRule, RepeatedSequence o, EtsiBnf bnf):
+	getRule(listToHash(o.definitions))
+;
+
+Rule addRepeatedSequenceReplacementRule(Rule superRule, RepeatedSequence o, EtsiBnf bnf):
+	let repetitionRule = addRepeatedSequenceReplacementRuleWithRepetition(superRule, o, bnf):
+	let plainRule = addRepeatedSequenceReplacementRuleWithoutRepetition(superRule, o, bnf):
+	let mainRule = addRepeatedSequenceReplacementRuleMain(superRule, plainRule, repetitionRule, o, bnf):
+	let hashValue = listToHash(o.definitions):
+	o.morethanonce ? addMoreThanOnceRepetitionRules(repetitionRule, plainRule, mainRule, bnf, hashValue): addNormalRepetitionRule(repetitionRule, bnf, hashValue)
+;
+
+Rule addNormalRepetitionRule(Rule repetitionRule, EtsiBnf bnf, String hashValue):
+	bnf.rule.add(repetitionRule)->
+	storeRule(hashValue, repetitionRule)->
+	repetitionRule
+;
+
+Rule addMoreThanOnceRepetitionRules(Rule repetitionRule, Rule plainRule, Rule mainRule, EtsiBnf bnf, String hashValue):
+	bnf.rule.add(repetitionRule)->
+	bnf.rule.add(plainRule)->
+	bnf.rule.add(mainRule)->
+	storeRule(hashValue, mainRule)->
+	mainRule
+;
+
+create Rule addRepeatedSequenceReplacementRuleWithRepetition(Rule superRule, RepeatedSequence o, EtsiBnf bnf):
+	let emptySingleDefinition = new SingleDefinition:
+	let newDefinitionList = new DefinitionList:
+	let singleDefinitions = {}:
+	let hashValue = listToHash(o.definitions):
+	let rsCopy = new RepeatedSequence:
+	rsCopy.setDefinitions(copyEObjectList(o.definitions))->
+	rsCopy.setMorethanonce(o.morethanonce)->
+	setName(superRule.name + "_gen_" + hashValue + "_rep")->
+	singleDefinitions.addAll(rsCopy.definitions.singleDefinition.createSingleDefinitionLeftRepetition(this, bnf, superRule, this.name))->
+	singleDefinitions.add(emptySingleDefinition)->
+	newDefinitionList.setSingleDefinition(singleDefinitions)->
+	setDefinitionList(newDefinitionList)
+;
+
+create Rule addRepeatedSequenceReplacementRuleWithoutRepetition(Rule superRule, RepeatedSequence o, EtsiBnf bnf):
+	let singleDefinitions = {}:
+	let newDefinitionList = new DefinitionList:
+	let hashValue = listToHash(o.definitions):
+	let rsCopy = new RepeatedSequence:
+	rsCopy.setDefinitions(copyEObjectList(o.definitions))->
+	rsCopy.setMorethanonce(o.morethanonce)->
+	setName(superRule.name + "_gen_" + hashValue + "_plain")->
+	singleDefinitions.addAll(rsCopy.definitions.singleDefinition.createSingleDefinition(bnf, superRule))->
+	newDefinitionList.setSingleDefinition(singleDefinitions)->
+	setDefinitionList(newDefinitionList)
+;
+
+create Rule this addRepeatedSequenceReplacementRuleMain(Rule superRule, Rule plainRule, Rule repetitionRule, RepeatedSequence o, EtsiBnf bnf):
+	let newDefinitionList = new DefinitionList:
+	let singleDefinitionList = {}:
+	let singleDefinition = new SingleDefinition:
+	let definitionsList = {}:
+	let hashValue = listToHash(o.definitions):
+	this.setName(superRule.name + "_gen_" + hashValue + "_main")->
+	singleDefinition.terms.add(plainRule.createRuleReferenceTerm(this.name))->
+	singleDefinition.terms.add(repetitionRule.createRuleReferenceTerm(this.name))->
+	newDefinitionList.singleDefinition.add(singleDefinition)->	
+	this.setDefinitionList(newDefinitionList)	
+;
+
+create Term this createRuleReferenceTerm(Rule rule, String id):
+	let newAtom = new Atom:
+	let newRuleReference = new RuleReference:
+	newRuleReference.setRuleref(rule)->
+	newAtom.setAtomRuleReference(newRuleReference)->
+	this.setTermAtom(newAtom)	
+;
+
+create SingleDefinition createRuleReferenceSingleDefinition(Rule rule, String id):
+	let newTerms = {}:
+	newTerms.add(createRuleReferenceTerm(rule, id))->
+	setTerms(newTerms)	
+;
+
+create Rule addGroupedSequenceReplacementRule(Rule superRule, GroupedSequence o, EtsiBnf bnf):
+	let newDefinitionList = new DefinitionList:
+	let singleDefinitions = {}:
+	let hashValue = listToHash(o.definitionList):
+	setName(superRule.name + "_gen_" + hashValue + "_group")->
+	singleDefinitions.addAll(o.definitionList.singleDefinition.createSingleDefinition(bnf, superRule))->
+	newDefinitionList.setSingleDefinition(singleDefinitions)->
+	setDefinitionList(newDefinitionList)->	
+	storeRule(hashValue, this)->
+	bnf.rule.add(this)
+;
+
+create Rule addOptionalSequenceReplacementRule(Rule superRule, OptionalSequence o, EtsiBnf bnf):
+	let newDefinitionList = new DefinitionList:
+	let emptySingleDefinition = new SingleDefinition:
+	let singleDefinitions = {}:
+	let hashValue = listToHash(o.definitionList):
+	setName(superRule.name + "_gen_" + hashValue + "_opt")->
+	singleDefinitions.addAll(o.definitionList.singleDefinition.createSingleDefinition(bnf, superRule))->
+	singleDefinitions.add(emptySingleDefinition)->
+	newDefinitionList.setSingleDefinition(singleDefinitions)->
+	setDefinitionList(newDefinitionList)->	
+	storeRule(hashValue, this)->
+	bnf.rule.add(this)
+;
+
+Void insertRuleReferenceInTermsList(Rule refRule, List termsList):
+	let newTerm = new Term: 
+	let newRuleRef = new RuleReference:
+	let newAtom = new Atom: 
+	newRuleRef.setRuleref(refRule)->
+	newAtom.setAtomRuleReference(newRuleRef)->
+	newTerm.setTermAtom(newAtom)->
+	termsList.add(newTerm)
+;
+
+// ----------------------------------------------------------------------------------------------------
+// Java Extensions
+// ----------------------------------------------------------------------------------------------------
+
+Void dump(String s):
+	JAVA de.ugoe.cs.swe.bnftools.ebnf.javaextensions.SimpleBNFHelper.dump(java.lang.String)
+;
+
+String definitionListToString(DefinitionList l):
+	JAVA de.ugoe.cs.swe.bnftools.ebnf.javaextensions.SimpleBNFHelper.definitionListToString(de.ugoe.cs.swe.bnftools.ebnf.DefinitionList)
+;
+
+String listToString(List l):
+	JAVA de.ugoe.cs.swe.bnftools.ebnf.javaextensions.SimpleBNFHelper.listToString(java.util.List)
+;
+
+String listToString(EObject l):
+	JAVA de.ugoe.cs.swe.bnftools.ebnf.javaextensions.SimpleBNFHelper.eobjectToString(org.eclipse.emf.ecore.EObject)
+;
+
+String listToHash(List l):
+	JAVA de.ugoe.cs.swe.bnftools.ebnf.javaextensions.SimpleBNFHelper.listToHash(java.util.List)
+;
+
+Void storeRule(String k, Rule r):
+	JAVA de.ugoe.cs.swe.bnftools.ebnf.javaextensions.SimpleBNFHelper.storeRule(java.lang.String, de.ugoe.cs.swe.bnftools.ebnf.Rule)
+;
+
+Boolean existsRule(String s):
+	JAVA de.ugoe.cs.swe.bnftools.ebnf.javaextensions.SimpleBNFHelper.existsRule(java.lang.String)
+;
+
+Rule getRule(String s):
+	JAVA de.ugoe.cs.swe.bnftools.ebnf.javaextensions.SimpleBNFHelper.getRule(java.lang.String)
+;
+
+EObject copyEObject(EObject o):
+	JAVA de.ugoe.cs.swe.bnftools.ebnf.javaextensions.SimpleBNFHelper.copyEObject(org.eclipse.emf.ecore.EObject)
+;
+
+List copyEObjectList(List l):
+	JAVA de.ugoe.cs.swe.bnftools.ebnf.javaextensions.SimpleBNFHelper.copyEObjectList(java.util.List)
+;
+
+// ----------------------------------------------------------------------------------------------------
+// duplication rules
+// ----------------------------------------------------------------------------------------------------
+
+create DefinitionList duplicateDefinitionList(DefinitionList d, EtsiBnf bnf, Rule refRule):
+	setSingleDefinition(d.singleDefinition.duplicateSingleDefinition(bnf, refRule))
+;
+
+create SingleDefinition duplicateSingleDefinition(SingleDefinition s, EtsiBnf bnf, Rule refRule):
+	setTerms(s.terms.duplicateTerms(bnf, refRule))
+;
+
+create Term duplicateTerms(Term t, EtsiBnf bnf, Rule refRule):
+	t.termAtom != null ? setTermAtom(t.termAtom.duplicateAtom(bnf, refRule)) : null->
+	t.termGroupedSequence != null ? setTermGroupedSequence(t.termGroupedSequence.duplicateGroupedSequence(bnf, refRule)) : null->
+	t.termOptionalSequence != null ? setTermOptionalSequence(t.termOptionalSequence.duplicateOptionalSequence(bnf, refRule)) : null->
+	t.termRepeatedSequence != null ? setTermRepeatedSequence(t.termRepeatedSequence.duplicateRepeatedSequence(bnf, refRule)) : null
+;
+
+create GroupedSequence duplicateGroupedSequence(GroupedSequence g, EtsiBnf bnf, Rule refRule):
+	setDefinitionList(g.definitionList)
+;
+
+create OptionalSequence duplicateOptionalSequence(OptionalSequence g, EtsiBnf bnf, Rule refRule):
+	setDefinitionList(g.definitionList)
+;
+
+create RepeatedSequence duplicateRepeatedSequence(RepeatedSequence r, EtsiBnf bnf, Rule refRule):
+	setDefinitions(r.definitions)->
+	setMorethanonce(r.morethanonce)
+;
+
+create Atom duplicateAtom(Atom a, EtsiBnf bnf, Rule refRule):
+	a.atomStringRule != null ? setAtomStringRule(a.atomStringRule) : null->
+	a.atomRuleReference != null ? setAtomRuleReference(a.atomRuleReference) : null
+;
+
+// ----------------------------------------------------------------------------------------------------
+// Extensions for templates
+// ----------------------------------------------------------------------------------------------------
+
+Rule firstNonGeneratedRule(EtsiBnf bnf):
+	bnf.rule.selectFirst(e|!e.name.contains("_gen_") )
+;
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/groupRuleTest.bnf
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/groupRuleTest.bnf	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/groupRuleTest.bnf	(revision 5)
@@ -0,0 +1,7 @@
+grammar groupruletest;
+
+a ::= b (c (d)) d
+
+b ::= "foo"
+c ::= "midfoo"
+d ::= "bar"
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/optionalRuleTest.bnf
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/optionalRuleTest.bnf	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/optionalRuleTest.bnf	(revision 5)
@@ -0,0 +1,7 @@
+grammar optionalruletest;
+
+a ::= b [c] d
+
+b ::= "foo"
+c ::= "midfoo"
+d ::= "bar"
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/repeatedRuleTest1.bnf
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/repeatedRuleTest1.bnf	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/repeatedRuleTest1.bnf	(revision 5)
@@ -0,0 +1,8 @@
+grammar repeatedruletest1;
+
+a ::= b {c e} d
+
+b ::= "foo"
+c ::= "bar"
+d ::= "magic"
+e ::= b {d} b
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/repeatedRuleTest2.bnf
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/repeatedRuleTest2.bnf	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/repeatedRuleTest2.bnf	(revision 5)
@@ -0,0 +1,8 @@
+grammar repeatedruletest2;
+
+a ::= b {c {d}}+ d e
+
+b ::= "foo"
+c ::= "bar"
+d ::= "magic"
+e ::= {d}
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/ttcn3-4.2.1-draft.bnf
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/ttcn3-4.2.1-draft.bnf	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/model/ttcn3-4.2.1-draft.bnf	(revision 5)
@@ -0,0 +1,1022 @@
+grammar ttcn3;
+
+A.1.6	TTCN 3 syntax BNF productions
+A.1.6.0	TTCN 3 module
+1. TTCN3Module ::= TTCN3ModuleKeyword TTCN3ModuleId
+                   "{"
+                   [ModuleDefinitionsPart]
+                   [ModuleControlPart]
+                   "}"
+                   [WithStatement] [SemiColon]
+2. TTCN3ModuleKeyword ::= "module"
+3. TTCN3ModuleId ::= ModuleId
+4. ModuleId ::= GlobalModuleId [LanguageSpec]
+5. GlobalModuleId ::= ModuleIdentifier 
+6. ModuleIdentifier ::= Identifier
+7. LanguageSpec ::= LanguageKeyword FreeText { "," FreeText }
+8. LanguageKeyword ::= "language"
+
+A.1.6.1	Module definitions part
+A.1.6.1.0	General
+9. ModuleDefinitionsPart ::= ModuleDefinitionsList
+10. ModuleDefinitionsList ::= {ModuleDefinition [SemiColon]}+
+11. ModuleDefinition ::= ( ([Visibility] 
+                            ( TypeDef |
+                              ConstDef |
+                              TemplateDef |
+                              ModuleParDef |
+                              FunctionDef |
+                              SignatureDef |
+                              TestcaseDef |
+                              AltstepDef |
+                              ImportDef |
+                              ExtFunctionDef |
+                              ExtConstDef )
+                            ) |
+                           (["public"] GroupDef ) |
+                           (["private"] FriendModuleDef )
+                         ) [WithStatement]
+12. Visibility ::= "public" | "friend" | "private"
+
+A.1.6.1.1	Typedef definitions
+13. TypeDef ::= TypeDefKeyword TypeDefBody
+14. TypeDefBody ::= StructuredTypeDef | SubTypeDef
+15. TypeDefKeyword ::= "type"
+16. StructuredTypeDef ::= RecordDef |
+                          UnionDef |
+                          SetDef |
+                          RecordOfDef |
+                          SetOfDef |
+                          EnumDef |
+                          PortDef |
+                          ComponentDef
+17. RecordDef ::= RecordKeyword StructDefBody
+18. RecordKeyword ::= "record"
+19. StructDefBody ::= (StructTypeIdentifier | AddressKeyword)
+                      "{" [StructFieldDef {"," StructFieldDef}] "}"
+20. StructTypeIdentifier ::= Identifier
+21. StructFieldDef ::= (Type | NestedTypeDef) StructFieldIdentifier [ArrayDef] [SubTypeSpec]
+                       [OptionalKeyword]
+22. NestedTypeDef ::= NestedRecordDef |
+                      NestedUnionDef |
+                      NestedSetDef |
+                      NestedRecordOfDef |
+                      NestedSetOfDef |
+                      NestedEnumDef
+23. NestedRecordDef ::= RecordKeyword "{" [StructFieldDef {"," StructFieldDef}] "}"
+24. NestedUnionDef ::= UnionKeyword "{" UnionFieldDef {"," UnionFieldDef} "}"
+25. NestedSetDef ::= SetKeyword "{" [StructFieldDef {"," StructFieldDef}] "}"
+26. NestedRecordOfDef ::= RecordKeyword [StringLength] OfKeyword (Type | NestedTypeDef)
+27. NestedSetOfDef ::= SetKeyword [StringLength] OfKeyword (Type | NestedTypeDef)
+28. NestedEnumDef ::= EnumKeyword "{" EnumerationList "}"
+29. StructFieldIdentifier ::= Identifier
+30. OptionalKeyword ::= "optional"
+31. UnionDef ::= UnionKeyword UnionDefBody
+32. UnionKeyword ::= "union"
+33. UnionDefBody ::= (StructTypeIdentifier | AddressKeyword)
+                     "{" UnionFieldDef {"," UnionFieldDef} "}"
+34. UnionFieldDef ::= (Type | NestedTypeDef) StructFieldIdentifier [ArrayDef] [SubTypeSpec]
+35. SetDef ::= SetKeyword StructDefBody
+36. SetKeyword ::= "set"
+37. RecordOfDef ::= RecordKeyword [StringLength] OfKeyword StructOfDefBody
+38. OfKeyword ::= "of"
+39. StructOfDefBody ::= (Type | NestedTypeDef) (StructTypeIdentifier | AddressKeyword) [SubTypeSpec] 
+40. SetOfDef ::= SetKeyword [StringLength] OfKeyword StructOfDefBody
+41. EnumDef ::= EnumKeyword (EnumTypeIdentifier | AddressKeyword)
+                "{" EnumerationList "}"
+42. EnumKeyword ::= "enumerated"
+43. EnumTypeIdentifier ::= Identifier
+44. EnumerationList ::= Enumeration {"," Enumeration}
+45. Enumeration ::= EnumerationIdentifier ["("[Minus] Number ")"]
+46. EnumerationIdentifier ::= Identifier
+47. SubTypeDef ::= Type (SubTypeIdentifier | AddressKeyword)  [ArrayDef] [SubTypeSpec]
+48. SubTypeIdentifier ::= Identifier
+49. SubTypeSpec ::= AllowedValues [StringLength] | StringLength
+/* STATIC SEMANTICS - AllowedValues shall be of the same type as the field being subtyped */
+50. AllowedValues ::= "(" (ValueOrRange {"," ValueOrRange}) | CharStringMatch ")"
+51. ValueOrRange ::= RangeDef | ConstantExpression | Type
+/* STATIC SEMANTICS - RangeDef production shall only be used with integer, charstring, universal charstring or float based types */
+/* STATIC SEMANTICS - When subtyping charstring or universal charstring range and values shall not be mixed in the same SubTypeSpec */
+52. RangeDef ::= LowerBound ".." UpperBound
+53. StringLength ::= LengthKeyword "(" SingleConstExpression [".." UpperBound] ")"
+/* STATIC SEMANTICS - StringLength shall only be used with String types or to limit set of and record of. SingleConstExpression and UpperBound shall evaluate to non-negative integer values (in case of UpperBound including infinity) */
+54.	LengthKeyword ::= "length"
+55. PortType ::= [GlobalModuleId Dot] PortTypeIdentifier
+56. PortDef ::= PortKeyword PortDefBody
+57. PortDefBody ::= PortTypeIdentifier PortDefAttribs
+58. PortKeyword ::= "port"
+59. PortTypeIdentifier ::= Identifier
+60. PortDefAttribs ::= MessageAttribs | ProcedureAttribs | MixedAttribs
+61. MessageAttribs ::= MessageKeyword
+                       "{" {MessageList [SemiColon]}+ "}"
+62. MessageList ::= Direction AllOrTypeList
+63. Direction ::= InParKeyword | OutParKeyword | InOutParKeyword
+64. MessageKeyword ::= "message"
+65. AllOrTypeList ::= AllKeyword | TypeList
+/* NOTE: The use of AllKeyword in port definitions is deprecated */
+66. AllKeyword ::= "all"
+67. TypeList ::= Type {"," Type}
+68. ProcedureAttribs ::= ProcedureKeyword
+                         "{" {ProcedureList  [SemiColon]}+ "}"
+69. ProcedureKeyword ::= "procedure"
+70. ProcedureList ::= Direction AllOrSignatureList
+71. AllOrSignatureList ::= AllKeyword | SignatureList
+72. SignatureList ::= Signature {"," Signature}
+73. MixedAttribs ::= MixedKeyword
+                     "{" {MixedList [SemiColon]}+ "}"
+74. MixedKeyword ::= "mixed"
+75. MixedList ::= Direction ProcOrTypeList
+76. ProcOrTypeList ::= AllKeyword | (ProcOrType {"," ProcOrType})
+77. ProcOrType ::= Signature | Type
+78. ComponentDef ::= ComponentKeyword ComponentTypeIdentifier
+                     [ExtendsKeyword ComponentType {"," ComponentType}]
+                     "{" [ComponentDefList] "}"
+79. ComponentKeyword ::= "component"
+80. ExtendsKeyword ::= "extends"
+81. ComponentType ::= [GlobalModuleId Dot] ComponentTypeIdentifier
+82. ComponentTypeIdentifier ::= Identifier
+83. ComponentDefList ::= {ComponentElementDef [SemiColon]}
+84. ComponentElementDef ::= PortInstance | VarInstance | TimerInstance | ConstDef
+85. PortInstance ::= PortKeyword PortType PortElement {"," PortElement}
+86. PortElement ::= PortIdentifier [ArrayDef]
+87. PortIdentifier ::= Identifier
+
+A.1.6.1.2	Constant definitions
+88. ConstDef ::= ConstKeyword Type ConstList
+89. ConstList ::= SingleConstDef  {"," SingleConstDef}
+90. SingleConstDef ::= ConstIdentifier [ArrayDef] AssignmentChar ConstantExpression
+91. ConstKeyword ::= "const"
+92. ConstIdentifier ::= Identifier
+
+A.1.6.1.3	Template definitions
+93. TemplateDef ::= TemplateKeyword [TemplateRestriction] BaseTemplate [DerivedDef] 
+                    AssignmentChar TemplateBody
+94. BaseTemplate ::= (Type | Signature) TemplateIdentifier  ["(" TemplateFormalParList ")"]
+95. TemplateKeyword ::= "template"
+96. TemplateIdentifier ::= Identifier
+97. DerivedDef ::= ModifiesKeyword TemplateRef
+98. ModifiesKeyword ::= "modifies"
+99. TemplateFormalParList ::= TemplateFormalPar {"," TemplateFormalPar}
+100. TemplateFormalPar ::= FormalValuePar | FormalTemplatePar
+/* STATIC SEMANTICS - FormalValuePar shall resolve to an in parameter */
+101. TemplateBody ::= (SimpleSpec | FieldSpecList | ArrayValueOrAttrib) [ExtraMatchingAttributes]
+/* STATIC SEMANTICS - Within TeplateBody the ArrayValueOrAttrib can be used for array, record, record of and set of types. */
+102. SimpleSpec ::= SingleValueOrAttrib
+103. FieldSpecList ::= "{"[FieldSpec {"," FieldSpec}] "}"
+104. FieldSpec ::= FieldReference AssignmentChar TemplateBody
+105. FieldReference ::= StructFieldRef | ArrayOrBitRef | ParRef
+106. StructFieldRef ::= StructFieldIdentifier| PredefinedType | TypeReference
+/* STATIC SEMANTICS - PredefinedType and TypeReference shall be used for anytype value notation only. PredefinedType shall not be AnyTypeKeyword.*/
+107. ParRef ::= SignatureParIdentifier
+/* STATIC SEMANTICS - SignatureParIdentifier shall be a formal parameter identifier from the associated signature definition */
+108. SignatureParIdentifier ::= ValueParIdentifier
+109. ArrayOrBitRef ::= "[" FieldOrBitNumber "]"
+/* STATIC SEMANTICS - ArrayRef shall be optionally used for array types and TTCN 3 record of and set of. The same notation can be used for a Bit reference inside an TTCN 3 charstring, universal charstring, bitstring, octetstring and hexstring type */
+110. FieldOrBitNumber ::= SingleExpression
+/* STATIC SEMANTICS - SingleExpression will resolve to a value of integer type */
+111. SingleValueOrAttrib ::= MatchingSymbol |
+                             SingleExpression |
+                             ( TemplateRefWithParList [ ExtendedFieldReference ] )
+/* STATIC SEMANTIC - VariableIdentifier (accessed via singleExpression) may only be used in in-line template definitions to reference variables in the current scope */
+112. ArrayValueOrAttrib ::= "{" ArrayElementSpecList "}"
+113. ArrayElementSpecList ::= ArrayElementSpec {"," ArrayElementSpec}
+114. ArrayElementSpec ::= NotUsedSymbol | PermutationMatch | TemplateBody
+115. NotUsedSymbol ::= Dash
+116. MatchingSymbol ::= Complement | 
+                        AnyValue | 
+                        AnyOrOmit | 
+                        ValueOrAttribList |
+                        Range | 
+                        BitStringMatch | 
+                        HexStringMatch |
+                        OctetStringMatch | 
+                        CharStringMatch | 
+                        SubsetMatch |
+                        SupersetMatch
+117. ExtraMatchingAttributes ::= LengthMatch | IfPresentMatch | (LengthMatch IfPresentMatch)
+118. BitStringMatch ::= "'" {BinOrMatch} "'" "B"
+119. BinOrMatch ::= Bin | AnyValue | AnyOrOmit
+120. HexStringMatch ::= "'" {HexOrMatch} "'" "H"
+121. HexOrMatch ::= Hex | AnyValue | AnyOrOmit
+122. OctetStringMatch ::= "'" {OctOrMatch} "'" "O"
+123. OctOrMatch ::= Oct | AnyValue | AnyOrOmit
+124. CharStringMatch ::= PatternKeyword Pattern {"&" (Pattern | ReferencedValue)}
+125. PatternKeyword ::= "pattern"
+126. Pattern ::= """ { PatternElement } """
+127. PatternElement ::= 
+         ("\" ("?" | "*" | "\" | "[" | "]" | "{" | "}" | """ | "|" | "(" | ")" | "#" | "+" |
+               "d" | "w" | "t" | "n" | "r" | "s" | "b")) |
+         ("?" | "*" | "\" | "|" | "+") |
+         ("[" ["^"] [ {PatternChar ["-" PatternChar] } ] "]") | 
+         ("{" ReferencedValue "}") |
+         ("\" "N" "{" (ReferencedValue | Type) "}") |
+         (""" """) | 
+         ("(" PatternElement ")") | 
+         ("#" (Num | ("(" Num "," [Num] ")") | ("(" "," Num ")"))) | 
+         PatternChar
+128. PatternChar ::= Char | PatternQuadruple
+129. PatternQuadruple ::= "\" "q" "(" Group "," Plane "," Row "," Cell ")"
+130. Complement ::= ComplementKeyword "(" TemplateBody {"," TemplateBody} ")"
+131. ComplementKeyword ::= "complement"
+132. SubsetMatch ::= SubsetKeyword ValueOrAttribList
+133. SubsetKeyword ::= "subset"
+134. SupersetMatch ::= SupersetKeyword ValueOrAttribList
+135. SupersetKeyword ::= "superset"
+136. PermutationMatch ::= PermutationKeyword PermutationList
+137. PermutationKeyword ::= "permutation"
+138. PermutationList ::= "(" TemplateBody { "," TemplateBody } ")"
+/* STATIC SEMANTICS: Restrictions on the content of TemplateBody are given in clause B.1.3.3 */
+139. AnyValue ::= "?"
+140. AnyOrOmit ::= "*"
+141. ValueOrAttribList ::= "(" TemplateBody {"," TemplateBody}+ ")"
+142. LengthMatch ::= StringLength
+143. IfPresentMatch ::= IfPresentKeyword
+144. IfPresentKeyword ::= "ifpresent"
+145. PresentKeyword ::= "present"
+146. Range ::= "(" LowerBound ".." UpperBound ")"
+147. LowerBound ::= SingleConstExpression | (Minus InfinityKeyword)
+148. UpperBound ::= SingleConstExpression | InfinityKeyword
+/* STATIC SEMANTICS - LowerBound and UpperBound shall evaluate to types integer, charstring, universal charstring or float. In case LowerBound or UpperBound evaluates to types charstring or universal charstring, only SingleConstExpression may be present and the string length shall be 1*/
+149. InfinityKeyword ::= "infinity"
+150. TemplateInstance ::= InLineTemplate
+151. TemplateInstanceAssignment ::= ( TemplateParIdentifier | ValueParIdentifier ) 
+                                      ":=" InLineTemplate
+/* STATIC SEMANTICS  if a value parameter is used, the inline template shall evaluate to a value */
+152. TemplateRefWithParList ::= [GlobalModuleId Dot] ( TemplateIdentifier [TemplateActualParList] |
+                                TemplateParIdentifier )
+153. TemplateRef ::= [GlobalModuleId Dot] TemplateIdentifier | TemplateParIdentifier
+154. InLineTemplate ::= [(Type | Signature) Colon] [DerivedRefWithParList AssignmentChar]
+                        TemplateBody
+155. DerivedRefWithParList ::= ModifiesKeyword TemplateRefWithParList
+156. TemplateActualParList ::= "(" [( TemplateActualPar {"," TemplateActualPar}) | 
+                               ( TemplateActualParAssignment {"," TemplateActualParAssignment })]")"
+157. TemplateActualPar ::= TemplateInstance | Dash
+/* STATIC SEMANTICS - When the corresponding formal parameter is not of template type the TemplateInstance production shall resolve to one or more SingleExpressions */
+158. TemplateActualParAssignment ::= TemplateInstanceAssignment
+159. TemplateOps ::= MatchOp | ValueofOp
+160. MatchOp ::= MatchKeyword "(" Expression "," TemplateInstance")"
+161. MatchKeyword ::= "match"
+162. ValueofOp ::= ValueofKeyword "(" TemplateInstance ")"
+163. ValueofKeyword ::= "valueof"
+
+A.1.6.1.4	Function definitions
+164. FunctionDef ::= FunctionKeyword FunctionIdentifier
+                     "("[FunctionFormalParList] ")" [RunsOnSpec] [ReturnType]
+                     StatementBlock
+165. FunctionKeyword ::= "function"
+166. FunctionIdentifier ::= Identifier
+167. FunctionFormalParList ::= FunctionFormalPar {"," FunctionFormalPar}
+168. FunctionFormalPar ::= FormalValuePar |
+                           FormalTimerPar |
+                           FormalTemplatePar |
+                           FormalPortPar
+169. ReturnType ::= ReturnKeyword [TemplateKeyword | RestrictedTemplate] Type
+170. ReturnKeyword ::= "return"
+171. RunsOnSpec ::= RunsKeyword OnKeyword ComponentType
+172. RunsKeyword ::= "runs"
+173. OnKeyword ::= "on"
+174. MTCKeyword ::= "mtc"
+175. StatementBlock ::= "{" [FunctionDefList] [FunctionStatementList] "}"
+176. FunctionDefList::= {(FunctionLocalDef | FunctionLocalInst)[SemiColon]}+
+177. FunctionStatementList::= {FunctionStatement [SemiColon]}+
+178. FunctionLocalInst ::= VarInstance | TimerInstance
+179. FunctionLocalDef ::= ConstDef | TemplateDef
+180. FunctionStatement ::= ConfigurationStatements |
+                           TimerStatements |
+                           CommunicationStatements |
+                           BasicStatements |
+                           BehaviourStatements |
+                           VerdictStatements |
+                           SUTStatements
+181. FunctionInstance ::= FunctionRef "(" [FunctionActualParList] ")"
+182. FunctionRef ::= [GlobalModuleId Dot] (FunctionIdentifier | ExtFunctionIdentifier ) |
+                     PreDefFunctionIdentifier
+183. PreDefFunctionIdentifier ::= Identifier
+/* STATIC SEMANTICS - The Identifier shall be one of the pre-defined TTCN 3 Function Identifiers from Annex C of ES 201 873-1 */
+184. FunctionActualParList ::= ( FunctionActualPar {"," FunctionActualPar} ) |
+                               ( FunctionActualParAssignment { "," FunctionActualParAssignment } )
+185. FunctionActualPar ::= TimerRef |
+                           TemplateInstance |
+                           Port |
+                           ComponentRef |
+                           Dash
+/* STATIC SEMANTICS - When the corresponding formal parameter is not of template type the TemplateInstance production shall resolve to one or more SingleExpressions i.e. equivalent to the Expression production */
+186. FunctionActualParAssignment ::= TemplateInstanceAssignment | ComponentRefAssignment |
+                                     PortAssignment | TimerRefAssignment
+187. TimerRefAssignment ::= TimerParIdentifier ":=" TimerRef
+188. PortAssignment ::= PortParIdentifier ":=" Port
+
+A.1.6.1.5	Signature definitions
+189. SignatureDef ::= SignatureKeyword SignatureIdentifier
+                      "("[SignatureFormalParList] ")" [ReturnType | NoBlockKeyword]
+                      [ExceptionSpec]
+190. SignatureKeyword ::= "signature"
+191. SignatureIdentifier ::= Identifier
+192. SignatureFormalParList ::= SignatureFormalPar {"," SignatureFormalPar}
+193. SignatureFormalPar ::= FormalValuePar
+194. ExceptionSpec ::= ExceptionKeyword "(" ExceptionTypeList ")"
+195. ExceptionKeyword ::= "exception"
+196. ExceptionTypeList ::= Type {"," Type}
+197. NoBlockKeyword ::= "noblock"
+198. Signature ::= [GlobalModuleId Dot] SignatureIdentifier
+
+A.1.6.1.6	Testcase definitions
+199. TestcaseDef ::= TestcaseKeyword TestcaseIdentifier
+                     "("[TestcaseFormalParList] ")" ConfigSpec
+                     StatementBlock
+200. TestcaseKeyword ::= "testcase"
+201. TestcaseIdentifier ::= Identifier
+202. TestcaseFormalParList ::= TestcaseFormalPar {"," TestcaseFormalPar}
+203. TestcaseFormalPar ::= FormalValuePar |
+                           FormalTemplatePar
+204. ConfigSpec ::= RunsOnSpec [SystemSpec]
+205. SystemSpec ::= SystemKeyword ComponentType
+206. SystemKeyword ::= "system"
+207. TestcaseInstance ::= ExecuteKeyword "(" TestcaseRef "(" [TestcaseActualParList] ")"
+                          ["," TimerValue] ")"
+208. ExecuteKeyword ::= "execute"
+209. TestcaseRef ::= [GlobalModuleId Dot] TestcaseIdentifier
+210. TestcaseActualParList ::= ( TestcaseActualPar {"," TestcaseActualPar} ) | 
+                               ( TestcaseActualParAssignment { "," TestcaseActualParAssignment })
+211. TestcaseActualPar ::= TemplateInstance | Dash
+/* STATIC SEMANTICS - When the corresponding formal parameter is not of template type the TemplateInstance production shall resolve to one or more SingleExpressions i.e. equivalent to the Expression production */
+212. TestcaseActualParAssignment ::= TemplateInstanceAssignment
+
+A.1.6.1.7	Altstep definitions
+213. AltstepDef ::= AltstepKeyword AltstepIdentifier
+                    "("[AltstepFormalParList] ")" [RunsOnSpec]
+                    "{" AltstepLocalDefList AltGuardList "}"
+214. AltstepKeyword ::= "altstep"
+215. AltstepIdentifier ::= Identifier
+216. AltstepFormalParList ::= FunctionFormalParList
+217. AltstepLocalDefList ::= {AltstepLocalDef [SemiColon]}
+218. AltstepLocalDef ::= VarInstance | TimerInstance | ConstDef | TemplateDef
+219. AltstepInstance ::= AltstepRef "(" [FunctionActualParList] ")"
+220. AltstepRef ::= [GlobalModuleId Dot] AltstepIdentifier
+
+A.1.6.1.8	Import definitions
+221. ImportDef ::= ImportKeyword ImportFromSpec (AllWithExcepts | ("{" ImportSpec "}"))
+222. ImportKeyword ::= "import"
+223. AllWithExcepts ::= AllKeyword [ExceptsDef]
+224. ExceptsDef ::= ExceptKeyword "{" ExceptSpec "}"
+225. ExceptKeyword ::= "except"
+226. ExceptSpec ::= {ExceptElement [SemiColon]}
+227. ExceptElement ::= ExceptGroupSpec |
+                       ExceptTypeDefSpec |
+                       ExceptTemplateSpec |
+                       ExceptConstSpec |
+                       ExceptTestcaseSpec |
+                       ExceptAltstepSpec |
+                       ExceptFunctionSpec |
+                       ExceptSignatureSpec |
+                       ExceptModuleParSpec
+228. ExceptGroupSpec ::= GroupKeyword (ExceptGroupRefList | AllKeyword)
+229. ExceptTypeDefSpec ::= TypeDefKeyword (TypeRefList | AllKeyword)
+230. ExceptTemplateSpec ::= TemplateKeyword (TemplateRefList | AllKeyword)
+231. ExceptConstSpec ::= ConstKeyword (ConstRefList | AllKeyword)
+232. ExceptTestcaseSpec ::= TestcaseKeyword (TestcaseRefList | AllKeyword)
+233. ExceptAltstepSpec ::= AltstepKeyword (AltstepRefList | AllKeyword)
+234. ExceptFunctionSpec ::= FunctionKeyword (FunctionRefList | AllKeyword)
+235. ExceptSignatureSpec ::= SignatureKeyword (SignatureRefList | AllKeyword)
+236. ExceptModuleParSpec ::= ModuleParKeyword (ModuleParRefList | AllKeyword)
+237. ImportSpec ::= {ImportElement [SemiColon]}
+238. ImportElement ::= ImportGroupSpec |
+                       ImportTypeDefSpec |
+                       ImportTemplateSpec |
+                       ImportConstSpec |
+                       ImportTestcaseSpec |
+                       ImportAltstepSpec |
+                       ImportFunctionSpec |
+                       ImportSignatureSpec |
+                       ImportModuleParSpec |
+                       ImportImportSpec
+239. ImportFromSpec ::= FromKeyword ModuleId [RecursiveKeyword]
+240. RecursiveKeyword ::= "recursive"
+241. ImportGroupSpec ::= GroupKeyword (GroupRefListWithExcept | AllGroupsWithExcept)
+242. GroupRefList ::= FullGroupIdentifier {"," FullGroupIdentifier}
+243. GroupRefListWithExcept ::= FullGroupIdentifierWithExcept {"," FullGroupIdentifierWithExcept}
+244. AllGroupsWithExcept ::= AllKeyword [ExceptKeyword GroupRefList]
+245. FullGroupIdentifier ::= GroupIdentifier {Dot GroupIdentifier} 
+246. FullGroupIdentifierWithExcept ::= FullGroupIdentifier [ExceptsDef]
+247. ExceptGroupRefList ::= ExceptFullGroupIdentifier {"," ExceptFullGroupIdentifier}
+248. ExceptFullGroupIdentifier ::= FullGroupIdentifier
+249. ImportTypeDefSpec ::= TypeDefKeyword (TypeRefList | AllTypesWithExcept)
+250. TypeRefList ::= TypeDefIdentifier {"," TypeDefIdentifier}
+251. AllTypesWithExcept ::= AllKeyword [ExceptKeyword TypeRefList]
+252. TypeDefIdentifier ::= StructTypeIdentifier |
+                           EnumTypeIdentifier |
+                           PortTypeIdentifier |
+                           ComponentTypeIdentifier |
+                           SubTypeIdentifier
+253. ImportTemplateSpec ::= TemplateKeyword (TemplateRefList | AllTemplsWithExcept)
+254. TemplateRefList ::= TemplateIdentifier {"," TemplateIdentifier}
+255. AllTemplsWithExcept ::= AllKeyword [ExceptKeyword TemplateRefList]
+256. ImportConstSpec ::= ConstKeyword (ConstRefList | AllConstsWithExcept)
+257. ConstRefList ::= ConstIdentifier {"," ConstIdentifier}
+258. AllConstsWithExcept ::= AllKeyword [ExceptKeyword ConstRefList]
+259. ImportAltstepSpec ::= AltstepKeyword (AltstepRefList | AllAltstepsWithExcept)
+260. AltstepRefList ::= AltstepIdentifier {"," AltstepIdentifier}
+261. AllAltstepsWithExcept ::= AllKeyword [ExceptKeyword AltstepRefList]
+262. ImportTestcaseSpec ::= TestcaseKeyword (TestcaseRefList | AllTestcasesWithExcept)
+263. TestcaseRefList ::= TestcaseIdentifier {"," TestcaseIdentifier}
+264. AllTestcasesWithExcept ::= AllKeyword [ExceptKeyword TestcaseRefList]
+265. ImportFunctionSpec ::= FunctionKeyword (FunctionRefList | AllFunctionsWithExcept)
+266. FunctionRefList ::= FunctionIdentifier {"," FunctionIdentifier}
+267. AllFunctionsWithExcept ::= AllKeyword [ExceptKeyword FunctionRefList]
+268. ImportSignatureSpec ::= SignatureKeyword  (SignatureRefList | AllSignaturesWithExcept)
+269. SignatureRefList ::= SignatureIdentifier {"," SignatureIdentifier}
+270. AllSignaturesWithExcept ::= AllKeyword [ExceptKeyword SignatureRefList]
+271. ImportModuleParSpec ::= ModuleParKeyword  (ModuleParRefList | AllModuleParWithExcept)
+272. ModuleParRefList ::= ModuleParIdentifier {"," ModuleParIdentifier}
+273. AllModuleParWithExcept ::= AllKeyword [ExceptKeyword ModuleParRefList]
+274. ImportImportSpec ::= ImportKeyword AllKeyword
+
+A.1.6.1.9	Group definitions
+275. GroupDef ::= GroupKeyword GroupIdentifier
+                  "{" [ModuleDefinitionsPart] "}"
+276. GroupKeyword ::= "group"
+277. GroupIdentifier ::= Identifier
+
+A.1.6.1.10	External function definitions
+278. ExtFunctionDef ::= ExtKeyword FunctionKeyword ExtFunctionIdentifier
+                        "("[FunctionFormalParList] ")" [ReturnType]
+279. ExtKeyword ::= "external"
+280. ExtFunctionIdentifier ::= Identifier
+
+A.1.6.1.11	External constant definitions
+281. ExtConstDef ::= ExtKeyword ConstKeyword Type ExtConstIdentifierList
+282. ExtConstIdentifierList ::= ExtConstIdentifier { "," ExtConstIdentifier }
+283. ExtConstIdentifier ::= Identifier
+
+A.1.6.1.12	Module parameter definitions
+284. ModuleParDef ::= ModuleParKeyword ( ModulePar | ("{" MultitypedModuleParList "}"))
+285. ModuleParKeyword ::= "modulepar"
+286. MultitypedModuleParList ::= { ModulePar [SemiColon] }
+287. ModulePar ::= ModuleParType ModuleParList
+288. ModuleParType ::= Type
+289. ModuleParList ::= ModuleParIdentifier [AssignmentChar ConstantExpression]
+                      {","ModuleParIdentifier [AssignmentChar ConstantExpression]}
+290. ModuleParIdentifier ::= Identifier
+
+A.1.6.1.13	Friend module definitions
+291. FriendModuleDef ::= "friend" "module" ModuleIdentifier {"," ModuleIdentifier } [SemiColon]
+
+A.1.6.2	Control part
+A.1.6.2.0	General
+292. ModuleControlPart ::= ControlKeyword
+                           "{" ModuleControlBody "}"
+                           [WithStatement] [SemiColon]
+293. ControlKeyword ::= "control"
+294. ModuleControlBody ::= [ControlStatementOrDefList]
+295. ControlStatementOrDefList ::= {ControlStatementOrDef [SemiColon]}+
+296. ControlStatementOrDef ::= FunctionLocalDef |
+                               FunctionLocalInst |
+                               ControlStatement
+297. ControlStatement ::= TimerStatements |
+                          BasicStatements |
+                          BehaviourStatements |
+                          SUTStatements |
+                          StopKeyword
+
+A.1.6.2.1	Variable instantiation
+298. VarInstance ::= VarKeyword ((Type VarList) 
+                      | (( TemplateKeyword | RestrictedTemplate ) Type TempVarList))
+299. VarList ::= SingleVarInstance {"," SingleVarInstance}
+300. SingleVarInstance ::= VarIdentifier [ArrayDef] [AssignmentChar VarInitialValue]
+301. VarInitialValue ::= Expression
+302. VarKeyword ::= "var"
+303. VarIdentifier ::= Identifier
+304. TempVarList ::= SingleTempVarInstance {"," SingleTempVarInstance}
+305. SingleTempVarInstance ::= VarIdentifier [ArrayDef] [AssignmentChar TempVarInitialValue]
+306. TempVarInitialValue ::= TemplateBody
+307. VariableRef ::= ( VarIdentifier | ValueParIdentifier | TemplateParIdentifier )
+                     [ ExtendedFieldReference ]
+
+A.1.6.2.2	Timer instantiation
+308. TimerInstance ::= TimerKeyword TimerList
+309. TimerList ::= SingleTimerInstance{"," SingleTimerInstance}
+310. SingleTimerInstance ::= TimerIdentifier [ArrayDef] [AssignmentChar TimerValue]
+311. TimerKeyword ::= "timer"
+312. TimerIdentifier ::= Identifier
+313. TimerValue ::= Expression
+314. TimerRef ::= (TimerIdentifier | TimerParIdentifier) {ArrayOrBitRef}
+
+A.1.6.2.3	Component operations
+315. ConfigurationStatements ::= ConnectStatement |
+                                 MapStatement |
+                                 DisconnectStatement |
+                                 UnmapStatement |
+                                 DoneStatement |
+                                 KilledStatement |
+                                 StartTCStatement |
+                                 StopTCStatement |
+                                 KillTCStatement
+316. ConfigurationOps ::= CreateOp | SelfOp | SystemOp | MTCOp | RunningOp | AliveOp
+317. CreateOp ::= ComponentType Dot CreateKeyword ["(" SingleExpression ")"] [AliveKeyword]
+318. SystemOp ::= SystemKeyword
+319. SelfOp ::= "self"
+320. MTCOp ::= MTCKeyword
+321. DoneStatement ::= ComponentId Dot DoneKeyword
+322. KilledStatement ::= ComponentId Dot KilledKeyword
+323. ComponentId ::= ComponentOrDefaultReference | (AnyKeyword | AllKeyword) ComponentKeyword
+324. DoneKeyword ::= "done"
+325. KilledKeyword ::= "killed"
+326. RunningOp ::= ComponentId Dot RunningKeyword
+327. RunningKeyword ::= "running"
+328. AliveOp ::= ComponentId Dot AliveKeyword
+329. CreateKeyword ::= "create"
+330. AliveKeyword ::= "alive"
+331. ConnectStatement ::= ConnectKeyword SingleConnectionSpec
+332. ConnectKeyword ::= "connect"
+333. SingleConnectionSpec ::= "(" PortRef "," PortRef ")"
+334. PortRef ::= ComponentRef Colon Port
+335. ComponentRef ::= ComponentOrDefaultReference | SystemOp | SelfOp | MTCOp
+336. ComponentRefAssignment ::= ValueParIdentifier ":=" ComponentRef
+337. DisconnectStatement ::= DisconnectKeyword [SingleOrMultiConnectionSpec]
+338. SingleOrMultiConnectionSpec ::= SingleConnectionSpec |
+                                     AllConnectionsSpec |
+                                     AllPortsSpec |
+                                     AllCompsAllPortsSpec
+339. AllConnectionsSpec ::= "(" PortRef ")"
+340. AllPortsSpec ::= "(" ComponentRef ":" AllKeyword PortKeyword ")"
+341. AllCompsAllPortsSpec ::= "(" AllKeyword ComponentKeyword ":" AllKeyword PortKeyword ")"
+342. DisconnectKeyword ::= "disconnect"
+343. MapStatement ::= MapKeyword SingleConnectionSpec
+344. MapKeyword ::= "map"
+345. UnmapStatement ::= UnmapKeyword [SingleOrMultiConnectionSpec]
+346. UnmapKeyword ::= "unmap"
+347. StartTCStatement ::= ComponentOrDefaultReference Dot StartKeyword "(" FunctionInstance ")"
+348. StartKeyword ::= "start"
+349. StopTCStatement ::= StopKeyword | (ComponentReferenceOrLiteral Dot StopKeyword) |
+                         (AllKeyword ComponentKeyword Dot StopKeyword)
+350. ComponentReferenceOrLiteral ::= ComponentOrDefaultReference | MTCOp | SelfOp
+351. KillTCStatement ::= KillKeyword | (ComponentReferenceOrLiteral Dot KillKeyword) |
+                         (AllKeyword ComponentKeyword Dot KillKeyword)
+352. ComponentOrDefaultReference ::= VariableRef | FunctionInstance
+353. KillKeyword ::= "kill"
+
+A.1.6.2.4	Port operations
+354. Port ::= (PortIdentifier | PortParIdentifier) {ArrayOrBitRef}
+355. CommunicationStatements ::= SendStatement |
+                                 CallStatement |
+                                 ReplyStatement |
+                                 RaiseStatement |
+                                 ReceiveStatement |
+                                 TriggerStatement |
+                                 GetCallStatement |
+                                 GetReplyStatement |
+                                 CatchStatement |
+                                 CheckStatement |
+                                 ClearStatement |
+                                 StartStatement |
+                                 StopStatement |
+                                 HaltStatement
+356. SendStatement ::= Port Dot PortSendOp
+357. PortSendOp ::= SendOpKeyword "(" SendParameter ")" [ToClause]
+358. SendOpKeyword ::= "send"
+359. SendParameter ::= TemplateInstance
+360. ToClause ::= ToKeyword ( AddressRef |
+                  AddressRefList |
+                  AllKeyword ComponentKeyword )
+361. AddressRefList ::= "(" AddressRef {"," AddressRef} ")"
+362. ToKeyword ::= "to"
+363. AddressRef ::= TemplateInstance
+364. CallStatement ::= Port Dot PortCallOp  [PortCallBody]
+365. PortCallOp ::= CallOpKeyword "(" CallParameters ")" [ToClause]
+366. CallOpKeyword ::= "call"
+367. CallParameters ::= TemplateInstance ["," CallTimerValue]
+368. CallTimerValue ::= TimerValue | NowaitKeyword
+369. NowaitKeyword ::= "nowait"
+370. PortCallBody ::= "{" CallBodyStatementList "}"
+371. CallBodyStatementList ::= {CallBodyStatement [SemiColon]}+
+372. CallBodyStatement ::= CallBodyGuard StatementBlock
+373. CallBodyGuard ::= AltGuardChar CallBodyOps
+374. CallBodyOps ::= GetReplyStatement | CatchStatement
+375. ReplyStatement ::= Port Dot PortReplyOp
+376. PortReplyOp ::= ReplyKeyword "(" TemplateInstance [ReplyValue]")" [ToClause]
+377. ReplyKeyword ::= "reply"
+378. ReplyValue ::= ValueKeyword Expression
+379. RaiseStatement ::= Port Dot PortRaiseOp
+380. PortRaiseOp ::= RaiseKeyword "(" Signature "," TemplateInstance ")" [ToClause]
+381. RaiseKeyword ::= "raise"
+382. ReceiveStatement ::= PortOrAny Dot PortReceiveOp
+383. PortOrAny ::= Port | AnyKeyword PortKeyword
+384. PortReceiveOp ::= ReceiveOpKeyword ["(" ReceiveParameter ")"] [FromClause] [PortRedirect]
+385. ReceiveOpKeyword ::= "receive"
+386. ReceiveParameter ::= TemplateInstance
+387. FromClause ::= FromKeyword ( AddressRef |
+                    AddressRefList |
+                    AnyKeyword ComponentKeyword )
+388. FromKeyword ::= "from"
+389. PortRedirect ::= PortRedirectSymbol (ValueSpec [SenderSpec] | SenderSpec)
+390. PortRedirectSymbol ::= "->"
+391. ValueSpec ::= ValueKeyword ( VariableRef | 
+                                 ( "(" SingleValueSpec { "," SingleValueSpec } ")" ) )
+392. SingleValueSpec ::= VariableRef [ AssignmentChar FieldReference ExtendedFieldReference ]
+/*STATIC SEMANTICS  FieldReference shall not be ParRef and ExtendedFieldReference shall not be
+                     TypeDefIdentifier*/
+393. ValueKeyword ::= "value"
+394. SenderSpec ::= SenderKeyword VariableRef
+395. SenderKeyword ::= "sender"
+396. TriggerStatement ::= PortOrAny Dot PortTriggerOp
+397. PortTriggerOp ::= TriggerOpKeyword ["(" ReceiveParameter ")"] [FromClause] [PortRedirect]
+398. TriggerOpKeyword ::= "trigger"
+399. GetCallStatement ::= PortOrAny  Dot PortGetCallOp
+400. PortGetCallOp ::= GetCallOpKeyword ["(" ReceiveParameter ")"] [FromClause]
+                       [PortRedirectWithParam]
+401. GetCallOpKeyword ::= "getcall"
+402. PortRedirectWithParam ::= PortRedirectSymbol RedirectWithParamSpec
+403. RedirectWithParamSpec ::= ParamSpec [SenderSpec] |
+                              SenderSpec
+404. ParamSpec ::= ParamKeyword ParamAssignmentList
+405. ParamKeyword ::= "param"
+406. ParamAssignmentList ::= "(" (AssignmentList | VariableList) ")"
+407. AssignmentList ::= VariableAssignment {"," VariableAssignment}
+408. VariableAssignment ::= VariableRef AssignmentChar ParameterIdentifier
+409. ParameterIdentifier ::= ValueParIdentifier
+410. VariableList ::= VariableEntry  {"," VariableEntry}
+411. VariableEntry ::= VariableRef | NotUsedSymbol
+412. GetReplyStatement ::= PortOrAny Dot PortGetReplyOp
+413. PortGetReplyOp ::= GetReplyOpKeyword ["(" ReceiveParameter [ValueMatchSpec] ")"]
+                        [FromClause] [PortRedirectWithValueAndParam]
+414. PortRedirectWithValueAndParam ::= PortRedirectSymbol RedirectWithValueAndParamSpec
+415. RedirectWithValueAndParamSpec ::= ValueSpec [ParamSpec] [SenderSpec] |
+                                       RedirectWithParamSpec
+416. GetReplyOpKeyword ::= "getreply"
+417. ValueMatchSpec ::= ValueKeyword TemplateInstance
+418. CheckStatement ::= PortOrAny Dot PortCheckOp
+419. PortCheckOp ::= CheckOpKeyword ["(" CheckParameter ")"]
+420. CheckOpKeyword ::= "check"
+421. CheckParameter ::= CheckPortOpsPresent | FromClausePresent | RedirectPresent
+422. FromClausePresent ::= FromClause [PortRedirectSymbol SenderSpec]
+423. RedirectPresent ::= PortRedirectSymbol SenderSpec
+424. CheckPortOpsPresent ::= PortReceiveOp | PortGetCallOp | PortGetReplyOp | PortCatchOp
+425. CatchStatement ::= PortOrAny Dot PortCatchOp
+426. PortCatchOp ::= CatchOpKeyword ["("CatchOpParameter ")"] [FromClause] [PortRedirect]
+427. CatchOpKeyword ::= "catch"
+428. CatchOpParameter ::= Signature "," TemplateInstance | TimeoutKeyword
+429. ClearStatement ::= PortOrAll Dot PortClearOp
+430. PortOrAll ::= Port | AllKeyword PortKeyword
+431. PortClearOp ::= ClearOpKeyword
+432. ClearOpKeyword ::= "clear"
+433. StartStatement ::= PortOrAll Dot PortStartOp
+434. PortStartOp ::= StartKeyword
+435. StopStatement ::= PortOrAll Dot PortStopOp
+436. PortStopOp ::= StopKeyword
+437. StopKeyword ::= "stop"
+438. HaltStatement ::= PortOrAll Dot PortHaltOp
+439. PortHaltOp ::= HaltKeyword
+440. HaltKeyword ::= "halt"
+441. AnyKeyword ::= "any"
+
+A.1.6.2.5	Timer operations
+442. TimerStatements ::= StartTimerStatement | StopTimerStatement | TimeoutStatement
+443. TimerOps ::= ReadTimerOp | RunningTimerOp
+444. StartTimerStatement ::= TimerRef Dot StartKeyword ["(" TimerValue ")"]
+445. StopTimerStatement ::= TimerRefOrAll Dot StopKeyword
+446. TimerRefOrAll ::= TimerRef | AllKeyword TimerKeyword
+447. ReadTimerOp ::= TimerRef Dot ReadKeyword
+448. ReadKeyword ::= "read"
+449. RunningTimerOp ::= TimerRefOrAny Dot RunningKeyword
+450. TimeoutStatement ::= TimerRefOrAny Dot TimeoutKeyword
+451. TimerRefOrAny ::= TimerRef | ( AnyKeyword TimerKeyword )
+452. TimeoutKeyword ::= "timeout"
+
+A.1.6.3	Type
+453. Type ::= PredefinedType | ReferencedType
+454. PredefinedType ::= BitStringKeyword |
+                        BooleanKeyword |
+                        CharStringKeyword |
+                        UniversalCharString |
+                        IntegerKeyword |
+                        OctetStringKeyword |
+                        HexStringKeyword |
+                        VerdictTypeKeyword |
+                        FloatKeyword |
+                        AddressKeyword |
+                        DefaultKeyword |
+                        AnyTypeKeyword
+455. BitStringKeyword ::= "bitstring"
+456. BooleanKeyword ::= "boolean"
+457. IntegerKeyword ::= "integer"
+458. OctetStringKeyword ::= "octetstring"
+459. HexStringKeyword ::= "hexstring"
+460. VerdictTypeKeyword ::= "verdicttype"
+461. FloatKeyword ::= "float"
+462. AddressKeyword ::= "address"
+463. DefaultKeyword ::= "default"
+464. AnyTypeKeyword ::= "anytype"
+465. CharStringKeyword ::= "charstring"
+466. UniversalCharString ::= UniversalKeyword CharStringKeyword
+467. UniversalKeyword ::= "universal"
+468. ReferencedType ::= [GlobalModuleId Dot] TypeReference [ExtendedFieldReference]
+469. TypeReference ::= StructTypeIdentifier |
+                       EnumTypeIdentifier |
+                       SubTypeIdentifier |
+                       ComponentTypeIdentifier
+470. ArrayDef ::= {"[" ArrayBounds [".." ArrayBounds] "]"}+
+471. ArrayBounds ::= SingleConstExpression
+/* STATIC SEMANTICS - ArrayBounds will resolve to a non negative value of integer type */
+
+A.1.6.4	Value
+472. Value ::= PredefinedValue | ReferencedValue
+473. PredefinedValue ::= BitStringValue |
+                         BooleanValue |
+                         CharStringValue |
+                         IntegerValue |
+                         OctetStringValue |
+                         HexStringValue |
+                         VerdictTypeValue |
+                         EnumeratedValue |
+                         FloatValue |
+                         AddressValue |
+                         OmitValue
+474. BitStringValue ::= Bstring
+475. BooleanValue ::= "true" | "false"
+476. IntegerValue ::= Number
+477. OctetStringValue ::= Ostring
+478. HexStringValue ::= Hstring
+479. VerdictTypeValue ::= "pass" | "fail" | "inconc" | "none" | "error"
+480. EnumeratedValue ::= EnumerationIdentifier
+481. CharStringValue ::= Cstring | Quadruple
+482. Quadruple ::= CharKeyword "(" Group "," Plane "," Row "," Cell ")"
+483. CharKeyword ::= "char"
+484. Group ::= Number
+485. Plane ::= Number
+486. Row ::= Number
+487. Cell ::= Number
+488. FloatValue ::= FloatDotNotation | FloatENotation | NaNKeyword
+489. NaNKeyword ::= "not_a_number"
+490. FloatDotNotation ::= Number Dot DecimalNumber
+491. FloatENotation ::= Number [Dot DecimalNumber] Exponential [Minus] Number
+492. Exponential ::= "E"
+493. ReferencedValue ::= ValueReference [ExtendedFieldReference]
+494. ValueReference ::= [GlobalModuleId Dot] (ConstIdentifier | ExtConstIdentifier |
+                        ModuleParIdentifier ) |
+                        ValueParIdentifier |
+                        VarIdentifier
+495. Number ::= (NonZeroNum {Num}) | "0"
+496. NonZeroNum ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
+497. DecimalNumber ::= {Num}+
+498. Num ::= "0" | NonZeroNum
+499. Bstring ::= "'" {Bin} "'" "B"
+500. Bin ::= "0" | "1"
+501. Hstring ::= "'" {Hex} "'" "H"
+502. Hex ::= Num | "A" | "B" | "C" | "D" | "E" | "F"| "a" | "b" | "c" | "d" | "e" | "f"
+503. Ostring ::= "'" {Oct} "'" "O"
+504. Oct ::= Hex Hex
+505. Cstring ::= """ {Char} """
+506. Char ::= /* REFERENCE - A character defined by the relevant CharacterString type. For charstring a character from the character set defined in ISO/IEC 646. For universal charstring a character from any character set defined in ISO/IEC 10646 */
+507. Identifier ::= Alpha{AlphaNum | Underscore}
+508. Alpha ::= UpperAlpha | LowerAlpha
+509. AlphaNum ::= Alpha | Num
+510. UpperAlpha ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
+511. LowerAlpha ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
+512. ExtendedAlphaNum ::= /* REFERENCE - A graphical character from the BASIC LATIN or from the LATIN-1 SUPPLEMENT character sets defined in ISO/IEC 10646  (characters from char (0,0,0,32) to char (0,0,0,126), from char (0,0,0,161) to char (0,0,0,172) and from char (0,0,0,174) to char (0,0,0,255) */
+513. FreeText ::= """ {ExtendedAlphaNum} """
+514. AddressValue ::= "null"
+515. OmitValue ::= OmitKeyword
+516. OmitKeyword ::= "omit"
+
+A.1.6.5	Parameterization
+517. InParKeyword ::= "in"
+518. OutParKeyword ::= "out"
+519. InOutParKeyword ::= "inout"
+520. FormalValuePar ::= [(InParKeyword | InOutParKeyword | OutParKeyword)]
+                        Type ValueParIdentifier [ ":=" ( Expression | Dash ) ]
+521. ValueParIdentifier ::= Identifier
+522. FormalPortPar ::= [InOutParKeyword] PortTypeIdentifier PortParIdentifier
+523. PortParIdentifier ::= Identifier
+524. FormalTimerPar ::= [InOutParKeyword] TimerKeyword TimerParIdentifier
+525. TimerParIdentifier ::= Identifier
+526. FormalTemplatePar ::= [( InParKeyword | OutParKeyword | InOutParKeyword )]
+                           ( TemplateKeyword | RestrictedTemplate ) 
+                           Type TemplateParIdentifier [ ":=" ( TemplateInstance | Dash ) ]
+527. TemplateParIdentifier ::= Identifier
+528. RestrictedTemplate ::= OmitKeyword | ( TemplateKeyword TemplateRestriction )
+529. TemplateRestriction ::= "(" ( OmitKeyword | ValueKeyword | PresentKeyword ) ")"
+
+A.1.6.6	With statement
+530. WithStatement ::= WithKeyword WithAttribList
+531. WithKeyword ::= "with"
+532. WithAttribList ::= "{" MultiWithAttrib "}"
+533. MultiWithAttrib ::= {SingleWithAttrib [SemiColon]}
+534. SingleWithAttrib ::= AttribKeyword  [OverrideKeyword] [AttribQualifier] AttribSpec
+535. AttribKeyword ::= EncodeKeyword |
+                       VariantKeyword |
+                       DisplayKeyword |
+                       ExtensionKeyword |
+                       OptionalKeyword
+536. EncodeKeyword ::= "encode"
+537. VariantKeyword ::= "variant"
+538. DisplayKeyword ::= "display"
+539. ExtensionKeyword ::= "extension"
+540. OverrideKeyword ::= "override"
+541. AttribQualifier ::= "(" DefOrFieldRefList ")"
+542. DefOrFieldRefList ::= DefOrFieldRef {"," DefOrFieldRef}
+543. DefOrFieldRef ::= DefinitionRef | 
+                       ( FieldReference [ ExtendedFieldReference ] ) | 
+                       ( "[" NotUsedSymbol | SingleExpression "]" ) | 
+                       AllRef
+544. DefinitionRef ::= StructTypeIdentifier |
+                       EnumTypeIdentifier |
+                       PortTypeIdentifier |
+                       ComponentTypeIdentifier |
+                       SubTypeIdentifier |
+                       ConstIdentifier |
+                       TemplateIdentifier |
+                       AltstepIdentifier |
+                       TestcaseIdentifier |
+                       FunctionIdentifier |
+                       SignatureIdentifier |
+                       VarIdentifier |
+                       TimerIdentifier |
+                       PortIdentifier |
+                       ModuleParIdentifier |
+                       FullGroupIdentifier
+545. AllRef ::= ( GroupKeyword AllKeyword [ExceptKeyword "{" GroupRefList "}"]) |
+                ( TypeDefKeyword AllKeyword [ExceptKeyword "{" TypeRefList "}"]) |
+                ( TemplateKeyword AllKeyword [ExceptKeyword "{" TemplateRefList "}"]) |
+                ( ConstKeyword AllKeyword [ExceptKeyword "{" ConstRefList "}"]) |
+                ( AltstepKeyword AllKeyword [ExceptKeyword "{" AltstepRefList "}"]) |
+                ( TestcaseKeyword AllKeyword [ExceptKeyword "{" TestcaseRefList "}"]) |
+                ( FunctionKeyword AllKeyword [ExceptKeyword "{" FunctionRefList "}"]) |
+                ( SignatureKeyword AllKeyword [ExceptKeyword "{" SignatureRefList "}"]) |
+                ( ModuleParKeyword AllKeyword [ExceptKeyword "{" ModuleParRefList "}"]) 
+546. AttribSpec ::= FreeText
+
+A.1.6.7	Behaviour statements
+547. BehaviourStatements ::= TestcaseInstance |
+                             FunctionInstance |
+                             ReturnStatement |
+                             AltConstruct |
+                             InterleavedConstruct |
+                             LabelStatement |
+                             GotoStatement |
+                             RepeatStatement |
+                             DeactivateStatement |
+                             AltstepInstance |
+                             ActivateOp |
+                             BreakStatement |
+                             ContinueStatement
+548. VerdictStatements ::= SetLocalVerdict
+549. VerdictOps ::= GetLocalVerdict
+550. SetLocalVerdict ::= SetVerdictKeyword "(" SingleExpression { "," LogItem } ")"
+551. SetVerdictKeyword ::= "setverdict"
+552. GetLocalVerdict ::= "getverdict"
+553. SUTStatements ::= ActionKeyword "(" ActionText {StringOp ActionText} ")"
+554. ActionKeyword ::= "action"
+555. ActionText ::= FreeText | Expression
+556. ReturnStatement ::= ReturnKeyword [Expression | InLineTemplate]
+/* STATIC SEMANTICS - Expression shall evaluate to a value of a type compatible with the return type for functions returning a value. It shall evaluate to a value, template (literal or template instance), or a matching mechanism compatible with the return type for functions returning a template. */
+557. AltConstruct ::= AltKeyword "{" AltGuardList "}"
+558. AltKeyword ::= "alt"
+559. AltGuardList ::= {GuardStatement | ElseStatement [SemiColon]}
+560. GuardStatement ::= AltGuardChar (AltstepInstance [StatementBlock] | GuardOp StatementBlock)
+561. ElseStatement ::= "["ElseKeyword "]" StatementBlock
+562. AltGuardChar ::= "[" [BooleanExpression] "]"
+563. GuardOp ::= TimeoutStatement |
+                 ReceiveStatement |
+                 TriggerStatement |
+                 GetCallStatement |
+                 CatchStatement |
+                 CheckStatement |
+                 GetReplyStatement |
+                 DoneStatement |
+                 KilledStatement
+564. InterleavedConstruct ::= InterleavedKeyword "{" InterleavedGuardList "}"
+565. InterleavedKeyword ::= "interleave"
+566. InterleavedGuardList ::= {InterleavedGuardElement [SemiColon]}+
+567. InterleavedGuardElement ::= InterleavedGuard InterleavedAction
+568. InterleavedGuard ::= "[" "]" GuardOp
+569. InterleavedAction ::= StatementBlock
+570. LabelStatement ::= LabelKeyword LabelIdentifier
+571. LabelKeyword ::= "label"
+572. LabelIdentifier ::= Identifier
+573. GotoStatement ::= GotoKeyword LabelIdentifier
+574. GotoKeyword ::= "goto"
+575. RepeatStatement ::= "repeat"
+576. ActivateOp ::= ActivateKeyword "(" AltstepInstance ")"
+577. ActivateKeyword ::= "activate"
+578. DeactivateStatement ::= DeactivateKeyword ["(" ComponentOrDefaultReference ")"]
+579. DeactivateKeyword ::= "deactivate"
+580. BreakStatement ::= "break"
+581. ContinueStatement ::= "continue"
+
+A.1.6.8	Basic statements
+582. BasicStatements ::= Assignment | LogStatement | LoopConstruct | ConditionalConstruct |
+                         SelectCaseConstruct | StatementBlock
+583. Expression ::= SingleExpression | CompoundExpression
+584. CompoundExpression ::= FieldExpressionList | ArrayExpression
+/* STATIC SEMANTICS - Within CompoundExpression the ArrayExpression can be used for Arrays, record, record of and set of types. */
+585. FieldExpressionList ::= "{" FieldExpressionSpec {"," FieldExpressionSpec} "}"
+586. FieldExpressionSpec ::= FieldReference AssignmentChar NotUsedOrExpression
+587. ArrayExpression ::= "{" [ArrayElementExpressionList] "}"
+588. ArrayElementExpressionList ::= NotUsedOrExpression  {"," NotUsedOrExpression}
+589. NotUsedOrExpression ::= Expression | NotUsedSymbol
+590. ConstantExpression ::= SingleConstExpression | CompoundConstExpression
+591. SingleConstExpression ::= SingleExpression
+592. BooleanExpression ::= SingleExpression
+/* STATIC SEMANTICS - BooleanExpression shall resolve to a Value of type Boolean */
+593. CompoundConstExpression ::= FieldConstExpressionList | ArrayConstExpression
+/* STATIC SEMANTICS - Within CompoundConstExpression the ArrayConstExpression can be used for arrays, record, record of and set of types. */
+594. FieldConstExpressionList ::= "{" FieldConstExpressionSpec {"," FieldConstExpressionSpec} "}"
+595. FieldConstExpressionSpec ::= FieldReference AssignmentChar ConstantExpression
+596. ArrayConstExpression ::= "{" [ArrayElementConstExpressionList] "}"
+597. ArrayElementConstExpressionList ::= ConstantExpression {"," ConstantExpression}
+598. Assignment ::= VariableRef AssignmentChar (Expression | TemplateBody)
+/* STATIC SEMANTICS - The Expression on the right hand side of Assignment shall evaluate to an explicit value of a type compatible with the type of the left hand side for value variables and shall evaluate to an explicit value, template (literal or a template instance) or a matching mechanism compatible with the type of the left hand side for template variables. */
+599. SingleExpression ::= XorExpression { "or" XorExpression }
+/* STATIC SEMANTICS - If more than one XorExpression exists, then the XorExpressions shall evaluate to specific values of compatible types */
+600. XorExpression ::= AndExpression { "xor" AndExpression }
+/* STATIC SEMANTICS - If more than one AndExpression exists, then the AndExpressions shall evaluate to specific values of compatible types */
+601. AndExpression ::= NotExpression { "and" NotExpression }
+/* STATIC SEMANTICS - If more than one NotExpression exists, then the NotExpressions shall evaluate to specific values of compatible types */
+602. NotExpression ::= [ "not" ] EqualExpression
+/* STATIC SEMANTICS - Operands of the not operator shall be of type boolean or derivatives of type Boolean. */
+603. EqualExpression ::= RelExpression { EqualOp RelExpression }
+/* STATIC SEMANTICS - If more than one RelExpression exists, then the RelExpressions shall evaluate to specific values of compatible types */
+604. RelExpression ::= ShiftExpression [ RelOp ShiftExpression ]
+/* STATIC SEMANTICS - If both ShiftExpressions exist, then each ShiftExpression shall evaluate to a specific integer, Enumerated or float Value or derivatives of these types */
+605. ShiftExpression ::= BitOrExpression { ShiftOp BitOrExpression }
+/* STATIC SEMANTICS - Each Result shall resolve to a specific Value. If more than one Result exists the right-hand operand shall be of type integer or derivatives and if the shift op is "<<" or ">>" then the left-hand operand shall resolve to either bitstring, hexstring or octetstring type or derivatives of these types. If the shift op is "<@" or "@>" then the left-hand operand shall be of type bitstring, hexstring, octetstring, charstring, universal charstring, record of, set of, or array, or derivatives of these types */
+606. BitOrExpression ::= BitXorExpression { "or4b" BitXorExpression }
+/* STATIC SEMANTICS - If more than one BitXorExpression exists, then the BitXorExpressions shall evaluate to specific values of compatible types */
+607. BitXorExpression ::= BitAndExpression { "xor4b" BitAndExpression }
+/* STATIC SEMANTICS - If more than one BitAndExpression exists, then the BitAndExpressions shall evaluate to specific values of compatible types */
+608. BitAndExpression ::= BitNotExpression { "and4b" BitNotExpression }
+/* STATIC SEMANTICS - If more than one BitNotExpression exists, then the BitNotExpressions shall evaluate to specific values of compatible types */
+609. BitNotExpression ::= [ "not4b" ] AddExpression
+/* STATIC SEMANTICS - If the not4b operator exists, the operand shall be of type bitstring, octetstring or hexstring or derivatives of these types. */
+610. AddExpression ::= MulExpression { AddOp MulExpression }
+/* STATIC SEMANTICS - Each MulExpression shall resolve to a specific Value. If more than one MulExpression exists and the AddOp resolves to StringOp then the MulExpressions shall be valid operands for StringOp. If more than one MulExpression exists and the AddOp does not resolve to StringOp then the MulExpression shall both resolve to type integer or float or derivatives of these types.*/
+611. MulExpression ::= UnaryExpression { MultiplyOp UnaryExpression }
+/* STATIC SEMANTICS - Each UnaryExpression shall resolve to a specific Value. If more than one UnaryExpression exists then the UnaryExpressions shall resolve to type integer or float or derivatives of these types. */
+612. UnaryExpression ::= [ UnaryOp ] Primary
+/* STATIC SEMANTICS - Primary shall resolve to a specific Value of type integer or float or derivatives of these types.*/
+613. Primary ::= OpCall | Value | "(" SingleExpression ")"
+614. ExtendedFieldReference ::= { ( Dot ( StructFieldIdentifier | TypeDefIdentifier ) )
+                                  | ArrayOrBitRef 
+                                  | ( "[" NotUsedSymbol "]" ) }+
+/* STATIC SEMANTIC - The TypeDefIdentifier shall be used only if the type of the VarInstance or ReferencedValue in which the ExtendedFieldReference is used is anytype. 
+ArrayOrBitRef shall be used when referencing elements of values or arrays.
+The square brackets with dash shall be used when referencing inner types of a record of or set of type. */
+615. OpCall ::= ConfigurationOps |
+                VerdictOps |
+                TimerOps |
+                TestcaseInstance |
+                ( FunctionInstance [ ExtendedFieldReference ] ) |
+                ( TemplateOps [ ExtendedFieldReference ] ) |
+                ActivateOp
+616. AddOp ::= "+" | "-" | StringOp
+/* STATIC SEMANTICS - Operands of the "+" or "-" operators shall be of type integer or float or derivations of integer or float (i.e. subrange) */
+617. MultiplyOp ::= "*" | "/" | "mod" | "rem"
+/* STATIC SEMANTICS - Operands of the "*", "/", rem or mod operators shall be of type integer or float or derivations of integer or float (i.e. subrange) */
+618. UnaryOp ::= "+" | "-"
+/* STATIC SEMANTICS - Operands of the "+" or "-" operators shall be of type integer or float or derivations of integer or float (i.e. subrange) */
+619. RelOp ::= "<" | ">" | ">=" | "<="
+/* STATIC SEMANTICS - the precedence of the operators is defined in Table 6 */
+620. EqualOp ::= "==" | "!="  
+621. StringOp ::= "&"
+/* STATIC SEMANTICS - Operands of the list operator shall be bitstring, hexstring, octetstring, (universal) character string, record of, set of, or array types, or derivates of these types */
+622. ShiftOp ::= "<<" | ">>" | "<@" | "@>"
+623. LogStatement ::= LogKeyword "(" LogItem { "," LogItem } ")"
+624. LogKeyword ::= "log"
+625. LogItem ::= FreeText | TemplateInstance
+626. LoopConstruct ::= ForStatement |
+                       WhileStatement |
+                       DoWhileStatement
+627. ForStatement ::= ForKeyword "(" Initial SemiColon Final SemiColon Step ")"
+                      StatementBlock
+628. ForKeyword ::= "for"
+629. Initial ::= VarInstance | Assignment
+630. Final ::= BooleanExpression
+631. Step ::= Assignment
+632. WhileStatement ::= WhileKeyword "(" BooleanExpression ")"
+                        StatementBlock
+633. WhileKeyword ::= "while"
+634. DoWhileStatement ::= DoKeyword StatementBlock
+                          WhileKeyword "(" BooleanExpression ")"
+635. DoKeyword ::= "do"
+636. ConditionalConstruct ::= IfKeyword "(" BooleanExpression ")"
+                              StatementBlock
+                              {ElseIfClause}[ElseClause]
+637. IfKeyword ::= "if"
+638. ElseIfClause ::= ElseKeyword IfKeyword "(" BooleanExpression ")"  StatementBlock
+639. ElseKeyword ::= "else"
+640. ElseClause ::= ElseKeyword StatementBlock
+641. SelectCaseConstruct ::= SelectKeyword "(" SingleExpression ")" SelectCaseBody
+642. SelectKeyword ::= "select"
+643. SelectCaseBody ::= "{" { SelectCase }+ "}"
+644. SelectCase ::= CaseKeyword ( "(" TemplateInstance {"," TemplateInstance } ")" | ElseKeyword )
+                    StatementBlock
+645. CaseKeyword ::= "case"
+
+A.1.6.9	Miscellaneous productions
+646. Dot ::= "."
+647. Dash ::= "-"
+648. Minus ::= Dash
+649. SemiColon ::= ";"
+650. Colon ::= ":"
+651. Underscore ::= "_"
+652. AssignmentChar ::= ":="
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/templates/Antlr3.xpt
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/templates/Antlr3.xpt	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/templates/Antlr3.xpt	(revision 5)
@@ -0,0 +1,110 @@
+«IMPORT ebnf»
+«EXTENSION org::eclipse::xtend::util::stdlib::globalvar»
+
+«REM» ========================================================================== «ENDREM»
+
+«DEFINE Root FOR EtsiBnf-»
+	«FOREACH rule AS r-»
+		«EXPAND check(r.name) FOR r-»
+	«ENDFOREACH-»
+	
+	«FILE name+".g"-»
+		grammar «name»;
+		
+		options { 
+			backtrack = true;
+			memoize = true;
+		}
+		
+		«FOREACH rule AS r-»
+			«IF (getGlobalVar(r.name.toLowerCase()) != null)-»
+				«IF r.name.toLowerCase() == "final"»
+					finalRule:
+				«ELSE»
+					«r.name.toLowerCase()-»:
+				«ENDIF»
+			«ELSE-»
+				«r.name.toUpperCase()-»:
+			«ENDIF-»
+			«EXPAND DefStart FOR r.definitionList-»
+				;
+
+		«ENDFOREACH-»
+	«ENDFILE-»
+«ENDDEFINE»
+
+«REM» ========================================================================== «ENDREM»
+
+«DEFINE check(String name) FOR emf::EObject»
+	«IF (this.metaType == RuleReference)-» 
+		«storeGlobalVar(name.toLowerCase(), name.toLowerCase())»
+	«ELSEIF this.eContents.size != 0-»
+		«EXPAND check(name) FOREACH this.eContents-»
+	«ENDIF-»
+«ENDDEFINE»
+
+«REM» ========================================================================== «ENDREM»
+
+«DEFINE OptionalSequenceStart FOR OptionalSequence-» 
+	(«EXPAND DefStart FOREACH definitionList-»)? 
+«ENDDEFINE»
+
+«REM» ========================================================================== «ENDREM»
+
+«DEFINE GroupedSequenceStart FOR GroupedSequence-» 
+	(«EXPAND DefStart FOREACH this.definitionList-») 
+«ENDDEFINE»
+
+«REM» ========================================================================== «ENDREM»
+
+«DEFINE RepeatedSequenceStart FOR RepeatedSequence-» 
+	(
+	«EXPAND DefStart FOREACH definitions-»
+	«IF this.morethanonce==true-»
+		)+ 
+	«ELSE-»
+		)* 
+	«ENDIF-»
+«ENDDEFINE»
+
+«REM» ========================================================================== «ENDREM»
+
+«DEFINE DefStart FOR DefinitionList-»
+	«FOREACH singleDefinition AS singleDef ITERATOR iter-»
+		«IF !iter.firstIteration-» | «ENDIF-»
+		
+		«FOREACH singleDef.terms AS t-»
+			«IF t.termAtom != null-»
+				«IF t.termAtom.atomStringRule != null-»
+					«IF t.termAtom.atomStringRule.colon.length > 0-»
+					'\"'
+					«ELSE»
+						«IF t.termAtom.atomStringRule.literal == "\\"-»
+							'\\'
+						«ELSEIF t.termAtom.atomStringRule.literal == "'"-»
+							'\''
+						«ELSE»
+							'«t.termAtom.atomStringRule.literal-»'
+						«ENDIF»
+					«ENDIF» 
+				«ELSEIF t.termAtom.atomRuleReference != null-»
+					«IF (getGlobalVar(t.termAtom.atomRuleReference.ruleref.name.toLowerCase()) != null)-» 
+						«IF t.termAtom.atomRuleReference.ruleref.name.toLowerCase() == "final"»
+							finalRule
+						«ELSE»
+							«t.termAtom.atomRuleReference.ruleref.name.toLowerCase()-» 
+						«ENDIF»
+					«ELSE-» 
+						«t.termAtom.atomRuleReference.ruleref.name.toUpperCase()-» 
+					«ENDIF-» 
+				«ENDIF-»
+			«ELSEIF t.termGroupedSequence != null-» 
+				«EXPAND GroupedSequenceStart FOR t.termGroupedSequence-»
+			«ELSEIF t.termOptionalSequence != null-» 
+				«EXPAND OptionalSequenceStart FOR t.termOptionalSequence-»
+			«ELSEIF t.termRepeatedSequence != null-» 
+				«EXPAND RepeatedSequenceStart FOR t.termRepeatedSequence-» 
+			«ENDIF-»
+		«ENDFOREACH-»
+	«ENDFOREACH-»
+«ENDDEFINE»
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/templates/Gold.xpt
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/templates/Gold.xpt	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/templates/Gold.xpt	(revision 5)
@@ -0,0 +1,49 @@
+«IMPORT ebnf»
+«EXTENSION org::eclipse::xtend::util::stdlib::globalvar»
+«EXTENSION extensions::SimpleBnf»
+
+«DEFINE Root FOR EtsiBnf-»
+
+«FILE name+".grm"-»
+"Name"		= '«name»'
+"Version"	= '1.0'
+"Author"	= 'BNFTools EBnf Gold Generator'
+"About"		= 'n/a'
+
+"Case Sensitive" = 'True' 
+"Start Symbol"   = <«firstNonGeneratedRule(this).name-»>
+
+«FOREACH rule AS r-»
+<«r.name-»> ::=«EXPAND DefStart FOR r.definitionList-»
+
+«ENDFOREACH-»
+«ENDFILE-»
+
+«ENDDEFINE»
+
+«REM» ========================================================================== «ENDREM»
+
+«REM» ========================================================================== «ENDREM»
+«DEFINE OptionalSequenceStart FOR OptionalSequence-» («EXPAND DefStart FOREACH definitionList-»)?«ENDDEFINE»
+«REM» ========================================================================== «ENDREM»
+
+«REM» ========================================================================== «ENDREM»
+«DEFINE GroupedSequenceStart FOR GroupedSequence-» («EXPAND DefStart FOREACH this.definitionList-»)«ENDDEFINE»
+«REM» ========================================================================== «ENDREM»
+
+«REM» ========================================================================== «ENDREM»
+«DEFINE RepeatedSequenceStart FOR RepeatedSequence-» («EXPAND DefStart FOREACH definitions-»«IF this.morethanonce==true-»)+«ELSE-»)*«ENDIF-»«ENDDEFINE»
+«REM» ========================================================================== «ENDREM»
+
+«REM» ========================================================================== «ENDREM»
+«DEFINE DefStart FOR DefinitionList-»
+«FOREACH singleDefinition AS singleDef ITERATOR iter-»
+«IF !iter.firstIteration-» |«ENDIF-»
+«FOREACH singleDef.terms AS t-»«IF t.termAtom != null-»«IF t.termAtom.atomStringRule != null-» «IF t.termAtom.atomStringRule.literal == "'"»'\"'«ELSE»'«t.termAtom.atomStringRule.literal-»'«ENDIF»«ELSEIF t.termAtom.atomRuleReference != null-» <«t.termAtom.atomRuleReference.ruleref.name-»>«ELSEIF t.termGroupedSequence != null-»«EXPAND GroupedSequenceStart FOR t.termGroupedSequence-»«ELSEIF t.termOptionalSequence != null-»«EXPAND OptionalSequenceStart FOR t.termOptionalSequence-»«ELSEIF t.termRepeatedSequence != null-»«EXPAND RepeatedSequenceStart FOR t.termRepeatedSequence-»
+«ENDIF-»
+«ENDIF-»
+«ENDFOREACH-»
+«ENDFOREACH-»
+«ENDDEFINE»
+«REM» ========================================================================== «ENDREM»
+
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/workflow/AntlrGenerator.mwe2
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/workflow/AntlrGenerator.mwe2	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/workflow/AntlrGenerator.mwe2	(revision 5)
@@ -0,0 +1,40 @@
+module workflow.AntlrGenerator
+
+import org.eclipse.emf.mwe.utils.*
+
+var targetDir = "src-gen"
+var fileEncoding = "Cp1252"
+var modelPath = "src/model"
+
+Workflow {
+
+	component = org.eclipse.xtext.mwe.Reader {
+		// lookup all resources on the classpath
+		// useJavaClassPath = true
+
+		// or define search scope explicitly
+		path = modelPath
+
+		// this class will be generated by the xtext generator 
+		register = de.ugoe.cs.swe.bnftools.EbnfStandaloneSetup {}
+		load = {
+			slot = "model"
+			type = "EtsiBnf"
+		}
+	}  
+
+	component = org.eclipse.xpand2.Generator {
+		metaModel = org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel {}
+//		output = org.eclipse.xpand2.output.BlankLineSkippingOutput {}
+		expand = "templates::Antlr3::Root FOREACH model"
+		outlet = {
+			path = targetDir
+		}
+		outlet = {
+		 	name = "ruleasd"
+			append = true
+			path = targetDir
+		 }
+		fileEncoding = fileEncoding
+	}
+}
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/workflow/GoldGenerator.mwe2
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/workflow/GoldGenerator.mwe2	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/workflow/GoldGenerator.mwe2	(revision 5)
@@ -0,0 +1,58 @@
+module workflow.GoldGenerator
+
+import org.eclipse.emf.mwe.utils.*
+
+var modelPath = "src/model"
+var targetDir = "src-gen"
+var fileEncoding = "Cp1252"
+
+Workflow {
+
+	component = org.eclipse.xtext.mwe.Reader {
+		// lookup all resources on the classpath
+		// useJavaClassPath = true
+		
+		// or define search scope explicitly
+		path = modelPath
+		uriFilter = org.eclipse.xtext.mwe.NameBasedFilter {
+//			regularExpression="repeatedRuleTest1.*"
+//			regularExpression="repeatedRuleTest2.*"
+//			regularExpression="groupRuleTest.*"
+			regularExpression="optional.*"
+//			regularExpression="ttcn3-4.2.1-draft.*"
+		}
+
+		// this class will be generated by the xtext generator 
+		register = de.ugoe.cs.swe.bnftools.EbnfStandaloneSetup {}
+		load = {
+			slot = "model"
+			type = "EtsiBnf"
+		}
+	}  
+
+	component = org.eclipse.xtend.XtendComponent {
+		metaModel = org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel {}
+		invoke = "extensions::SimpleBnf::transform(model)"
+		outputSlot = "simplebnfmodel"
+	}
+
+	component = Writer {
+//		useSingleGlobalResourceSet = true
+//		cloneSlotContents = true
+		modelSlot = "simplebnfmodel"
+		uri = "src-gen/newModel.xmi"
+	}
+
+	component = org.eclipse.xpand2.Generator {
+		metaModel = org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel {}
+
+		expand = "templates::Gold::Root FOREACH simplebnfmodel"
+		outlet = {
+//			name = "ruleasd"
+//			append = true
+			path = targetDir
+		 }
+		fileEncoding = fileEncoding
+	}
+
+}
Index: trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/workflow/SimpleBnfGenerator.mwe2
===================================================================
--- trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/workflow/SimpleBnfGenerator.mwe2	(revision 5)
+++ trunk/de.ugoe.cs.swe.bnftools.ebnf.generator/src/workflow/SimpleBnfGenerator.mwe2	(revision 5)
@@ -0,0 +1,43 @@
+module workflow.SimpleBnfGenerator
+
+import org.eclipse.emf.mwe.utils.*
+
+var modelPath = "src/model"
+
+
+
+Workflow {
+
+	component = org.eclipse.xtext.mwe.Reader {
+		// lookup all resources on the classpath
+		// useJavaClassPath = true
+
+		// or define search scope explicitly
+		path = modelPath
+		uriFilter = org.eclipse.xtext.mwe.NameBasedFilter {
+			regularExpression="repeatedRuleTest1.*"
+//			regularExpression="repeatedRuleTest2.*"
+//			regularExpression="optional.*"
+		}
+
+		// this class will be generated by the xtext generator 
+		register = de.ugoe.cs.swe.bnftools.EbnfStandaloneSetup {}
+		load = {
+			slot = "model"
+			type = "EtsiBnf"
+		}
+	}  
+
+	component = org.eclipse.xtend.XtendComponent {
+		metaModel = org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel {}
+		invoke = "extensions::SimpleBnf::transform(model)"
+		outputSlot = "simplebnfmodel"
+	}
+
+	component = Writer {
+		useSingleGlobalResourceSet = true
+		modelSlot = "simplebnfmodel"
+		uri = "src-gen/newModel.xmi"
+	}
+	
+}
