From 73be2f2dbaa15e89a2bf765c84a4b8a7b847f5ca Mon Sep 17 00:00:00 2001
From: Andrea Enrici <andrea.enrici@nokia.com>
Date: Thu, 15 Jan 2015 09:25:44 +0000
Subject: [PATCH] corrected a bug in parsing the fork-join

---
 src/compiler/tmlCPparser/CPparserDEF.jjt | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/compiler/tmlCPparser/CPparserDEF.jjt b/src/compiler/tmlCPparser/CPparserDEF.jjt
index 5c5f51fd09..5ed59e7729 100644
--- a/src/compiler/tmlCPparser/CPparserDEF.jjt
+++ b/src/compiler/tmlCPparser/CPparserDEF.jjt
@@ -524,8 +524,6 @@ void parseReferenceToDiagram( TMLCP mainCP ):
 	}
 }
 
-//Modify the data structure of the activity diagram as TMLCPElement is an abstract class, so it is not possible to instantiate an
-//ArrayList<TMLCPElement> to be returned after parsing the fork-join
 void parseForkJoin( TMLCP mainCP ):
 {
 	String name;
@@ -541,6 +539,7 @@ void parseForkJoin( TMLCP mainCP ):
 		fork1.addNextElement( currentElement );	//the next element of Fork is only the first element of the sequence
 		globalAD.addElement( currentElement );
 		previousElement = currentElement;
+		TraceManager.addDev( "Je me plante apres" );
 	}
 	// from now on is like parsing a normal sequence, in the sense that I ignore the fact of being inside a fork-join
 	(
@@ -555,15 +554,27 @@ void parseForkJoin( TMLCP mainCP ):
 	)*
 	"}"	// end of the first branch
 	{ previousElement.addNextElement( join1 ); }
+	// then one or more branches
 	( "*" "{" parseReferenceToDiagram( mainCP )
 	{
 		fork1.addNextElement( currentElement );
 		globalAD.addElement( currentElement );
 		previousElement = currentElement;
 	}
-	"}"
+	// from now on is like parsing a normal sequence, in the sense that I ignore the fact of being inside a fork-join
+	(
+	<SEQUENCING_OP> parseReferenceToDiagram( mainCP )
+	{
+		if( currentElement != null )	{
+			previousElement.addNextElement( currentElement );
+			globalAD.addElement( currentElement );
+			previousElement = currentElement;
+		}
+	}
+	)*
+	"}"	// end of a branch
 	{ previousElement.addNextElement( join1 ); }
-	)+	"};"
+	)+	"};"	// end of a whole fork-join
 	{
 		globalAD.addElement( fork1 );
 		globalAD.addElement( join1 );
-- 
GitLab