diff --git a/src/diagrams/gantt/parser/gantt.jison b/src/diagrams/gantt/parser/gantt.jison index 49ab3ad47..75741ab22 100644 --- a/src/diagrams/gantt/parser/gantt.jison +++ b/src/diagrams/gantt/parser/gantt.jison @@ -7,27 +7,42 @@ %options case-insensitive -%{ - // Pre-lexer code can go here -%} - +/* string is used to detect blocks that are surrounded by double quotes. */ +/* 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'; \s+ /* skip whitespace */ \#[^\n]* /* skip comments */ \%%[^\n]* /* skip comments */ -"gantt" return 'gantt'; +/* Strings are used to detect tooltips */ +["] this.begin("string"); +["] this.popState(); +[^"]* return 'STR'; +"call"\s this.begin("callbackname"); +\( this.popState(); this.begin("callback"); +[^(]+ return 'callbackname'; +[)] this.popState(); +[^)]* return 'callbackarguments'; + +"click" return 'click'; +"gantt" return 'gantt'; "dateFormat"\s[^#\n;]+ return 'dateFormat'; "axisFormat"\s[^#\n;]+ return 'axisFormat'; \d\d\d\d"-"\d\d"-"\d\d return 'date'; "title"\s[^#\n;]+ return 'title'; "section"\s[^#:\n;]+ return 'section'; -[^#:\n;]+ return 'taskTxt'; +[^#:()\n;]+ return 'taskTxt'; ":"[^#\n;]+ return 'taskData'; -":" return ':'; -<> return 'EOF'; -. return 'INVALID'; +":" return ':'; +<> return 'EOF'; +. return 'INVALID'; /lex @@ -54,11 +69,17 @@ line ; 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);} - | title {yy.setTitle($1.substr(6));$$=$1.substr(6);} - | section {yy.addSection($1.substr(8));$$=$1.substr(8);} - | taskTxt taskData {yy.addTask($1,$2);$$='task';} - ; + | title {yy.setTitle($1.substr(6));$$=$1.substr(6);} + | section {yy.addSection($1.substr(8));$$=$1.substr(8);} + | 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);} + ; %%