Added <a href> and callback functionality to gantt diagrams

This commit is contained in:
abzicht
2019-03-07 22:00:02 +01:00
parent 7d3578b31a
commit e298351caa

View File

@@ -7,27 +7,42 @@
%options case-insensitive %options case-insensitive
%{ /* string is used to detect blocks that are surrounded by double quotes. */
// Pre-lexer code can go here /* copied from /src/diagrams/flowchart/parser/flow.jison */
%} %x string
/* a valid callback looks like this: callback(example_callback_arg) */
/* callback prefix: callback( */
/* callback suffix: ) */
%x callback
%x callbackname
%% %%
[\n]+ return 'NL'; [\n]+ return 'NL';
\s+ /* skip whitespace */ \s+ /* skip whitespace */
\#[^\n]* /* skip comments */ \#[^\n]* /* skip comments */
\%%[^\n]* /* skip comments */ \%%[^\n]* /* skip comments */
"gantt" return 'gantt'; /* Strings are used to detect tooltips */
["] this.begin("string");
<string>["] this.popState();
<string>[^"]* return 'STR';
"call"\s this.begin("callbackname");
<callbackname>\( this.popState(); this.begin("callback");
<callbackname>[^(]+ return 'callbackname';
<callback>[)] this.popState();
<callback>[^)]* return 'callbackarguments';
"click" return 'click';
"gantt" return 'gantt';
"dateFormat"\s[^#\n;]+ return 'dateFormat'; "dateFormat"\s[^#\n;]+ return 'dateFormat';
"axisFormat"\s[^#\n;]+ return 'axisFormat'; "axisFormat"\s[^#\n;]+ return 'axisFormat';
\d\d\d\d"-"\d\d"-"\d\d return 'date'; \d\d\d\d"-"\d\d"-"\d\d return 'date';
"title"\s[^#\n;]+ return 'title'; "title"\s[^#\n;]+ return 'title';
"section"\s[^#:\n;]+ return 'section'; "section"\s[^#:\n;]+ return 'section';
[^#:\n;]+ return 'taskTxt'; [^#:()\n;]+ return 'taskTxt';
":"[^#\n;]+ return 'taskData'; ":"[^#\n;]+ return 'taskData';
":" return ':'; ":" return ':';
<<EOF>> return 'EOF'; <<EOF>> return 'EOF';
. return 'INVALID'; . return 'INVALID';
/lex /lex
@@ -54,11 +69,17 @@ line
; ;
statement statement
: 'dateFormat' {yy.setDateFormat($1.substr(11));$$=$1.substr(11);} : 'dateFormat' {yy.setDateFormat($1.substr(11));$$=$1.substr(11);}
| 'axisFormat' {yy.setAxisFormat($1.substr(11));$$=$1.substr(11);} | 'axisFormat' {yy.setAxisFormat($1.substr(11));$$=$1.substr(11);}
| title {yy.setTitle($1.substr(6));$$=$1.substr(6);} | title {yy.setTitle($1.substr(6));$$=$1.substr(6);}
| section {yy.addSection($1.substr(8));$$=$1.substr(8);} | section {yy.addSection($1.substr(8));$$=$1.substr(8);}
| taskTxt taskData {yy.addTask($1,$2);$$='task';} | clickStatement
; | taskTxt taskData {yy.addTask($1,$2);$$='task';}
;
clickStatement
: click callbackname callbackarguments {$$ = $1;yy.setClickEvent($2, $3);}
| click STR callbackname callbackarguments {$$ = $1;yy.setLink($2);yy.setClickEvent($3, $4);}
| click STR {$$ = $1;yy.setLink($2);}
;
%% %%