diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java index 4b58996bad24ccadb7d2ade9210a529070fbf204..93bdf8c751e449b86298acc2cd1b6bd80727c56a 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java @@ -66,6 +66,8 @@ public class Avatar2SysML { name = _name; msgtype = null; fieldNames = new ArrayList<String>(); + fieldTypes = new ArrayList<Integer>(); + dataTypes = new ArrayList<AvatarDataType>(); returnType = -1; returnDataType = null; } @@ -73,6 +75,8 @@ public class Avatar2SysML { name = _name; msgtype = null; fieldNames = new ArrayList<String>(); + fieldTypes = new ArrayList<Integer>(); + dataTypes = new ArrayList<AvatarDataType>(); returnType = _returnType; if (_returnType != AvatarDataType.DATATYPE) returnDataType = null; @@ -83,6 +87,8 @@ public class Avatar2SysML { name = _name; msgtype = _msgtype; fieldNames = new ArrayList<String>(); + fieldTypes = new ArrayList<Integer>(); + dataTypes = new ArrayList<AvatarDataType>(); returnType = -1; returnDataType = null; } @@ -564,7 +570,7 @@ public class Avatar2SysML { sendStateSysMLname(((AvatarActionOnSignal)asme).getSignal().getName(), sendNumber), presendStateSysMLname(((AvatarActionOnSignal)asme).getSignal().getName(), sendNumber++)); else - stateinfo = new StateInfo(receiveStateSysMLname(((AvatarActionOnSignal)asme).getSignal().getName(), receiveNumber++), + stateinfo = new StateInfo(receiveStateSysMLname(((AvatarActionOnSignal)asme).getSignal().getName(), receiveNumber), prereceiveStateSysMLname(((AvatarActionOnSignal)asme).getSignal().getName(), receiveNumber++)); } else if (asme instanceof AvatarSetTimer) { @@ -1102,7 +1108,7 @@ public class Avatar2SysML { if (parameters.get(k) instanceof AvatarTermFunction) result.append(methodCall2SysML((AvatarTermFunction) parameters.get(k)) + ","); else - result.append(indent + expr2SysML(parameters.get(k).getName()) + ","); + result.append(expr2SysML(parameters.get(k).getName()) + ","); k++; j++; } else { diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLLexer.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLLexer.java index 6e78fff8ad7b567b7783a514aa0409f12a0a6afa..c586cc2a12f8439c9272bf934690fb1531a0d942 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 24/04/2024 15:37 */ +/* The following code was generated by JFlex 1.4.3 on 24/04/2024 16:06 */ /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille * @@ -45,7 +45,7 @@ import java_cup.runtime.*; /** * This class is a scanner generated by * <a href="http://www.jflex.de/">JFlex</a> 1.4.3 - * on 24/04/2024 15:37 from the specification file + * on 24/04/2024 16:06 from the specification file * <tt>__Avatar2SysMLLexer__.jflex</tt> */ public class Avatar2SysMLLexer implements java_cup.runtime.Scanner { @@ -602,85 +602,85 @@ public class Avatar2SysMLLexer implements java_cup.runtime.Scanner { { return new Symbol(Avatar2SysMLSymbols.NOT); } case 25: break; - case 8: - { return new Symbol(Avatar2SysMLSymbols.DIV); + case 3: + { try { return new Symbol(Avatar2SysMLSymbols.CONSTANT, "" + Integer.parseInt(yytext()));} + catch (NumberFormatException nfe) { throw new Exception ("Lexer : Integer Format : " + yytext()); } } case 26: break; - case 18: - { return new Symbol(Avatar2SysMLSymbols.DIF); + case 8: + { return new Symbol(Avatar2SysMLSymbols.DIV); } case 27: break; - case 11: - { return new Symbol(Avatar2SysMLSymbols.LT); + case 4: + { return new Symbol(Avatar2SysMLSymbols.IDENT, yytext()); } case 28: break; - case 3: - { try { return new Symbol(Avatar2SysMLSymbols.LEAVE, "" + Integer.parseInt(yytext()));} - catch (NumberFormatException nfe) { throw new Exception ("Lexer : Integer Format : " + yytext()); } + case 18: + { return new Symbol(Avatar2SysMLSymbols.DIF); } case 29: break; - case 15: - { return new Symbol(Avatar2SysMLSymbols.COMMA); + case 23: + { return new Symbol(Avatar2SysMLSymbols.CONSTANT, "false"); } case 30: break; - case 23: - { return new Symbol(Avatar2SysMLSymbols.LEAVE, "false"); + case 11: + { return new Symbol(Avatar2SysMLSymbols.LT); } case 31: break; + case 15: + { return new Symbol(Avatar2SysMLSymbols.COMMA); + } + case 32: break; case 5: { return new Symbol(Avatar2SysMLSymbols.PLUS); } - case 32: break; + case 33: break; case 12: { return new Symbol(Avatar2SysMLSymbols.GT); } - case 33: break; + case 34: break; case 21: { return new Symbol(Avatar2SysMLSymbols.GEQ); } - case 34: break; + case 35: break; case 9: { return new Symbol(Avatar2SysMLSymbols.MOD); } - case 35: break; + case 36: break; case 19: { return new Symbol(Avatar2SysMLSymbols.EQ); } - case 36: break; + case 37: break; case 14: { return new Symbol(Avatar2SysMLSymbols.RPAR); } - case 37: break; + case 38: break; case 17: { return new Symbol(Avatar2SysMLSymbols.OR); } - case 38: break; + case 39: break; case 20: { return new Symbol(Avatar2SysMLSymbols.LEQ); } - case 39: break; + case 40: break; case 1: { throw new Exception ("Unknown character in expression"); } - case 40: break; + case 41: break; case 6: { return new Symbol(Avatar2SysMLSymbols.MINUS); } - case 41: break; - case 7: - { return new Symbol(Avatar2SysMLSymbols.MULT); - } case 42: break; case 22: - { return new Symbol(Avatar2SysMLSymbols.LEAVE, "true"); + { return new Symbol(Avatar2SysMLSymbols.CONSTANT, "true"); } case 43: break; - case 13: - { return new Symbol(Avatar2SysMLSymbols.LPAR); + case 7: + { return new Symbol(Avatar2SysMLSymbols.MULT); } case 44: break; - case 4: - { return new Symbol(Avatar2SysMLSymbols.LEAVE, yytext()); + case 13: + { return new Symbol(Avatar2SysMLSymbols.LPAR); } case 45: break; case 2: diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java index 64ba45acd05ea4a66cce931b61b8cf82ef467418..3c31fc87949f417a3f66a602493a0bb96f2c1647 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java @@ -94,7 +94,7 @@ public class Avatar2SysMLNames { public static String presetTimerStateSysMLname(String timerName, int number){ return "'@st:preset." + timerName.trim() + "." + number + "'"; } public static String preresetTimerStateSysMLname(String timerName, int number){ return "'@st:prereset." + timerName.trim() + "." + number + "'"; } public static String preexpireTimerStateSysMLname(String timerName, int number){ return "'@st:preexpire." + timerName.trim() + "." + number + "'"; } - public static String timerBlockSysMLname(String timerName){ return "'@@tmr:" + timerName.trim() + "'"; } + public static String timerBlockSysMLname(String timerName){ return "'@tmr:" + timerName.trim() + "'"; } public static String timerRelationSysMLname(String timerName){ return "'TMRRel:" + timerName.trim() + "'"; } public static String setTimerChannelSysMLname(String timerName){ return "'@ch:set." + timerName.trim() + "'"; } public static String resetTimerChannelSysMLname(String timerName){ return "'@ch:reset." + timerName.trim() + "'"; } diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLParser.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLParser.java index f2dd737c468bfefd87de48c23811bc34822cea0f..bfacbca610ab86e5a8743078d81b566245571b7e 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLParser.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLParser.java @@ -33,13 +33,14 @@ public class Avatar2SysMLParser extends java_cup.runtime.lr_parser { /** Production table. */ protected static final short _production_table[][] = unpackFromStrings(new String[] { - "\000\026\000\002\002\005\000\002\002\004\000\002\002" + + "\000\027\000\002\002\005\000\002\002\004\000\002\002" + "\005\000\002\002\005\000\002\002\005\000\002\002\005" + "\000\002\002\004\000\002\002\005\000\002\002\005\000" + "\002\002\004\000\002\002\005\000\002\002\005\000\002" + "\002\005\000\002\002\005\000\002\002\005\000\002\002" + "\005\000\002\002\005\000\002\002\005\000\002\002\006" + - "\000\002\002\003\000\002\003\003\000\002\003\005" }); + "\000\002\002\003\000\002\002\003\000\002\003\003\000" + + "\002\003\005" }); /** Access to production table. */ @Override @@ -48,84 +49,89 @@ public class Avatar2SysMLParser extends java_cup.runtime.lr_parser { /** Parse-action table. */ protected static final short[][] _action_table = unpackFromStrings(new String[] { - "\000\054\000\012\005\007\021\004\022\006\026\005\001" + - "\002\000\012\005\007\021\004\022\006\026\005\001\002" + - "\000\044\002\uffee\004\uffee\005\uffee\006\uffee\007\uffee\010" + - "\uffee\011\uffee\012\uffee\013\uffee\014\uffee\015\uffee\016\uffee" + - "\017\uffee\020\uffee\022\047\023\uffee\025\uffee\001\002\000" + - "\012\005\007\021\004\022\006\026\005\001\002\000\012" + - "\005\007\021\004\022\006\026\005\001\002\000\036\002" + - "\017\004\016\005\011\006\013\007\021\010\014\011\012" + - "\012\025\013\020\014\015\015\024\016\022\017\026\020" + - "\023\001\002\000\012\005\007\021\004\022\006\026\005" + - "\001\002\000\012\005\007\021\004\022\006\026\005\001" + - "\002\000\012\005\007\021\004\022\006\026\005\001\002" + - "\000\012\005\007\021\004\022\006\026\005\001\002\000" + - "\012\005\007\021\004\022\006\026\005\001\002\000\012" + - "\005\007\021\004\022\006\026\005\001\002\000\004\002" + - "\000\001\002\000\012\005\007\021\004\022\006\026\005" + - "\001\002\000\012\005\007\021\004\022\006\026\005\001" + - "\002\000\012\005\007\021\004\022\006\026\005\001\002" + - "\000\012\005\007\021\004\022\006\026\005\001\002\000" + - "\012\005\007\021\004\022\006\026\005\001\002\000\012" + - "\005\007\021\004\022\006\026\005\001\002\000\012\005" + - "\007\021\004\022\006\026\005\001\002\000\032\002\ufff5" + - "\004\016\005\011\006\013\007\021\010\014\011\ufff5\012" + - "\ufff5\013\ufff5\014\ufff5\023\ufff5\025\ufff5\001\002\000\042" + - "\002\ufffa\004\016\005\011\006\013\007\021\010\014\011" + - "\012\012\ufffa\013\020\014\015\015\024\016\022\017\026" + - "\020\023\023\ufffa\025\ufffa\001\002\000\032\002\ufff7\004" + - "\016\005\011\006\013\007\021\010\014\011\ufff7\012\ufff7" + - "\013\ufff7\014\ufff7\023\ufff7\025\ufff7\001\002\000\032\002" + - "\ufff4\004\016\005\011\006\013\007\021\010\014\011\ufff4" + - "\012\ufff4\013\ufff4\014\ufff4\023\ufff4\025\ufff4\001\002\000" + - "\032\002\ufff6\004\016\005\011\006\013\007\021\010\014" + - "\011\ufff6\012\ufff6\013\ufff6\014\ufff6\023\ufff6\025\ufff6\001" + - "\002\000\042\002\ufffd\004\ufffd\005\ufffd\006\ufffd\007\ufffd" + - "\010\ufffd\011\ufffd\012\ufffd\013\ufffd\014\ufffd\015\ufffd\016" + - "\ufffd\017\ufffd\020\ufffd\023\ufffd\025\ufffd\001\002\000\042" + - "\002\ufff3\004\016\005\011\006\013\007\021\010\014\011" + - "\ufff3\012\ufff3\013\ufff3\014\ufff3\015\024\016\022\017\026" + - "\020\023\023\ufff3\025\ufff3\001\002\000\042\002\001\004" + - "\001\005\001\006\013\007\021\010\014\011\001\012\001" + - "\013\001\014\001\015\001\016\001\017\001\020\001\023" + - "\001\025\001\001\002\000\042\002\ufff2\004\016\005\011" + - "\006\013\007\021\010\014\011\ufff2\012\ufff2\013\ufff2\014" + - "\ufff2\015\024\016\022\017\026\020\023\023\ufff2\025\ufff2" + - "\001\002\000\042\002\ufffc\004\ufffc\005\ufffc\006\ufffc\007" + - "\ufffc\010\ufffc\011\ufffc\012\ufffc\013\ufffc\014\ufffc\015\ufffc" + - "\016\ufffc\017\ufffc\020\ufffc\023\ufffc\025\ufffc\001\002\000" + - "\042\002\ufffe\004\ufffe\005\ufffe\006\ufffe\007\ufffe\010\ufffe" + - "\011\ufffe\012\ufffe\013\ufffe\014\ufffe\015\ufffe\016\ufffe\017" + - "\ufffe\020\ufffe\023\ufffe\025\ufffe\001\002\000\042\002\ufff9" + - "\004\016\005\011\006\013\007\021\010\014\011\ufff9\012" + - "\ufff9\013\020\014\015\015\024\016\022\017\026\020\023" + - "\023\ufff9\025\ufff9\001\002\000\042\002\uffff\004\uffff\005" + - "\uffff\006\013\007\021\010\014\011\uffff\012\uffff\013\uffff" + - "\014\uffff\015\uffff\016\uffff\017\uffff\020\uffff\023\uffff\025" + - "\uffff\001\002\000\042\002\ufffb\004\ufffb\005\ufffb\006\ufffb" + - "\007\ufffb\010\ufffb\011\ufffb\012\ufffb\013\ufffb\014\ufffb\015" + - "\ufffb\016\ufffb\017\ufffb\020\ufffb\023\ufffb\025\ufffb\001\002" + - "\000\036\004\016\005\011\006\013\007\021\010\014\011" + - "\012\012\025\013\020\014\015\015\024\016\022\017\026" + - "\020\023\023\046\001\002\000\042\002\ufff1\004\ufff1\005" + - "\ufff1\006\ufff1\007\ufff1\010\ufff1\011\ufff1\012\ufff1\013\ufff1" + - "\014\ufff1\015\ufff1\016\ufff1\017\ufff1\020\ufff1\023\ufff1\025" + - "\ufff1\001\002\000\014\005\007\021\004\022\006\023\052" + - "\026\005\001\002\000\004\023\055\001\002\000\040\004" + - "\016\005\011\006\013\007\021\010\014\011\012\012\025" + - "\013\020\014\015\015\024\016\022\017\026\020\023\023" + - "\uffed\025\053\001\002\000\042\002\ufff0\004\ufff0\005\ufff0" + - "\006\ufff0\007\ufff0\010\ufff0\011\ufff0\012\ufff0\013\ufff0\014" + - "\ufff0\015\ufff0\016\ufff0\017\ufff0\020\ufff0\023\ufff0\025\ufff0" + - "\001\002\000\012\005\007\021\004\022\006\026\005\001" + - "\002\000\004\023\uffec\001\002\000\042\002\uffef\004\uffef" + - "\005\uffef\006\uffef\007\uffef\010\uffef\011\uffef\012\uffef\013" + - "\uffef\014\uffef\015\uffef\016\uffef\017\uffef\020\uffef\023\uffef" + - "\025\uffef\001\002\000\042\002\ufff8\004\016\005\011\006" + - "\013\007\021\010\014\011\ufff8\012\ufff8\013\020\014\015" + - "\015\024\016\022\017\026\020\023\023\ufff8\025\ufff8\001" + - "\002" }); + "\000\055\000\014\005\007\021\005\022\006\026\010\027" + + "\004\001\002\000\042\002\uffee\004\uffee\005\uffee\006\uffee" + + "\007\uffee\010\uffee\011\uffee\012\uffee\013\uffee\014\uffee\015" + + "\uffee\016\uffee\017\uffee\020\uffee\023\uffee\025\uffee\001\002" + + "\000\014\005\007\021\005\022\006\026\010\027\004\001" + + "\002\000\014\005\007\021\005\022\006\026\010\027\004" + + "\001\002\000\014\005\007\021\005\022\006\026\010\027" + + "\004\001\002\000\044\002\uffed\004\uffed\005\uffed\006\uffed" + + "\007\uffed\010\uffed\011\uffed\012\uffed\013\uffed\014\uffed\015" + + "\uffed\016\uffed\017\uffed\020\uffed\022\045\023\uffed\025\uffed" + + "\001\002\000\036\002\020\004\017\005\012\006\014\007" + + "\022\010\015\011\013\012\026\013\021\014\016\015\025" + + "\016\023\017\027\020\024\001\002\000\014\005\007\021" + + "\005\022\006\026\010\027\004\001\002\000\014\005\007" + + "\021\005\022\006\026\010\027\004\001\002\000\014\005" + + "\007\021\005\022\006\026\010\027\004\001\002\000\014" + + "\005\007\021\005\022\006\026\010\027\004\001\002\000" + + "\014\005\007\021\005\022\006\026\010\027\004\001\002" + + "\000\014\005\007\021\005\022\006\026\010\027\004\001" + + "\002\000\004\002\000\001\002\000\014\005\007\021\005" + + "\022\006\026\010\027\004\001\002\000\014\005\007\021" + + "\005\022\006\026\010\027\004\001\002\000\014\005\007" + + "\021\005\022\006\026\010\027\004\001\002\000\014\005" + + "\007\021\005\022\006\026\010\027\004\001\002\000\014" + + "\005\007\021\005\022\006\026\010\027\004\001\002\000" + + "\014\005\007\021\005\022\006\026\010\027\004\001\002" + + "\000\014\005\007\021\005\022\006\026\010\027\004\001" + + "\002\000\032\002\ufff5\004\017\005\012\006\014\007\022" + + "\010\015\011\ufff5\012\ufff5\013\ufff5\014\ufff5\023\ufff5\025" + + "\ufff5\001\002\000\042\002\ufffa\004\017\005\012\006\014" + + "\007\022\010\015\011\013\012\ufffa\013\021\014\016\015" + + "\025\016\023\017\027\020\024\023\ufffa\025\ufffa\001\002" + + "\000\032\002\ufff7\004\017\005\012\006\014\007\022\010" + + "\015\011\ufff7\012\ufff7\013\ufff7\014\ufff7\023\ufff7\025\ufff7" + + "\001\002\000\032\002\ufff4\004\017\005\012\006\014\007" + + "\022\010\015\011\ufff4\012\ufff4\013\ufff4\014\ufff4\023\ufff4" + + "\025\ufff4\001\002\000\032\002\ufff6\004\017\005\012\006" + + "\014\007\022\010\015\011\ufff6\012\ufff6\013\ufff6\014\ufff6" + + "\023\ufff6\025\ufff6\001\002\000\042\002\ufffd\004\ufffd\005" + + "\ufffd\006\ufffd\007\ufffd\010\ufffd\011\ufffd\012\ufffd\013\ufffd" + + "\014\ufffd\015\ufffd\016\ufffd\017\ufffd\020\ufffd\023\ufffd\025" + + "\ufffd\001\002\000\042\002\ufff3\004\017\005\012\006\014" + + "\007\022\010\015\011\ufff3\012\ufff3\013\ufff3\014\ufff3\015" + + "\025\016\023\017\027\020\024\023\ufff3\025\ufff3\001\002" + + "\000\042\002\001\004\001\005\001\006\014\007\022\010" + + "\015\011\001\012\001\013\001\014\001\015\001\016\001" + + "\017\001\020\001\023\001\025\001\001\002\000\042\002" + + "\ufff2\004\017\005\012\006\014\007\022\010\015\011\ufff2" + + "\012\ufff2\013\ufff2\014\ufff2\015\025\016\023\017\027\020" + + "\024\023\ufff2\025\ufff2\001\002\000\042\002\ufffc\004\ufffc" + + "\005\ufffc\006\ufffc\007\ufffc\010\ufffc\011\ufffc\012\ufffc\013" + + "\ufffc\014\ufffc\015\ufffc\016\ufffc\017\ufffc\020\ufffc\023\ufffc" + + "\025\ufffc\001\002\000\042\002\ufffe\004\ufffe\005\ufffe\006" + + "\ufffe\007\ufffe\010\ufffe\011\ufffe\012\ufffe\013\ufffe\014\ufffe" + + "\015\ufffe\016\ufffe\017\ufffe\020\ufffe\023\ufffe\025\ufffe\001" + + "\002\000\042\002\ufff9\004\017\005\012\006\014\007\022" + + "\010\015\011\ufff9\012\ufff9\013\021\014\016\015\025\016" + + "\023\017\027\020\024\023\ufff9\025\ufff9\001\002\000\042" + + "\002\uffff\004\uffff\005\uffff\006\014\007\022\010\015\011" + + "\uffff\012\uffff\013\uffff\014\uffff\015\uffff\016\uffff\017\uffff" + + "\020\uffff\023\uffff\025\uffff\001\002\000\016\005\007\021" + + "\005\022\006\023\050\026\010\027\004\001\002\000\004" + + "\023\053\001\002\000\040\004\017\005\012\006\014\007" + + "\022\010\015\011\013\012\026\013\021\014\016\015\025" + + "\016\023\017\027\020\024\023\uffec\025\051\001\002\000" + + "\042\002\ufff0\004\ufff0\005\ufff0\006\ufff0\007\ufff0\010\ufff0" + + "\011\ufff0\012\ufff0\013\ufff0\014\ufff0\015\ufff0\016\ufff0\017" + + "\ufff0\020\ufff0\023\ufff0\025\ufff0\001\002\000\014\005\007" + + "\021\005\022\006\026\010\027\004\001\002\000\004\023" + + "\uffeb\001\002\000\042\002\uffef\004\uffef\005\uffef\006\uffef" + + "\007\uffef\010\uffef\011\uffef\012\uffef\013\uffef\014\uffef\015" + + "\uffef\016\uffef\017\uffef\020\uffef\023\uffef\025\uffef\001\002" + + "\000\042\002\ufffb\004\ufffb\005\ufffb\006\ufffb\007\ufffb\010" + + "\ufffb\011\ufffb\012\ufffb\013\ufffb\014\ufffb\015\ufffb\016\ufffb" + + "\017\ufffb\020\ufffb\023\ufffb\025\ufffb\001\002\000\036\004" + + "\017\005\012\006\014\007\022\010\015\011\013\012\026" + + "\013\021\014\016\015\025\016\023\017\027\020\024\023" + + "\056\001\002\000\042\002\ufff1\004\ufff1\005\ufff1\006\ufff1" + + "\007\ufff1\010\ufff1\011\ufff1\012\ufff1\013\ufff1\014\ufff1\015" + + "\ufff1\016\ufff1\017\ufff1\020\ufff1\023\ufff1\025\ufff1\001\002" + + "\000\042\002\ufff8\004\017\005\012\006\014\007\022\010" + + "\015\011\ufff8\012\ufff8\013\021\014\016\015\025\016\023" + + "\017\027\020\024\023\ufff8\025\ufff8\001\002" }); /** Access to parse-action table. */ @Override @@ -134,23 +140,24 @@ public class Avatar2SysMLParser extends java_cup.runtime.lr_parser { /** <code>reduce_goto</code> table. */ protected static final short[][] _reduce_table = unpackFromStrings(new String[] { - "\000\054\000\004\002\007\001\001\000\004\002\055\001" + - "\001\000\002\001\001\000\004\002\044\001\001\000\004" + - "\002\043\001\001\000\002\001\001\000\004\002\042\001" + - "\001\000\004\002\041\001\001\000\004\002\040\001\001" + - "\000\004\002\037\001\001\000\004\002\036\001\001\000" + - "\004\002\035\001\001\000\002\001\001\000\004\002\034" + - "\001\001\000\004\002\033\001\001\000\004\002\032\001" + - "\001\000\004\002\031\001\001\000\004\002\030\001\001" + - "\000\004\002\027\001\001\000\004\002\026\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\000\055\000\004\002\010\001\001\000\002\001\001\000" + + "\004\002\056\001\001\000\004\002\054\001\001\000\004" + + "\002\053\001\001\000\002\001\001\000\002\001\001\000" + + "\004\002\043\001\001\000\004\002\042\001\001\000\004" + + "\002\041\001\001\000\004\002\040\001\001\000\004\002" + + "\037\001\001\000\004\002\036\001\001\000\002\001\001" + + "\000\004\002\035\001\001\000\004\002\034\001\001\000" + + "\004\002\033\001\001\000\004\002\032\001\001\000\004" + + "\002\031\001\001\000\004\002\030\001\001\000\004\002" + + "\027\001\001\000\002\001\001\000\002\001\001\000\002" + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + - "\002\001\001\000\002\001\001\000\002\001\001\000\006" + - "\002\050\003\047\001\001\000\002\001\001\000\002\001" + - "\001\000\002\001\001\000\006\002\050\003\053\001\001" + - "\000\002\001\001\000\002\001\001\000\002\001\001" }); + "\002\001\001\000\006\002\046\003\045\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\006\002" + + "\046\003\051\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001" }); /** Access to <code>reduce_goto</code> table. */ @Override @@ -467,7 +474,7 @@ class CUP$Avatar2SysMLParser$actions { return CUP$Avatar2SysMLParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 17: // expr ::= LEAVE LPAR RPAR + case 17: // expr ::= IDENT LPAR RPAR { String RESULT =null; int ileft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; @@ -479,7 +486,7 @@ class CUP$Avatar2SysMLParser$actions { return CUP$Avatar2SysMLParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 18: // expr ::= LEAVE LPAR exprlist RPAR + case 18: // expr ::= IDENT LPAR exprlist RPAR { String RESULT =null; int ileft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-3)).left; @@ -494,7 +501,19 @@ class CUP$Avatar2SysMLParser$actions { return CUP$Avatar2SysMLParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 19: // expr ::= LEAVE + case 19: // expr ::= CONSTANT + { + String RESULT =null; + int eleft = (CUP$Avatar2SysMLParser$stack.peek()).left; + int eright = (CUP$Avatar2SysMLParser$stack.peek()).right; + 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); + } + return CUP$Avatar2SysMLParser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 20: // expr ::= IDENT { String RESULT =null; int eleft = (CUP$Avatar2SysMLParser$stack.peek()).left; @@ -506,7 +525,7 @@ class CUP$Avatar2SysMLParser$actions { return CUP$Avatar2SysMLParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 20: // exprlist ::= expr + case 21: // exprlist ::= expr { String RESULT =null; int eleft = (CUP$Avatar2SysMLParser$stack.peek()).left; @@ -518,7 +537,7 @@ class CUP$Avatar2SysMLParser$actions { return CUP$Avatar2SysMLParser$result; /*. . . . . . . . . . . . . . . . . . . .*/ - case 21: // exprlist ::= expr COMMA exprlist + case 22: // exprlist ::= expr COMMA exprlist { String RESULT =null; int eleft = (CUP$Avatar2SysMLParser$stack.elementAt(CUP$Avatar2SysMLParser$top-2)).left; diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLSymbols.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLSymbols.java index 20f867d88eea0a673251649f770452a99a20a264..7d033ac016f3c42eaa8e97b189135d06fbb9c5dd 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLSymbols.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLSymbols.java @@ -12,8 +12,10 @@ public class Avatar2SysMLSymbols { public static final int MOD = 6; public static final int AND = 7; public static final int LT = 11; + public static final int IDENT = 20; public static final int PLUS = 2; public static final int OR = 8; + public static final int CONSTANT = 21; public static final int NOT = 15; public static final int GT = 12; public static final int COMMA = 19; @@ -25,7 +27,6 @@ public class Avatar2SysMLSymbols { public static final int EQ = 9; public static final int LEQ = 13; public static final int RPAR = 17; - public static final int LEAVE = 20; public static final int LPAR = 16; public static final int DIF = 10; public static final int UMINUS = 18; @@ -50,7 +51,8 @@ public class Avatar2SysMLSymbols { "RPAR", "UMINUS", "COMMA", - "LEAVE" + "IDENT", + "CONSTANT" }; } diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLLexer.jflex b/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLLexer.jflex index f31df2fca74eebe67e3d1fd81550be6c5b761eaf..abcd0e05b258194575fae630ae14d81f1c88bde0 100644 --- a/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLLexer.jflex +++ b/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLLexer.jflex @@ -61,9 +61,9 @@ Identifier = [a-zA-Z_][a-zA-Z0-9_\.]* <YYINITIAL> { {Space} { } - "true" { return new Symbol(#Symb.LEAVE, "true"); } - "false" { return new Symbol(#Symb.LEAVE, "false"); } - {Natural} { try { return new Symbol(#Symb.LEAVE, "" + Integer.parseInt(yytext()));} + "true" { return new Symbol(#Symb.CONSTANT, "true"); } + "false" { return new Symbol(#Symb.CONSTANT, "false"); } + {Natural} { try { return new Symbol(#Symb.CONSTANT, "" + Integer.parseInt(yytext()));} catch (NumberFormatException nfe) { throw new Exception ("Lexer : Integer Format : " + yytext()); } } "+" { return new Symbol(#Symb.PLUS); } @@ -86,6 +86,6 @@ Identifier = [a-zA-Z_][a-zA-Z0-9_\.]* "(" { return new Symbol(#Symb.LPAR); } ")" { return new Symbol(#Symb.RPAR); } "," { return new Symbol(#Symb.COMMA); } - {Identifier} { return new Symbol(#Symb.LEAVE, yytext()); } + {Identifier} { return new Symbol(#Symb.IDENT, yytext()); } . { throw new Exception ("Unknown character in expression"); } } diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLParser.jcup b/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLParser.jcup index 1baa19a91767dd7829aa70247084a2a7fbe7ffeb..335d847cb65a7a02b0551b2638c7218c21a8877c 100644 --- a/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLParser.jcup +++ b/src/main/java/avatartranslator/tosysmlv2/javacup/Avatar2SysMLParser.jcup @@ -49,7 +49,7 @@ parser code {: /* Terminals (tokens returned by the scanner). */ terminal PLUS, MINUS, MULT, DIV, MOD, AND, OR, EQ, DIF, LT, GT, LEQ, GEQ; terminal NOT, LPAR, RPAR, UMINUS, COMMA; -terminal String LEAVE; +terminal String IDENT, CONSTANT; /* Non terminals */ @@ -84,9 +84,10 @@ expr ::= | expr:l EQ expr:r {: RESULT = l + " == " + r; :} | expr:l DIF expr:r {: RESULT = l + " != " + r; :} | LPAR expr:e RPAR {: RESULT = "(" + e + ")"; :} - | LEAVE:i LPAR RPAR {: RESULT = i + "()"; :} - | LEAVE:i LPAR exprlist:l RPAR {: RESULT = methodSysMLname(i) + "(" + l + ")"; :} - | LEAVE:e {: RESULT = attributeSysMLname(e); :} + | IDENT:i LPAR RPAR {: RESULT = i + "()"; :} + | IDENT:i LPAR exprlist:l RPAR {: RESULT = methodSysMLname(i) + "(" + l + ")"; :} + | CONSTANT:e {: RESULT = e; :} + | IDENT:e {: RESULT = attributeSysMLname(e); :} ; exprlist ::= expr:e {: RESULT = e; :}