From 1dfff7ac0eb61ceebae6fa7074adf5cb7cc9c43b Mon Sep 17 00:00:00 2001 From: abzicht Date: Sun, 10 Mar 2019 13:41:02 +0100 Subject: [PATCH] Added documentation and implemented empty functionarguments --- src/diagrams/gantt/parser/gantt.jison | 55 +++++++++++++++++++++------ 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/src/diagrams/gantt/parser/gantt.jison b/src/diagrams/gantt/parser/gantt.jison index 358f157da..723052b14 100644 --- a/src/diagrams/gantt/parser/gantt.jison +++ b/src/diagrams/gantt/parser/gantt.jison @@ -7,8 +7,6 @@ %options case-insensitive -/* string is used to detect blocks that are surrounded by double quotes. */ -/* copied from /src/diagrams/flowchart/parser/flow.jison */ %x click %x href %x callbackname @@ -20,16 +18,37 @@ \#[^\n]* /* skip comments */ \%%[^\n]* /* skip comments */ -"href"[\s]+["] this.begin("href"); /* return the next double quoted word after 'href' */ -["] this.popState(); /* e.g. return https://example.com for 'href "https://example.com"' */ +/* +---interactivity command--- +'href' adds a link to the specified task. 'href' can only be specified when the +line was introduced with 'click'. +'href ""' attaches the specified link to the task that was specified by 'click'. +*/ +"href"[\s]+["] this.begin("href"); +["] this.popState(); [^"]* return 'href'; +/* +---interactivity command--- +'call' adds a callback to the specified task. 'call' can only be specified when +the line was introdcued with 'click'. +'call ()' attaches the function 'callbackname' with the specified +arguments to the task that was specified by 'click'. +Function arguments are optional: 'call ()' simply executes 'callbackname' without any arguments. +*/ "call"[\s]+ this.begin("callbackname"); +\([\s]*\) this.popState(); \( this.popState(); this.begin("callbackargs"); [^(]* return 'callbackname'; \) this.popState(); [^)]* return 'callbackargs'; +/* +'click' is the keyword to introduce a line that contains interactivity commands. +'click' must be followed by an existing task-id. All commands are attached to +that id. +'click ' can be followed by href or call commands in any desired order +*/ "click"[\s]+ this.begin("click"); [\s\n] this.popState(); [^\s\n]* return 'click'; @@ -79,17 +98,31 @@ statement | taskTxt taskData {yy.addTask($1,$2);$$='task';} ; +/* +click allows any combination of href and call. +*/ clickStatement - : click callbackname callbackargs {$$ = $1;yy.setClickEvent($1, $2, $3);} + : click callbackname {$$ = $1;yy.setClickEvent($1, $2, null);} + | click callbackname callbackargs {$$ = $1;yy.setClickEvent($1, $2, $3);} + + | click callbackname href {$$ = $1;yy.setClickEvent($1, $2, null);yy.setLink($1,$3);} | click callbackname callbackargs href {$$ = $1;yy.setClickEvent($1, $2, $3);yy.setLink($1,$4);} + + | click href callbackname {$$ = $1;yy.setClickEvent($1, $3, null);yy.setLink($1,$2);} | click href callbackname callbackargs {$$ = $1;yy.setClickEvent($1, $3, $4);yy.setLink($1,$2);} + | click href {$$ = $1;yy.setLink($1, $2);} ; clickStatementDebug - : click callbackname callbackargs {$$=$1+' ' + $2 + ' ' + $3;} - | click callbackname callbackargs href {$$=$1+' ' + $2 + ' ' + $3 + ' ' + $4;} - | click href callbackname callbackargs {$$=$1+' ' + $2 + ' ' + $3 + ' ' + $4;} - | click href {$$=$1+' ' + $2;} - ; -%% + : click callbackname {$$=$1 + ' ' + $2;} + | click callbackname href {$$=$1 + ' ' + $2 + ' ' + $3;} + + | click callbackname callbackargs {$$=$1 + ' ' + $2 + ' ' + $3;} + | click callbackname callbackargs href {$$=$1 + ' ' + $2 + ' ' + $3 + ' ' + $4;} + + | click href callbackname {$$=$1 + ' ' + $2 + ' ' + $3;} + | click href callbackname callbackargs {$$=$1 + ' ' + $2 + ' ' + $3 + ' ' + $4;} + + | click href {$$=$1 + ' ' + $2;} + ;%%