From 1c8e706bd6f54688f87a1b93ad2a3f008711a1d2 Mon Sep 17 00:00:00 2001 From: Sophie Coudert <sophie.coudert@telecom-paris.fr> Date: Thu, 20 Jun 2024 17:01:19 +0200 Subject: [PATCH] save --- .../tosysmlv2/Avatar2SysML.java | 11 +- .../tosysmlv2/Avatar2SysMLLexer.java | 11 +- .../tosysmlv2/Avatar2SysMLNames.java | 7 + .../tosysmlv2/Avatar2SysMLParser.java | 153 ++++---- .../tosysmlv2/Avatar2SysMLSymbols.java | 4 + .../tosysmlv2/AvatarFromSysML.java | 7 + .../tosysmlv2/AvatarFromSysMLError.java | 44 +++ .../tosysmlv2/AvatarFromSysMLLexer.java | 51 ++- .../tosysmlv2/AvatarFromSysMLSyntax.java | 203 +++++++++- .../tosysmlv2/javacup/Avatar2SysMLLexer.jflex | 1 + .../tosysmlv2/javacup/Avatar2SysMLParser.jcup | 2 - .../tosysmlv2/javacup/AvatarFromSysML.jcup | 38 +- .../tosysmlv2/javacup/AvatarFromSysML.jflex | 39 +- .../tosysmlv2/javacup/compile | 10 +- .../tosysmlv2/javacup/compile2 | 6 +- .../tosysmlv2/package-info.java | 358 ++++++++++++++++++ 16 files changed, 840 insertions(+), 105 deletions(-) create mode 100644 src/main/java/avatartranslator/tosysmlv2/package-info.java diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java index 21c61ce163..f03501521f 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java @@ -47,12 +47,15 @@ import java.util.List; import java.util.ArrayList; - +/** + * Class Avatar2SysMLV2 + * Creation: 20/06/2024 + * + * @author Sophie Coudert + * @version 0.1 20/06/2024 + */ public class Avatar2SysML { - /** - * Memorized while declaring channels, to be reused for generating states - */ class MethodInfo { private String name; private String msgtype; // null for methods that are not signals diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLLexer.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLLexer.java index 4f643483cc..3faf15b59b 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLLexer.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLLexer.java @@ -1,4 +1,4 @@ -/* The following code was generated by JFlex 1.4.3 on 15/06/2024 17:17 */ +/* The following code was generated by JFlex 1.4.3 on 20/06/2024 14:07 */ /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille * @@ -45,8 +45,8 @@ import java_cup.runtime.*; /** * This class is a scanner generated by * <a href="http://www.jflex.de/">JFlex</a> 1.4.3 - * on 15/06/2024 17:17 from the specification file - * <tt>__Avatar2SysMLLexer__.jflex</tt> + * on 20/06/2024 14:07 from the specification file + * <code>__Avatar2SysMLLexer__.jflex</code> */ public class Avatar2SysMLLexer implements java_cup.runtime.Scanner { @@ -285,6 +285,7 @@ public class Avatar2SysMLLexer implements java_cup.runtime.Scanner { /* user code: */ + /** * Creates a new scanner * There is also a java.io.InputStream version of this constructor. @@ -396,7 +397,7 @@ public class Avatar2SysMLLexer implements java_cup.runtime.Scanner { * * All internal variables are reset, the old input stream * <b>cannot</b> be reused (internal buffer is discarded and lost). - * Lexical state is set to <tt>ZZ_INITIAL</tt>. + * Lexical state is set to <code>ZZ_INITIAL</code>. * * @param reader the new input stream */ @@ -439,7 +440,7 @@ public class Avatar2SysMLLexer implements java_cup.runtime.Scanner { /** - * Returns the character at position <tt>pos</tt> from the + * Returns the character at position <code>pos</code> from the * matched text. * * It is equivalent to yytext().charAt(pos), but faster diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java index 0ba091a47a..d7335aec14 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java @@ -35,6 +35,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ +/** + * Class Avatar2SysMLNames + * Creation: 20/06/2024 + * + * @author Sophie Coudert + * @version 0.1 20/06/2024 + */ package avatartranslator.tosysmlv2; import java.io.StringReader; import java.util.List; diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLParser.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLParser.java index c7f8be5b27..71ee53c46f 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLParser.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLParser.java @@ -7,6 +7,7 @@ package avatartranslator.tosysmlv2; import java_cup.runtime.*; import static avatartranslator.tosysmlv2.Avatar2SysMLNames.*; +import java_cup.runtime.ComplexSymbolFactory.Location; import java_cup.runtime.XMLElement; /** CUP v0.11b 20210814 (GIT d69c832) generated parser. @@ -232,11 +233,11 @@ class CUP$Avatar2SysMLParser$actions { case 0: // expr ::= expr PLUS expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " + " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -247,8 +248,8 @@ class CUP$Avatar2SysMLParser$actions { case 1: // $START ::= expr EOF { Object RESULT =null; - int start_valleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).left; - int start_valright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).right; + Location start_valxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).xleft; + Location start_valxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).xright; String start_val = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1).<String>value(); RESULT = start_val; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("$START",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -261,11 +262,11 @@ class CUP$Avatar2SysMLParser$actions { case 2: // expr ::= expr MINUS expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " - " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -276,11 +277,11 @@ class CUP$Avatar2SysMLParser$actions { case 3: // expr ::= expr MULT expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " * " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -291,11 +292,11 @@ class CUP$Avatar2SysMLParser$actions { case 4: // expr ::= expr DIV expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " / " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -306,11 +307,11 @@ class CUP$Avatar2SysMLParser$actions { case 5: // expr ::= expr MOD expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " % " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -321,8 +322,8 @@ class CUP$Avatar2SysMLParser$actions { case 6: // expr ::= MINUS expr { String RESULT =null; - int eleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int eright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location exleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location exright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String e = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = "-" + e; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -333,11 +334,11 @@ class CUP$Avatar2SysMLParser$actions { case 7: // expr ::= expr OR expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " or " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -348,11 +349,11 @@ class CUP$Avatar2SysMLParser$actions { case 8: // expr ::= expr AND expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " and " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -363,8 +364,8 @@ class CUP$Avatar2SysMLParser$actions { case 9: // expr ::= NOT expr { String RESULT =null; - int eleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int eright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location exleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location exright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String e = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = "not " + e; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -375,11 +376,11 @@ class CUP$Avatar2SysMLParser$actions { case 10: // expr ::= expr LT expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " < " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -390,11 +391,11 @@ class CUP$Avatar2SysMLParser$actions { case 11: // expr ::= expr GT expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " > " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -405,11 +406,11 @@ class CUP$Avatar2SysMLParser$actions { case 12: // expr ::= expr LEQ expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " <= " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -420,11 +421,11 @@ class CUP$Avatar2SysMLParser$actions { case 13: // expr ::= expr GEQ expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " >= " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -435,11 +436,11 @@ class CUP$Avatar2SysMLParser$actions { case 14: // expr ::= expr EQ expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " == " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -450,11 +451,11 @@ class CUP$Avatar2SysMLParser$actions { case 15: // expr ::= expr DIF expr { String RESULT =null; - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int rleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int rright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location rxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location rxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String r = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = l + " != " + r; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -465,8 +466,8 @@ class CUP$Avatar2SysMLParser$actions { case 16: // expr ::= LPAR expr RPAR { String RESULT =null; - int eleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).left; - int eright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).right; + Location exleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).xleft; + Location exright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).xright; String e = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1).<String>value(); RESULT = "(" + e + ")"; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -477,8 +478,8 @@ class CUP$Avatar2SysMLParser$actions { case 17: // expr ::= IDENT LPAR RPAR { String RESULT =null; - int ileft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int iright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location ixleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location ixright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String i = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); RESULT = i + "()"; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -489,11 +490,11 @@ class CUP$Avatar2SysMLParser$actions { case 18: // expr ::= IDENT LPAR exprlist RPAR { String RESULT =null; - int ileft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-3)).left; - int iright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-3)).right; + Location ixleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-3)).xleft; + Location ixright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-3)).xright; String i = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-3).<String>value(); - int lleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).left; - int lright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1)).xright; String l = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-1).<String>value(); RESULT = methodSysMLname(i) + "(" + l + ")"; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-3), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -504,8 +505,8 @@ class CUP$Avatar2SysMLParser$actions { case 19: // expr ::= CONSTANT { String RESULT =null; - int eleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int eright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location exleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location exright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String e = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = e; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.peek(), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -516,8 +517,8 @@ class CUP$Avatar2SysMLParser$actions { case 20: // expr ::= IDENT { String RESULT =null; - int eleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int eright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location exleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location exright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String e = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = attributeSysMLname(e); CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("expr",0, CUP$Avatar2SysMLParser$stack.peek(), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -528,8 +529,8 @@ class CUP$Avatar2SysMLParser$actions { case 21: // exprlist ::= expr { String RESULT =null; - int eleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int eright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location exleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location exright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String e = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = e; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("exprlist",1, CUP$Avatar2SysMLParser$stack.peek(), CUP$Avatar2SysMLParser$stack.peek(), RESULT); @@ -540,11 +541,11 @@ class CUP$Avatar2SysMLParser$actions { case 22: // exprlist ::= expr COMMA exprlist { String RESULT =null; - int eleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; - int eright = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).right; + Location exleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xleft; + Location exright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).xright; String e = CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2).<String>value(); - int lleft = (CUP$Avatar2SysMLParser$stack.peek()).left; - int lright = (CUP$Avatar2SysMLParser$stack.peek()).right; + Location lxleft = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xleft; + Location lxright = ((java_cup.runtime.ComplexSymbolFactory.ComplexSymbol)CUP$Avatar2SysMLParser$stack.peek()).xright; String l = CUP$Avatar2SysMLParser$stack.peek().<String>value(); RESULT = e + ", " + l; CUP$Avatar2SysMLParser$result = parser.getSymbolFactory().newSymbol("exprlist",1, CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2), CUP$Avatar2SysMLParser$stack.peek(), RESULT); diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLSymbols.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLSymbols.java index 7d033ac016..ad94b26ae4 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLSymbols.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLSymbols.java @@ -54,5 +54,9 @@ public class Avatar2SysMLSymbols { "IDENT", "CONSTANT" }; + + /* non terminals */ + static final int exprlist = 1; + static final int expr = 0; } diff --git a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java index 0f4ab5e803..bd3344a4bc 100644 --- a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java +++ b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java @@ -35,6 +35,13 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ +/** + * Class AvatarFromSysML + * Creation: 20/06/2024 + * + * @author Sophie Coudert + * @version 0.1 20/06/2024 + */ package avatartranslator.tosysmlv2; import java.io.FileReader; diff --git a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLError.java b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLError.java index 7a3e5aab5e..b1ff7b4b24 100644 --- a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLError.java +++ b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLError.java @@ -1,6 +1,50 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ package avatartranslator.tosysmlv2; import java_cup.runtime.ComplexSymbolFactory.Location; +/** + * Class AvatarFromSysMLError + * Creation: 20/06/2024 + * + * @author Sophie Coudert + * @version 0.1 20/06/2024 + */ public class AvatarFromSysMLError { public static final byte LOWWARNING = 0; public static final byte HIGHWARNING = 1; diff --git a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLLexer.java b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLLexer.java index 83877e34f7..9ef25bc3c6 100644 --- a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLLexer.java +++ b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLLexer.java @@ -1,6 +1,43 @@ -/* The following code was generated by JFlex 1.4.3 on 19/06/2024 15:51 */ - -package avatartranslator.tosysmlv2; +/* The following code was generated by JFlex 1.4.3 on 20/06/2024 14:07 */ + +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.tosysmlv2; import java_cup.runtime.*; import java_cup.runtime.ComplexSymbolFactory.*; import java.util.HashSet; @@ -9,8 +46,8 @@ import avatartranslator.tosysmlv2.AvatarFromSysMLSyntax.*; /** * This class is a scanner generated by * <a href="http://www.jflex.de/">JFlex</a> 1.4.3 - * on 19/06/2024 15:51 from the specification file - * <tt>__AvatarFromSysMLLexer__.jflex</tt> + * on 20/06/2024 14:07 from the specification file + * <code>__AvatarFromSysMLLexer__.jflex</code> */ public class AvatarFromSysMLLexer implements java_cup.runtime.Scanner { @@ -2330,7 +2367,7 @@ public class AvatarFromSysMLLexer implements java_cup.runtime.Scanner { * * All internal variables are reset, the old input stream * <b>cannot</b> be reused (internal buffer is discarded and lost). - * Lexical state is set to <tt>ZZ_INITIAL</tt>. + * Lexical state is set to <code>ZZ_INITIAL</code>. * * @param reader the new input stream */ @@ -2373,7 +2410,7 @@ public class AvatarFromSysMLLexer implements java_cup.runtime.Scanner { /** - * Returns the character at position <tt>pos</tt> from the + * Returns the character at position <code>pos</code> from the * matched text. * * It is equivalent to yytext().charAt(pos), but faster diff --git a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java index 4e72d4d268..83a9686cb3 100644 --- a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java +++ b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java @@ -1,3 +1,41 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.tosysmlv2; import java.util.ArrayList; @@ -8,7 +46,22 @@ import java.util.function.BiConsumer; import avatartranslator.AvatarTransition; import java_cup.runtime.ComplexSymbolFactory.Location; +/** + * Class AvatarFromSysMLSyntax + * Creation: 20/06/2024 + * + * @author Sophie Coudert + * @version 0.1 20/06/2024 + * + * Abstract Syntax "trees" (in fact models) and their components. + * Associated locations (left, right) locate the component with + * line and column in the source file + */ public class AvatarFromSysMLSyntax { + /** (technical) Arrays allowing to set a value at any index. + * + * Missing values are set to null. + */ public static class MyArray<E> extends ArrayList<E> { @Override public E set(int index, E element){ @@ -23,68 +76,151 @@ public class AvatarFromSysMLSyntax { else return super.get(index); } } + /** type of idents generated for datatype names */ public static final byte DATATYPENAME = 0; + /** type of idents generated for block names */ public static final byte BLOCKNAME = 1; + /** type of idents generated for attribute or method names */ public static final byte ATTRIBUTENAME = 2; + /** type of idents generated for relation names */ public static final byte RELATIONNAME = 3; + /** type of idents generated for some part of channel names */ public static final byte CHANNELPRENAME = 4; + /** type of idents generated for signal names */ public static final byte SIGNALNAME = 5; + /** type of idents generated for channel names */ public static final byte CHANNELNAME = 6; + /** type of idents generated for signal profile names */ public static final byte MESSAGENAME = 7; + /** type of idents generated for Avatar state names */ public static final byte STANDARDSTATENAME = 8; + /** type of idents generated for start state names */ public static final byte STARTSTATENAME = 9; + /** type of idents generated for stop state names */ public static final byte STOPSTATENAME = 10; + /** type of idents generated for random operation names */ public static final byte RANDOMSTATENAME = 11; + /** type of idents generated for signal count operation names */ public static final byte COUNTSTATENAME = 12; + /** type of idents generated for signal sending action names */ public static final byte SENDSTATENAME = 13; + /** type of idents generated for signal receiving operation names */ public static final byte RECEIVESTATENAME = 14; + /** type of idents generated for technically added state before sending action names */ public static final byte PRESENDSTATENAME = 15; + /** type of idents generated for technically added state before receiving action names */ public static final byte PRERECEIVESTATENAME = 16; + /** type of idents generated for setting timer action names */ public static final byte SETTIMERSTATENAME = 17; + /** type of idents generated for resetting timer action names */ public static final byte RESETTIMERSTATENAME = 18; + /** type of idents generated for expire timer action names */ public static final byte EXPIRETIMERSTATENAME = 19; + /** type of idents generated for technically added state before setting timer action names */ public static final byte PRESETTIMERSTATENAME = 20; + /** type of idents generated for technically added state before resetting timer action names */ public static final byte PRERESETTIMERSTATENAME = 21; + /** type of idents generated for technically added state before expire timer action names */ public static final byte PREEXPIRETIMERSTATENAME = 22; + /** type of idents generated for timer names */ public static final byte TIMERBLOCKNAME = 23; + /** type of idents generated for any name between quotes that is not of another type */ public static final byte QUOTEDNAME = 24; + /** type of idents generated for Avatar-well-formed ident names */ public static final byte AVATARNAME = 25; + /** type of start states */ public static final byte STXSTARTSTATE = 0; + /** type of stop states */ public static final byte STXSTOPSTATE = 1; + /** type of Avatar states */ public static final byte STXSTANDARDSTATE = 2; + /** type of Random actions */ public static final byte STXRANDOMSTATE = 3; + /** type of count signal actions */ public static final byte STXCOUNTSTATE = 4; + /** type of send actions */ public static final byte STXSENDSTATE = 5; + /** type of receive actions */ public static final byte STXRECEIVESTATE = 6; + /** type of state added before send actions */ public static final byte STXPRESENDSTATE = 7; + /** type of state added before receive actions */ public static final byte STXPRERECEIVESTATE = 8; + /** type of set timer actions */ public static final byte STXSETTIMERSTATE = 9; + /** type of reset timer actions */ public static final byte STXRESETTIMERSTATE = 10; + /** type of expire timer actions */ public static final byte STXEXPIRETIMERSTATE = 11; + /** type of transitions without communication */ public static final byte STXTRIVIALTRANSITION = 0; + /** type of transitions requiring a send action to complete */ public static final byte STXSENDTRANSITION = 1; + /** type of transitions requiring a receive action to complete */ public static final byte STXRECEIVETRANSITION = 2; + /** type of transitions requiring a set timer action to complete */ public static final byte STXSETTIMERTRANSITION = 3; + /** type of transitions requiring a reset timer action to complete */ public static final byte STXRESETTIMERTRANSITION = 4; + /** type of transitions requiring an expire timer action to complete */ public static final byte STXEXPIRETIMERTRANSITION = 5; + /** type of assignment transitions action */ public static final byte STXASSIGNACTION = 0; + /** type of method-call transitions action */ public static final byte STXMETHODACTION = 1; - /** idents collected while parsing an Avatar SysML Model */ + /** idents collected while parsing an Avatar SysML Model + * + * All these idents are without quotes (removed when found while parsing) + */ public static class Ident extends StxElement { + /** type of the ident */ private byte type; - private String sysMLName; + /** sysML ident as found in the source file */ + private String sysMLName; // yet unused. perhaps to remove... + /** Avatar name + * + * different from sysMLName for generated idents: original names are + * restored + */ private String avatarName; - + /** + * builds an ident from a SysML string + * @param _type the ident type + * @param _smlName the SysML string + */ public Ident(byte _type, String _smlName) { super(_smlName.trim()); setTypeName(_type, _smlName.trim()); } + + /** + * builds an ident from a SysML string + * @param _left + * @param _right + * @param _type the ident type + * @param _smlName the SysML string + */ public Ident(Location _left, Location _right, byte _type, String _smlName) { super(_smlName.trim(), _left, _right); setTypeName(_type, _smlName.trim()); }; + + /** + * generally the Avatar name + * @return the associated string + */ @Override public String toString() { return getAvatarName(); } + + /** + * Sets the names. + * + * Extract the Avatar original names from the generated names if relevant. + * If generated, _smlName must be consistant with _type + * + * @param _type known type + * @param _smlName SysML String. + */ private void setTypeName(byte _type, String _smlName) { type = _type; if (type == AVATARNAME) { @@ -111,47 +247,83 @@ public class AvatarFromSysMLSyntax { } } + + /** @return type of the ident */ public byte getType() { return type; } + /** @return the SysML name */ public String getSysMLName() { return sysMLName; } + /** @return the Avatar name */ public String getAvatarName() { return avatarName; } + /** Check ident type */ public boolean is_DATATYPENAME() { return type == DATATYPENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_BLOCKNAME() { return type == BLOCKNAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_ATTRIBUTENAME() { return type == ATTRIBUTENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_RELATIONNAME() { return type == RELATIONNAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_CHANNELPRENAME() { return type == CHANNELPRENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_SIGNALNAME() { return type == SIGNALNAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_CHANNELNAME() { return type == CHANNELNAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_MESSAGENAME() { return type == MESSAGENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_STANDARDSTATENAME() { return type == STANDARDSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_STARTSTATENAME() { return type == STARTSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_STOPSTATENAME() { return type == STOPSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_RANDOMSTATENAME() { return type == RANDOMSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_COUNTSTATENAME() { return type == COUNTSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_SENDSTATENAME() { return type == SENDSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_RECEIVESTATENAME() { return type == RECEIVESTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_PRESENDSTATENAME() { return type == PRESENDSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_PRERECEIVESTATENAME() { return type == PRERECEIVESTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_SETTIMERSTATENAME() { return type == SETTIMERSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_RESETTIMERSTATENAME() { return type == RESETTIMERSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_EXPIRETIMERSTATENAME() { return type == EXPIRETIMERSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_PRESETTIMERSTATENAME() { return type == PRESETTIMERSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_PRERESETTIMERSTATENAME() { return type == PRERESETTIMERSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_PREEXPIRETIMERSTATENAME() { return type == PREEXPIRETIMERSTATENAME || type == AVATARNAME; } + /** Check ident type */ public boolean is_TIMERBLOCKNAME() { return type == TIMERBLOCKNAME || type == AVATARNAME; } } - + /** Class of classified expression terms */ public abstract static class StxTerm extends StxElement { StxTerm(String _name, Location _left, Location _right) { super(_name, _left, _right); } StxTerm(String _name) { super(_name); } public String toString() { return getName(); } } + /** Terms that are int/bool expressions. + * + * They may be identifiers but not identified as such.*/ public static class StxExpr extends StxTerm { public StxExpr(String v) { super(v); } } + /** Terms that are Identifiers */ public static class StxId extends StxTerm { private String value ; public StxId(String v) { super(v); } } + /** Terms that are method call. + * intuitively, a call string is split into a sequence + * "segment ident ... segment ident segment" + * allowing to easyly replace the idents */ public static class StxCall extends StxTerm { private ArrayList<String> segments; private ArrayList<String> idents; @@ -166,6 +338,7 @@ public class AvatarFromSysMLSyntax { public int getNbIdents() { return idents.size(); } public String getSegment(int i) { return segments.get(i); } public String getIdent(int i) { return idents.get(i); } + /** rebuilds the original string by concatenating segments and idents */ public String toString() { StringBuffer result = new StringBuffer(); int size = getNbIdents(); @@ -178,6 +351,9 @@ public class AvatarFromSysMLSyntax { return result.toString(); } } + /** Syntactic elements with a name and locations in the source code. + * When possible, usually the left is the beginning location and the right is the ending one. + */ public abstract static class StxElement { private String name; protected Location defaultLocation = new Location(-1,-1); @@ -192,9 +368,15 @@ public class AvatarFromSysMLSyntax { public void setName(String _name) { name = _name; } public Location getLeft() { return left; } public Location getRight() { return right; } + + /** sets the element as declared + * + * @return true iff the element was not already declared + */ public boolean declare() { boolean res = !declared; declared = true; return res; } public boolean isDeclared() { return declared; } } + /** Typed fields for elements that are structures */ public static class StxField extends StxElement { private String type; public StxField(String _name, String _type) { @@ -208,6 +390,11 @@ public class AvatarFromSysMLSyntax { public String getType() { return type; } public void setType(String _type) { type = _type; } } + + /** Elements that are Structures + * + * they are provided with an ordered list of fields + */ public static class StxStructure extends StxElement { protected MyArray<StxField> fields; public StxStructure(String _name, Location _left, Location _right) { @@ -218,6 +405,12 @@ public class AvatarFromSysMLSyntax { super(_name.trim()); fields = new MyArray<StxField>(); } + + /** add a field at the end of the list of fields. + * + * @param _field the field to add + * @return null if success. Otherwise the field found with same name. + */ public StxField addField(StxField _field){ StxField result = null; for (StxField fld : fields) { @@ -229,7 +422,9 @@ public class AvatarFromSysMLSyntax { if (result == null) fields.add(_field); return result; } + /** amount of fields */ public int getSize() { return fields.size(); } + public StxField getField(int i) { return fields.get(i);} public String getFieldName(int i) { return fields.get(i).getName();} public String getFieldType(int i) { return fields.get(i).getType();} diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLLexer.jflex b/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLLexer.jflex index abcd0e05b2..89f644864b 100644 --- a/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLLexer.jflex +++ b/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLLexer.jflex @@ -51,6 +51,7 @@ import java_cup.runtime.*; %yylexthrow Exception %{ + %} Space = [\ \n\r\t\f] diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLParser.jcup b/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLParser.jcup index b80ffada5a..f2e0f3a204 100644 --- a/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLParser.jcup +++ b/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLParser.jcup @@ -35,8 +35,6 @@ * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. */ - - package avatartranslator.tosysmlv2; import java_cup.runtime.*; diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup b/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup index 4187a9522f..5ff29a785f 100644 --- a/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup +++ b/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup @@ -1,4 +1,40 @@ - + /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ package avatartranslator.tosysmlv2; import java_cup.runtime.*; import java.util.ArrayList; diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jflex b/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jflex index 16e3586000..7ee1a7a9ac 100644 --- a/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jflex +++ b/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jflex @@ -1,4 +1,41 @@ -package avatartranslator.tosysmlv2; +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.tosysmlv2; import java_cup.runtime.*; import java_cup.runtime.ComplexSymbolFactory.*; import java.util.HashSet; diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/compile b/src/main/java/avatartranslator/tosysmlv2/javacup/compile index ebb39dd187..edba2e581a 100755 --- a/src/main/java/avatartranslator/tosysmlv2/javacup/compile +++ b/src/main/java/avatartranslator/tosysmlv2/javacup/compile @@ -8,11 +8,15 @@ SYMBOL_CLASS="Avatar2SysMLSymbols" sed "s/LexerClassName/$LEXER_CLASS/g" $JFLEX_FILE > __${LEXER_CLASS}2__.jflex sed "s/#Symb/$SYMBOL_CLASS/g" __${LEXER_CLASS}2__.jflex > __${LEXER_CLASS}__.jflex -jflex __${LEXER_CLASS}__.jflex +jflex __${LEXER_CLASS}__.jflex rm __${LEXER_CLASS}__.jflex __${LEXER_CLASS}2__.jflex - -java-cup -parser $PARSER_CLASS -symbols $SYMBOL_CLASS $JAVACUP_FILE +sed "s/<tt>/<code>/g" ${LEXER_CLASS}.java > __${LEXER_CLASS}2__.java +sed "s/<\/tt>/<\/code>/g" __${LEXER_CLASS}2__.java > ${LEXER_CLASS}.java +rm __${LEXER_CLASS}2__.java +sed "s/LexerClassName/$LEXER_CLASS/g" $JAVACUP_FILE > __${PARSER_CLASS}2__.jcup +sed "s/ParserClassName/$PARSER_CLASS/g" __${PARSER_CLASS}2__.jcup > __${PARSER_CLASS}__.jcup +java-cup -dump -nonterms -locations -parser $PARSER_CLASS -symbols $SYMBOL_CLASS __${PARSER_CLASS}__.jcup 2> truc rm *~ mv $LEXER_CLASS.java $PARSER_CLASS.java $SYMBOL_CLASS.java .. diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/compile2 b/src/main/java/avatartranslator/tosysmlv2/javacup/compile2 index 882877a0bc..1542c8fd89 100755 --- a/src/main/java/avatartranslator/tosysmlv2/javacup/compile2 +++ b/src/main/java/avatartranslator/tosysmlv2/javacup/compile2 @@ -8,10 +8,12 @@ SYMBOL_CLASS="AvatarFromSysMLSymbols" sed "s/LexerClassName/$LEXER_CLASS/g" $JFLEX_FILE > __${LEXER_CLASS}2__.jflex sed "s/#Symb/$SYMBOL_CLASS/g" __${LEXER_CLASS}2__.jflex > __${LEXER_CLASS}__.jflex -jflex __${LEXER_CLASS}__.jflex +jflex __${LEXER_CLASS}__.jflex rm __${LEXER_CLASS}__.jflex __${LEXER_CLASS}2__.jflex - +sed "s/<tt>/<code>/g" ${LEXER_CLASS}.java > __${LEXER_CLASS}2__.java +sed "s/<\/tt>/<\/code>/g" __${LEXER_CLASS}2__.java > ${LEXER_CLASS}.java +rm __${LEXER_CLASS}2__.java sed "s/LexerClassName/$LEXER_CLASS/g" $JAVACUP_FILE > __${PARSER_CLASS}2__.jcup sed "s/ParserClassName/$PARSER_CLASS/g" __${PARSER_CLASS}2__.jcup > __${PARSER_CLASS}__.jcup java-cup -dump -nonterms -locations -parser $PARSER_CLASS -symbols $SYMBOL_CLASS __${PARSER_CLASS}__.jcup 2> truc diff --git a/src/main/java/avatartranslator/tosysmlv2/package-info.java b/src/main/java/avatartranslator/tosysmlv2/package-info.java new file mode 100644 index 0000000000..9574a808dc --- /dev/null +++ b/src/main/java/avatartranslator/tosysmlv2/package-info.java @@ -0,0 +1,358 @@ + /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +/** + * Package intboolsolver, a generic modular parser/evaluator for + * boolean/integer expressions with variables. + * Creation: 11/04/2023. + * + * <p> This package (IntBoolSolver or IBS) provides a way to parse and + * evaluate boolean/integer expressions. The handling of variables is + * parametrized (thus it can be instantiated in different contexts). The + * package is modular in the sense that expression structure or parsing + * algorithm can be changed without having to modify other components. </p> + * + * <p> The solver may be instantiated by usual expressions with variables + * and their usual evaluation, but it is more generally dedicated to + * two-level structured systems, i.e global specifications build over + * a set of components. Identifiers can be associated to components or + * to specifications. The solver also handles a notion of component/specification + * state that can be interpreted as state machine state. </p> + * <p> To instantiate this generic system, trivial parameters can be used + * when targeting solvers that do not use all the features, such as for example + * a solver for closed expressions (which is provided).</p> + * <ul> + * <li> <p>{@link myutil.intboolsolver.IBSParserAPI + * IBSParserAPI} provides documentation about the functions + * exported by the provided parser instances.</p> + * <p> The way leaves are handled depends on the notions of specification, + * component, specification state, component state and (state machine) + * state of the instance. Thus the corresponding classes are parameters + * of the generic parser.</p> + * <p> The handling of variables relies on an "<b>attribute class</b>" that + * must be provided for each instance (partial implementation is + * provided).</p> + * <p> The parser also relies on an "<b>expression class</b>" which + * implements the structure of the expressions build by the parser (full + * implementations is provided)</p> + * <p> {@link myutil.intboolsolver.IBSStdParser IBSStdParser}, + * {@link myutil.intboolsolver.IBSStdLexer IBSStdLexer} and + * {@link myutil.intboolsolver.IBSStdSymbols IBSStdSymbol} are classes + * generated by a <a href="#javacup">java-cup/jflex parser </a> (sources + * in the "javacup" subdirectory) that implements + * {@link myutil.intboolsolver.IBSParserAPI IBSParserAPI}. + * The additional interface {@link myutil.intboolsolver.IBSScanner + * IBSScanner} abstracts the lexers required by IBS, allowing to make + * them a parameter of the parser. + * </p> + * </li> + * <li> <p>{@link myutil.intboolsolver.IBSExpressions IBSExpressions} + * describes the interface expected for expression handling. It contains two + * kind of methods: methods for building expressions (required by parsing) + * and methods for evaluating expressions (useful for final user, but also + * available for parser implementations).</p> + * <p>{@link myutil.intboolsolver.IBSStdExpressions + * IBSStdExpressions} is a full implementation of {@link + * myutil.intboolsolver.IBSExpressions IBSExpressions}. + * Its classical structure is easy to extend (for example by adding + * operators). W.r.t. {@link myutil.intboolsolver.IBSExpressions + * IBSExpressions}, it provides additional features such as tools + * to identify expression kinds and to access sub-expressions.</p> + * <li> <p>{@link myutil.intboolsolver.IBSAttributes IBSAttributes} + * describes the interface required from the attribute class that must be + * provided for instantiation. It also provides some data shared by all + * instances (some constants and a technical classes). Roughly speaking, + * this class provides an interpretation for variables.</p> + * <p>{@link myutil.intboolsolver.IBSStdAttributes + * IBSStdAttributes} extends {@link + * myutil.intboolsolver.IBSAttributes IBSAttributes}. It + * provides a partial implementation so that instances just have + * to provide low level methods.</p> + * <li><p>{@link myutil.intboolsolver.IBSParamSpec IBSParamSpec}, + * {@link myutil.intboolsolver.IBSParamComp IBSParamComp}, + * {@link myutil.intboolsolver.IBSParamState IBSParamState}, + * {@link myutil.intboolsolver.IBSParamSpecState IBSParamSpecState} + * and {@link myutil.intboolsolver.IBSParamCompState IBSParamCompState} are + * trivial classes used for technical reasons. The corresponding concrete + * classes provided for instantiation must extend them. They are the type + * of the parameters of the generic parser. Thus to instantiate a parser we + * have to provide:</p> + * <ul> + * <li> <p>a {@code Spec} class, which <b>must implement</b> {@link + * myutil.intboolsolver.IBSParamSpec IBSParamSpec}: the class of + * global system specifications, which intuitively associates + * structures to specification level variables.</p> + * </li> + * <li> <p>a {@code Comp} class, which <b>must implement</b> {@link + * myutil.intboolsolver.IBSParamComp IBSParamComp}: the class + * of system components, which intuitively associates + * structures to component level variables.</p> + * </li> + * <li> <p>a {@code State} class, which <b>must implement</b> + * {@link myutil.intboolsolver.IBSParamState IBSParamState}: + * a class of states. In provided extension + * {@link myutil.intboolsolver.IBSStdAttributes IBSStdAttributes}, + * these states are state machine states associated to components. + * </p> + * </li> + * <li> <p>a {@code SpecState} class, which <b>must implement</b> + * {@link myutil.intboolsolver.IBSParamSpecState + * IBSParamSpecState}: the class of specification state, which + * associates int/bool values to specification level variables.</p> + * </li> + * <li> <p>a {@code CompState} class, which <b>must implement</b> + * {@link myutil.intboolsolver.IBSParamCompState + * IBSParamCompState}: the class of component states, which + * * associates int/bool values to component level variables.</p> + * </li> + * </ul> + * <p><b>WARNING!!</b> A successful instantiation requires that + * class <i>xxx</i> (with <i>xxx</i> among {@code Spec}, {@code Comp}, + * {@code SpecState}, {@code CompState} and {@code State}) does + * not implement any IBS<i>yyy</i>Param with <i>yyy</i> + * ≠ <i>xxx</i>.</p> + * <p> Trivial implementations of {@link myutil.intboolsolver.IBSParamSpec + * IBSParamSpec}, + * {@link myutil.intboolsolver.IBSParamComp IBSParamComp}, + * {@link myutil.intboolsolver.IBSParamState IBSParamState}, + * {@link myutil.intboolsolver.IBSParamSpecState IBSParamSpecState} + * and + * {@link myutil.intboolsolver.IBSParamCompState IBSParamCompState} + * (i.e. classes with empty code) can be used to + * instantiate solvers that do not implement the corresponding concepts.</p> + * </li><li> + * To make the use of the IBS system easier (in particular hide casts), + * wrapper classes can be written, as illustrated in the provided IBS + * instances. + * </li> + * + * </ul> + * <p><a id="instanciation_sumary"> <b>Instantiation summary:</b></a></p> + * <ol> + * <li><p> provide {@code Spec}, {@code Comp}, {@code SpecState}, + * {@code CompState} and {@code State} from application. These classes + * just have to extend their associated parameter IBS<i>xxx</i>Param + * and not extend any other IBS<i>yyy</i>Param (with + * <i>xxx</i> ≠ <i>yyy</i>)</p> + * </li> + * <li> <p> provide an implementation {@code Attribs} of + * {@link myutil.intboolsolver.IBSAttributes IBSAttributes} or + * {@link myutil.intboolsolver.IBSStdAttributes + * IBSStdAttributes}, and instanciate it with the chosen {@code Spec}, + * {@code Comp}, {@code SpecState}, {@code CompState} and {@code State}.</p> + <PRE> + known from context (package, imports): intboolsolver, + Spec, Comp, SpecState, CompState, State + + public class Attribs + extends IBS[Std]Attributes <Spec,Comp,SpecState,CompState,State> { + + !!! put implementation of IBS[Std]Attributes here + } + * </PRE> + * </li> + * <li> <p>build expression class <code>Exprs</code> for your instance, ie. + * for example instantiate {@link myutil.intboolsolver.IBSStdExpressions + * IBSStdExpressions}:</p> + <PRE> + known from context (package, imports): intboolsolver, + Spec, Comp, SpecState, CompState, State + + public class Exprs + extends IBSStdExpressions <Spec,Comp, SpecState, CompState, State> { + + public Exprs(){} + + !!! optionnal additionnal features here + } + * </PRE> + * <p>Note that if you want to add features to the inner class <code>Expr</code>, + * you have to directly modify {@link myutil.intboolsolver.IBSStdExpressions + * IBSStdExpressions}.</p> + * </li> + * <li> <p>build the parser <code>Parser</code> for your instance, ie. + * instantiate an implementation of the generic parser:</p> + * <PRE> + * known from context (package, imports): intboolsolver, + * Spec, Comp, SpecState, CompState, State + * + * public class Parser + * extends IBSParserImpl <Spec,Comp, SpecState, CompState, State> { + * + * public Parser() { super(new Attrs(),new Exprs()); } + * public Parser(Attrs _a, Exprs _e) { super(_c,_e); } + * + * !!! optional additional features here + * } + * </PRE> + * <p>Note: for the JavaCUP/Jflex parser, the scanner must also be provided + * (see <a href="#javacup">here </a>). {@link myutil.intboolsolver.IBSStdParser + * IBSStdParser} is the provided JavaCUP/Jflex implementation.</p> + * </li> + * <li> <p>Subpackage intboolsolver/closedformula contains a complete instantiation + * for closed formulas. This instantiation is trivial as behaviours for closed + * formulas are the default ones.This instantiation is made of + * {@link myutil.intboolsolver.closedformula.IBSClosedComp IBSClosedComp}, + * {@link myutil.intboolsolver.closedformula.IBSClosedSpec IBSClosedSpec}, + * {@link myutil.intboolsolver.closedformula.IBSClosedState IBSClosedState}, + * {@link myutil.intboolsolver.closedformula.IBSClosedCompState IBSClosedCompState}, + * {@link myutil.intboolsolver.closedformula.IBSClosedSpecState IBSClosedSpecState}, + * {@link myutil.intboolsolver.closedformula.IBSClosedFormulaAttributes IBSClosedFormulaAttributes}, + * {@link myutil.intboolsolver.closedformula.IBSClosedFormulaExpressions IBSClosedFormulaExpressions}, + * {@link myutil.intboolsolver.closedformula.IBSClosedFormulaParser IBSClosedFormulaParser}.</p> + * <p>Finally, two wrapper classes are provided that make all features available in + * a single classe and do most of the instance related casts. + * {@link myutil.intboolsolver.closedformula.IBSClosedFormulaSolver IBSClosedFormulaSolver} is + * a static instance of the system that that can be used from anywhere. It is not thread safe. + * {@link myutil.intboolsolver.closedformula.IBSClosedFormula IBSClosedFormula} is dynamic and thus + * must be used through objects. It is then thread safe but be careful: the class is quite big... + * Note that not all features are wrapped in these classes. In particular, some additional features + * are in {@link myutil.intboolsolver.closedformula.IBSClosedFormulaExpressions + * IBSClosedFormulaExpressions}</p> + * </li> + * <li> <p>There is also an instance dedicated to AVATAR structures, which can be found as an "intboolsolver" + * subpackage of the avatartranslator package of TTool</p></li> + * </ol> + * <p><a id="instanciation_use"> <b>Typical use of an instantiated parser (without wrapper classes):</b></a></p> + * <PRE> + * public Parser parser = new Parser(new Attribs(),new Exprs()); + * Exprs.BExpr e = (Exprs.BExpr) parser.parseBool("10 + 15 >= 20"); + * boolean b = e.eval(); + * ... + * </PRE> + * <p></p> + * <hr> + * <p><a id="javacup"> <b>The JavaCUP/JFlex provided parser</b></a></p> + * <p>A classical JavaCUP/JFlex parser is provided. Sources are in the subdirectory + * "javacup" of the intboolsolver package. A script <code>compile</code> is provided to + * generate the java code from the source. It relies on <code>sed</code> to make the + * small modifyings that cannot be made directly by the generating tools. + * Moreover by setting the variables at the beginning of the script, + * several different parsers and lexers can be produced (obviously, a lexer can only + * be coupled with a parser that defines all the symbols it uses)</p> + * <p>Notice that executing this script requires that javacup and jflex jar files + * be in the {@code CLASSPATH} environment variable (generally java-cup.jar or + * java_cup.jar and jflex.jar).</p> + * <p> In fact, two javacup parsers are provided (IBSStdParser.jcup and + * IBSOptParser.jcup). They both recognise the same set of usual boolean and integer + * expressions. The difference is that IBSOptParser implements constant propagation + * while parsing, which may simplify expression, while IBSStdParser does not and thus + * globally preserves original structure (provided that expression building primitives + * do)</p> + * + * <i>Script variables : </i> + * <ul><li><code>JFLEX_FILE</code>: the lexer jflex source file + * </li><li><code>JAVACUP_FILE</code>: the parser java-cup source file + * </li><li><code>LEXER_CLASS</code>: the class-and-file name of the generated lexer + * </li><li><code>PARSER_CLASS</code>: the class-and-file name of the generated parser + * </li><li><code>SYMBOL_CLASS</code>: the class-and-file name of the set of symbols + * generated by the parser and used by the lexer. + * </li></ul> + * <p> The script replaces tags in sources by the parameters provided in variables. + * Moreover it restore in the resulting java files the generic parameters that are not + * correctly handled by java-cup and jflex.</p> + * <ul><li> + * in the lexer source file, <code>IBSLexerClassName</code> is replaced by + * <code>LEXER_CLASS</code> and <code>IBSFlex#Symb</code> is replaced by + * <code>SYMBOL_CLASS</code>. After generation, the generic parameters + * of the lexer class are added in the lexer java file (<code>< Spec extends + * IBSParamSpec, Comp extends IBSParamComp, State extends IBSParamState, + * SpecState extends IBSParamSpecState, CompState extends IBSParamCompState + * ></code>) + * </li><li> + * the generic parameters + * of the parser class are added in the parser generated java file (<code>< + * Spec extends IBSParamSpec, Comp extends IBSParamComp, State extends + * IBSParamState, SpecState extends IBSParamSpecState, CompState extends + * IBSParamCompState ></code>) + * </li></ul> + * <p>As an example, the instantiation of the standard JFlex/javaCUP parser + * for Avatar : </p> + * <PRE> +public class AvatarIBSStdParser extends IBSStdParser< + AvatarSpecification, + AvatarBlock, + AvatarStateMachineElement, + SpecificationState, + SpecificationBlock> { + public AvatarIBSStdParser(AvatarIBSAttributes _a, AvatarIBSExpressions _e) { + super(); + setLexer(new IBSStdLexer< + AvatarSpecification, + AvatarBlock, + AvatarStateMachineElement, + SpecificationState, + SpecificationBlock>()); + setAttributes(_a); + setExpressions(_e); + } +} + </PRE> + * <p>Tech : the parser methods setAttributes and setExpressions modify + * the lexer as these classes are saved as member of the lexer and not + * as direct member of the parser. Thus these two methods must be called + * each time the lexer is set.</p> + * + * @version 1.0 11/04/2023 + * @author Sophie Coudert + */ +/** This package implements the generation of SysML V2 textual models from Avatar Models + * and the building of Avatar Models from SysML V2 textual models that respect the + * structure of Avatar (in fact a strongly constrained sub-language of SysML V2. + * <ul> + * <li>Avatar2SysML: generation of SysML V2 models from Avatar Models. This rely on + * <ul> + * <li> The content of the directory "static": libraries for Avatar SysML models</li> + * <li> Avatar2SysMLNames : generates names from Avatar idents that avoid any + * name clash with SysML keywords or fieldname in used SysML libraries </li> + * <li> A parser/lexer couple used to convert Avatar int/bool expressions into + * SysML int/bool expressions </li> + * </ul> + * </li> <li> AvatarFromSysML: building of Avatar Models from Avatar-compatible + * SysML V2 models + * <ul> + * <li> A parser/lexer couple builds an abstract syntax tree. The structures + * used for these trees are defined in AvatarSysMLSyntax.</li> + * <li>AvatarFromSysML then builds an Avatar Model from this abstract + * syntax tree.</li> + * <li> AvatarFromSysMLError is the format for errors collected during this + * process (a list of errors is available at the end of the process) </li> + * </ul> + * </ul> + */ +package avatartranslator.tosysmlv2; \ No newline at end of file -- GitLab