Skip to content

Commit

Permalink
Merge pull request #316 from ciekawy/activation_draft
Browse files Browse the repository at this point in the history
Activations
  • Loading branch information
knsv committed Mar 12, 2016
2 parents d6363e9 + 3f85391 commit b3d147b
Show file tree
Hide file tree
Showing 6 changed files with 301 additions and 94 deletions.
20 changes: 17 additions & 3 deletions src/diagrams/sequenceDiagram/parser/sequenceDiagram.jison
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,22 @@
"right of" return 'right_of';
"over" return 'over';
"note" return 'note';
"activate" { this.begin('ID'); return 'activate'; }
"deactivate" { this.begin('ID'); return 'deactivate'; }
"title" return 'title';
"sequenceDiagram" return 'SD';
"," return ',';
";" return 'NL';
[^\->:\n,;]+ { yytext = yytext.trim(); return 'ACTOR'; }
[^\+\->:\n,;]+ { yytext = yytext.trim(); return 'ACTOR'; }
"->>" return 'SOLID_ARROW';
"-->>" return 'DOTTED_ARROW';
"->" return 'SOLID_OPEN_ARROW';
"-->" return 'DOTTED_OPEN_ARROW';
\-[x] return 'SOLID_CROSS';
\-\-[x] return 'DOTTED_CROSS';
":"[^#\n;]+ return 'TXT';
"+" return '+';
"-" return '-';
<<EOF>> return 'NL';
. return 'INVALID';

Expand Down Expand Up @@ -84,6 +88,8 @@ statement
: 'participant' actor 'AS' restOfLine 'NL' {$2.description=$4; $$=$2;}
| 'participant' actor 'NL' {$$=$2;}
| signal 'NL'
| 'activate' actor 'NL' {$$={type: 'activeStart', signalType: yy.LINETYPE.ACTIVE_START, actor: $2};}
| 'deactivate' actor 'NL' {$$={type: 'activeEnd', signalType: yy.LINETYPE.ACTIVE_END, actor: $2};}
| note_statement 'NL'
| 'title' SPACE text 'NL'
| 'loop' restOfLine document end
Expand Down Expand Up @@ -139,8 +145,16 @@ placement
;

signal
: actor signaltype actor text2
{$$ = [$1,$3,{type: 'addMessage', from:$1.actor, to:$3.actor, signalType:$2, msg:$4}]}
: actor signaltype '+' actor text2
{ $$ = [$1,$4,{type: 'addMessage', from:$1.actor, to:$4.actor, signalType:$2, msg:$5},
{type: 'activeStart', signalType: yy.LINETYPE.ACTIVE_START, actor: $4}
]}
| actor signaltype '-' actor text2
{ $$ = [$1,$4,{type: 'addMessage', from:$1.actor, to:$4.actor, signalType:$2, msg:$5},
{type: 'activeEnd', signalType: yy.LINETYPE.ACTIVE_END, actor: $1}
]}
| actor signaltype actor text2
{ $$ = [$1,$3,{type: 'addMessage', from:$1.actor, to:$3.actor, signalType:$2, msg:$4}]}
;

actor
Expand Down
142 changes: 83 additions & 59 deletions src/diagrams/sequenceDiagram/parser/sequenceDiagram.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/diagrams/sequenceDiagram/sequenceDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ exports.LINETYPE = {
ALT_ELSE : 13 ,
ALT_END : 14 ,
OPT_START : 15 ,
OPT_END : 16
OPT_END : 16 ,
ACTIVE_START : 17 ,
ACTIVE_END : 18
};

exports.ARROWTYPE = {
Expand Down Expand Up @@ -100,11 +102,17 @@ exports.apply = function(param){
exports.apply(item);
});
} else {
// log.debug(param);
// console.info(param);
switch(param.type){
case 'addActor':
exports.addActor(param.actor, param.actor, param.description);
break;
case 'activeStart':
exports.addSignal(param.actor, undefined, undefined, param.signalType);
break;
case 'activeEnd':
exports.addSignal(param.actor, undefined, undefined, param.signalType);
break;
case 'addNote':
exports.addNote(param.actor,param.placement, param.text);
break;
Expand Down
Loading

0 comments on commit b3d147b

Please sign in to comment.