diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java index e16fa4bbf12ca626a6e2dc32ba89ce528cd95d21..b119041968e566c1981dd499e5437267be61209f 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java @@ -153,12 +153,13 @@ public class Avatar2SysML { void blocklink() { int size = blockChain.size(); if (size < 2) return; - StringBuffer chain = new StringBuffer(indentStep + "part " + blockChain.get(size - 1) + " = "); + StringBuffer chain = new StringBuffer(); for (int i=0; i < size-1; i++){ chain.append(blockChain.get(i) + "."); } - chain.append(blockChain.get(size - 1) + ";\n"); - blockLinks.append(chain); + chain.append(blockChain.get(size - 1)); + blockLinks.append( indentStep + "part " + blockChain.get(size - 1) + + " : '#AvatarBlock' :> " + chain.toString() + " = " + chain.toString() + ";\n" ); } StringBuffer blockLinks = new StringBuffer(); diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup b/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup index 44f86cb58e62f647bd821eab6f9929c98c19a22c..04f2b0ae2a185664f8405d3e852277be0bdd39d7 100644 --- a/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup +++ b/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jcup @@ -6,9 +6,10 @@ parser code {: /* Terminals (tokens returned by the scanner). */ -terminal Int INT; +terminal Integer INT; +terminal Boolean BOOL; -terminal EQ, TRUE, FALSE, LPAR, RPAR, LBRAC, RBRAC, COMMA, SEMICOLON, COLON, POINT, EQUAL, GETS; +terminal EQ, LPAR, RPAR, LBRAC, RBRAC, COMMA, SEMICOLON, COLON, POINT, EQUAL, GETS; // Field names terminal LOSSY_F, MAXSIZE_F, PRIVATE_F, RELATION_F, BLOCK1_F, BLOCK2_F, POOL_F, REQUEST_F, STATEACTION_F), INDEX_F, @@ -37,8 +38,7 @@ terminal AVSETTIMERSTATE_T, AVRESETTIMERSTATE_T, AVEXPIRETIMERSTATE_T, AVSETTIM terminal Ident DATATYPENAME, BLOCKNAME, ATTRIBUTENAME, RELATIONNAME, CHANNELPRENAME, SIGNALNAMENAME, CHANNELNAME, MESSAGENAME, STANDARDSTATENAME, STARTSTATENAME, STOPSTATENAME, RANDOMSTATENAME, COUNTSTATENAME, SENDSTATENAME, RECEIVESTATENAME, PRESENDSTATENAME, PRERECEIVESTATENAME, SETTIMERSTATENAME, RESETTIMERSTATENAME, EXPIRETIMERSTATENAME, - PRESETTIMERSTATENAME, PRERESETTIMERSTATENAME, PREEXPIRETIMERSTATENAME, TIMERBLOCKNAME, TIMERRELATIONNAME, - SETTIMERCHANNELNAME, RESETTIMERCHANNELNAME, EXPIRETIMERCHANNELNAME, AVATARNAME; + PRESETTIMERSTATENAME, PRERESETTIMERSTATENAME, PREEXPIRETIMERSTATENAME, TIMERBLOCKNAME, AVATARNAME; // Sysml reserved keywords terminal ABOUT, ABSTRACT, ACCEPT, ACTION, ACTOR, AFTER, ALIAS, ALL, ALLOCATE, ALLOCATION, ANALYSIS, AND, AS, ASSERT, @@ -47,9 +47,9 @@ terminal ABOUT, ABSTRACT, ACCEPT, ACTION, ACTOR, AFTER, ALIAS, ALL, ALLOCATE, AL EXIT, EXPOSE, FILTER, FIRST, FLOW, FOR, FORK, FRAME, FROM, HASTYPE, IF, IMPLIES, IMPORT, IN, INCLUDE, INDIVIDUAL, INOUT, INTERFACE, ISTYPE, ITEM, JOIN, LANGUAGE, LOOP, MERGE, MESSAGE, METADATA, NONUNIQUE, NOT, OBJECTIVE, OCCURRENCE, OF, OR, ORDERED, OUT, PACKAGE, PARALLEL, PART, PERFORM, PORT, PRIVATE, PROTECTED, PUBLIC, READONLY, REDEFINES, REF, - REFERENCES, RENDER, RENDERING, REP, REQUIRE, REQUIREMENT, RETURN, SATISFY, SEND, SNAPSHOT, SPECIALIZES, STAKEHOLDER, + REFERENCES, RENDER, RENDERING, REP, REQUIRE, REQUIREMENT, RETURN, SATISFY, SEND, SNAPSHOT, specializes, STAKEHOLDER, STATE, SUBJECT, SUBSETS, SUCCESSION, THEN, TIMESLICE, TO, TRANSITION, UNTIL, USE, VARIANT, VARIATION, VERIFICATION, - VERIFY, VIA, VIEW, VIEWPOINT, WHEN, WHILE, XOR; + VERIFY, VIA, VIEW, VIEWPOINT, WHEN, WHILE, XOR, REFINES; /* Non terminals */ @@ -62,6 +62,32 @@ non terminal Integer iexpr, bexpr; precedence left OR; precedence left AND; + +datatypename ::= DATATYPENAME | AVATARNAME; +blockname ::= BLOCKNAME | AVATARNAME; +attributename ::= ATTRIBUTENAME | AVATARNAME; +relationname ::= RELATIONNAME | AVATARNAME; +channelprename ::= CHANNELPRENAME | AVATARNAME; +signalname ::= SIGNALNAMENAME | AVATARNAME; +channelname ::= CHANNELNAME | AVATARNAME; +messagename ::= MESSAGENAME | AVATARNAME; +standardstatename ::= STANDARDSTATENAME | AVATARNAME; +startstatename ::= STARTSTATENAME | AVATARNAME; +stopstatename ::= STOPSTATENAME | AVATARNAME; +randomstatename ::= RANDOMSTATENAME | AVATARNAME; +countstatename ::= COUNTSTATENAME | AVATARNAME; +sendstatename ::= SENDSTATENAME | AVATARNAME; +receivestatename ::= RECEIVESTATENAME | AVATARNAME; +presendstatename ::= PRESENDSTATENAME | AVATARNAME; +prereceivestatename ::= PRERECEIVESTATENAME | AVATARNAME; +settimerstatename ::= SETTIMERSTATENAME | AVATARNAME; +resettimerstatename ::= RESETTIMERSTATENAME | AVATARNAME; +expiretimerstatename ::= EXPIRETIMERSTATENAME | AVATARNAME; +presettimerstatename ::= PRESETTIMERSTATENAME | AVATARNAME; +preresettimerstatename ::= PRERESETTIMERSTATENAME | AVATARNAME; +preexpiretimerstatename ::= PREEXPIRETIMERSTATENAME | AVATARNAME; +timerblockname ::= TIMERBLOCKNAME | AVATARNAME; + model ::= PACKAGE AVATARNAME LBRAC featureList RBRAC | PACKAGE AVATARNAME LBRAC RBRAC; featureList ::= feature | feature featureList; @@ -74,80 +100,116 @@ feature ::= | blockDecl | blockAlias ; -datatypeDecl ::= datatypeDeclHEADER datatypeDeclBODY; -relationDecl ::= syncRelDecl | nbfRelDecl |bfRelDecl; -syncRelDecl ::= syncRelDeclHEADER syncRelDeclBODY; -nbfRelDecl ::= nbfRelDeclHEADER fifofRelDeclBODY; -bfRelDecl ::= bfRelDeclHEADER fifoRelDeclBODY; -channelDecl ::= syncChDecl | nbfChDecl |bfChDecl; -syncChDecl ::= syncChDeclHEADER syncChDeclBODY; -nbfChDecl ::= nbfChDeclHEADER fifofChDeclBODY; -bfChDecl ::= bfChDeclHEADER fifoChDeclBODY; -signalBinding ::= inSignalBinding | outSignalBinding; -insignalBinding ::= insignalBindingHEADER insignalBindingBODY; -outsignalBinding ::= outsignalBindingHEADER outsignalBindingBODY; -messageDecl ::= inMessageDecl | outMessageDecl; -inMessageDecl ::= inMessageDeclHEADER inMessageDeclBODY; -outMessageDecl ::= outMessageDeclHEADER outMessageDeclBODY; -blockDecl ::= blockDeclHEADER blockDeclBODY; +specializes ::= SPECIALIZES | REFINES; +subsets ::= SUBSETS | REFINES; + +// BLOCK ALIASES blockAlias ::= - | PART BLOCKNAME EQ blockChain - | PART AVATARNAME EQ blockChain + PART blockname COLON AVBLOCK_T SUBSETS blockChain EQUAL blockChain SEMICOLON ; blockChain::= - | BLOCKNAME - | AVATARNAME - | BLOCKNAME blockChain - | AVATARNAME blockChain + | blockname + | blockname blockChain +; + +// DATATYPE DECLARATION $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +datatypeDecl ::= + datatypeDeclHEADER LBRAC fieldDecls RBRAC + | datatypeDeclHEADER LBRAC RBRAC ; datatypeDeclHEADER ::= - | ATTRIBUTE DEF DATATYPENAME SPECIALIZES AVDATATYPE - | ATTRIBUTE DEF AVATARNAME SPECIALIZES AVDATATYPE + ATTRIBUTE DEF datatypename specializes AVDATATYPE ; -syncRelDeclHEADER ::= - | PART RELATIONNAME SPECIALIZES SYNCREL_T - | PART AVATARNAME SPECIALIZES SYNCREL_T +fieldDecls ::= + | fieldDecl + | fieldDecl fieldDecls ; -bfRelDeclHEADER ::= - | PART RELATIONNAME SPECIALIZES BFIFOREL_T - | PART AVATARNAME SPECIALIZES BFIFOREL_T +fieldDecl ::= ATTRIBUTE AVATARNAME COLON typeIdent SEMICOLON ; -nbfRelDeclHEADER ::= - | PART RELATIONNAME SPECIALIZES NBFIFOREL_T - | PART AVATARNAME SPECIALIZES NBFIFOREL_T +typeIdent ::= INTEGER_T | BOOLEAN_T | AVATARNAME ; -syncChDeclHEADER ::= - | PART CHANNELNAME SPECIALIZES SYNC_T - | PART AVATARNAME SPECIALIZES SYNC_T + +// RELATION DECLARATION $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +relationDecl ::= syncRelDecl | nbfRelDecl | bfRelDecl; +syncRelDecl ::= + PART relationname COLON SYNCREL_T EQUAL SYNCREL_T LPAR syncRelParams RPAR SEMICOLON +; +nbfRelDecl ::= + PART relationname COLON NBFIFOREL_T EQUAL NBFIFOREL_T LPAR fifoRelParams RPAR SEMICOLON ; -bfChDeclHEADER ::= - | PART CHANNELNAME SPECIALIZES BFIFO_T - | PART AVATARNAME SPECIALIZES BFIFO_T +bfRelDecl ::= + PART relationname COLON BFIFOREL_T EQUAL BFIFOREL_T LPAR fifoRelParams RPAR SEMICOLON ; -nbfChDeclHEADER ::= - | PART CHANNELNAME SPECIALIZES NBFIFO_T - | PART AVATARNAME SPECIALIZES NBFIFO_T +syncRelParams ::= syncRelParam | syncRelParam COMMA syncRelParams; +syncRelParam ::= + | block1Param + | block2Param + | privateParam ; -insignalBindingHEADER ::= - | BINDING COLON INSIGNALBINDING_T - | BINDING AVATARNAME COLON INSIGNALBINDING_T +syncRelParams ::= fifoRelParam | fifoRelParam COMMA fifoRelParams; +fifoRelParam ::= + | block1Param + | block2Param + | privateParam + | maxsizeParam + | lossyParam ; -outsignalBindingHEADER ::= - | BINDING COLON OUTSIGNALBINDING_T - | BINDING AVATARNAME COLON INSIGNALBINDING_T +block1Param ::= BLOCK1_F EQUAL blockname; +block2Param ::= BLOCK2_F EQUAL blockname; +privateParam ::= PRIVATE_F EQUAL BOOL; +maxsizeParam ::= MAXSIZE_F EQUAL INT; +lossyParam ::= LOSSY_F EQUAL BOOL; + +// CHANNEL DECLARATION $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +channelDecl ::= syncChDecl | nbfChDecl |bfChDecl; +syncChDecl ::= PART channelname COLON SYNC_T EQUAL SYNC_T LPAR RELATION_F EQUAL relationname RPAR SEMICOLON ; -inMessageDeclHEADER ::= - | PART DEF MESSAGENAME SPECIALIZES INMESSAGE_T - | PART DEF AVATARNAME SPECIALIZES INMESSAGE_T +nbfChDecl ::= PART channelname COLON NBFIFO_T EQUAL NBFIFO_T LPAR RELATION_F EQUAL relationname RPAR SEMICOLON ; -outMessageDeclHEADER ::= - | PART DEF MESSAGENAME SPECIALIZES OUTMESSAGE_T COMMA MESSAGENAME - | PART DEF AVATARNAME SPECIALIZES OUTMESSAGE_T COMMA MESSAGENAME - | PART DEF MESSAGENAME SPECIALIZES MESSAGENAME COMMA OUTMESSAGE_T - | PART DEF AVATARNAME SPECIALIZES MESSAGENAME COMMA OUTMESSAGE_T +bfChDecl ::= PART channelname COLON BFIFO_T EQUAL BFIFO_T LPAR RELATION_F EQUAL relationname RPAR SEMICOLON +; + +// SIGNAL BINDING $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +signalBinding ::= inSignalBinding | outSignalBinding; +insignalBinding ::= BINDING COLON INSIGNALBINDING_T BIND blockChain POINT signalname EQUAL channelname SEMICOLON ; +outsignalBinding ::= BINDING COLON OUTSIGNALBINDING_T BIND blockChain POINT signalname EQUAL channelname SEMICOLON +; + +// MESSAGE DECLARATION $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +messageDecl ::= inMessageDecl | outMessageDecl +; +inMessageDecl ::= + PART DEF messagename specializes INMESSAGE_T LBRAC inMessageDeclBODY RBRAC +; +outMessageRefines ::= + specializes OUTMESSAGE_T COMMA messagename + | specializes messagename COMMA OUTMESSAGE_T +; +outMessageDecl ::= + PART DEF messagename outMessageRefines SEMICOLON + | PART DEF messagename outMessageRefines LBRAC RBRAC + | PART DEF messagename outMessageRefines LBRAC outMessageDeclBODY RBRAC +; +inMessageDeclBODY ::= messageChannel fieldDecls +; +messageChannel ::= + PRIVATE PART CHANNEL_F COLON CHANNEL_T EQUAL channelname SEMICOLON + | PRIVATE PART CHANNEL_F EQUAL channelname SEMICOLON +; +outMessageDeclBODY ::= + redefineField + | redefineField outMessageDeclBODY +; +redefineField ::= + ATTRIBUTE AVATARNAME REDEFINES AVATARNAME SEMICOLON +; + + +// BLOCK DECLARATION $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +blockDecl ::= blockDeclHEADER blockDeclBODY; blockDeclHEADER ::= - | PART DEF BLOCKNAME SPECIALIZES AVBLOCK_T - | PART DEF AVATARNAME SPECIALIZES AVBLOCK_T -; \ No newline at end of file + | PART DEF BLOCKNAME specializes AVBLOCK_T + | PART DEF AVATARNAME specializes AVBLOCK_T +; diff --git a/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jflex b/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jflex index ab8ed8a7cf52b0c75f4c9491002339c318814488..f978d55f3f17aed1c56fd2d17648513887963696 100644 --- a/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jflex +++ b/src/main/java/avatartranslator/tosysmlv2/javacup/AvatarFromSysML.jflex @@ -82,8 +82,8 @@ expireTimerChannelName = "'@ch:expire." AvIdent "'" } "==" { return new Symbol(XX#Symb.EQ, yyline, yycolumn); } - "true" { return new Symbol(XX#Symb.TRUE, yyline, yycolumn); } - "false" { return new Symbol(XX#Symb.FALSE, yyline, yycolumn); } + "true" { return new Symbol(XX#Symb.BOOL, yyline, yycolumn, TRUE); } + "false" { return new Symbol(XX#Symb.BOOL, yyline, yycolumn, FALSE); } "(" { return new Symbol(XX#Symb.LPAR, yyline, yycolumn); } ")" { return new Symbol(XX#Symb.RPAR, yyline, yycolumn); } "{" { return new Symbol(XX#Symb.LBRAC, yyline, yycolumn); } @@ -262,7 +262,7 @@ expireTimerChannelName = "'@ch:expire." AvIdent "'" "send" { return new Symbol(XX#Symb.SEND, yyline, yycolumn); } "snapshot" { return new Symbol(XX#Symb.SNAPSHOT, yyline, yycolumn); } "specializes" { return new Symbol(XX#Symb.SPECIALIZES, yyline, yycolumn); } - ":>" { return new Symbol(XX#Symb.SPECIALIZES, yyline, yycolumn); } + ":>" { return new Symbol(XX#Symb.REFINES, yyline, yycolumn); } "stakeholder" { return new Symbol(XX#Symb.STAKEHOLDER, yyline, yycolumn); } "state" { return new Symbol(XX#Symb.STATE, yyline, yycolumn); } "subject" { return new Symbol(XX#Symb.SUBJECT, yyline, yycolumn); } @@ -309,10 +309,6 @@ expireTimerChannelName = "'@ch:expire." AvIdent "'" preresetTimerStateName { return new Symbol(XX#Symb.PRERESETTIMERSTATENAME, identFromString(yytext())); } preexpireTimerStateName { return new Symbol(XX#Symb.PREEXPIRETIMERSTATENAME, identFromString(yytext())); } timerBlockName { return new Symbol(XX#Symb.TIMERBLOCKNAME, identFromTIMERBLOCKNAME(yytext())); } - timerRelationName { return new Symbol(XX#Symb.TIMERRELATIONNAME, identFromString(yytext())); } - setTimerChannelName { return new Symbol(XX#Symb.SETTIMERCHANNELNAME, identFromString(yytext())); } - resetTimerChannelName { return new Symbol(XX#Symb.RESETTIMERCHANNELNAME, identFromString(yytext())); } - expireTimerChannelName { return new Symbol(XX#Symb.EXPIRETIMERCHANNELNAME, identFromString(yytext())); } fieldName { return new Symbol(XX#Symb.AVATARNAME, identFromString(yytext())); } AvIdent { return new Symbol(XX#Symb.AVATARNAME, yytext()); }