From fbb6eb849eb11700b7a3356027c2825dd507fd2c Mon Sep 17 00:00:00 2001 From: Ibrahim Wassouf Date: Sat, 8 Jul 2023 14:07:46 -0300 Subject: [PATCH] Give call higher precedence than STR --- .../diagrams/class/parser/classDiagram.jison | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/mermaid/src/diagrams/class/parser/classDiagram.jison b/packages/mermaid/src/diagrams/class/parser/classDiagram.jison index 170e2cd4f..28725c7ac 100644 --- a/packages/mermaid/src/diagrams/class/parser/classDiagram.jison +++ b/packages/mermaid/src/diagrams/class/parser/classDiagram.jison @@ -50,6 +50,21 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili "classDiagram" return 'CLASS_DIAGRAM'; "[*]" return 'EDGE_STATE'; +/* +---interactivity command--- +'call' adds a callback to the specified node. 'call' can only be specified when +the line was introduced with 'click'. +'call ()' attaches the function 'callback_name' with the specified +arguments to the node that was specified by 'click'. +Function arguments are optional: 'call ()' simply executes 'callback_name' without any arguments. +*/ +"call"[\s]+ this.begin("callback_name"); +\([\s]*\) this.popState(); +\( this.popState(); this.begin("callback_args"); +[^(]* return 'CALLBACK_NAME'; +\) this.popState(); +[^)]* return 'CALLBACK_ARGS'; + ["] this.popState(); [^"]* return "STR"; <*>["] this.begin("string"); @@ -92,24 +107,10 @@ line was introduced with 'click'. 'href ""' attaches the specified link to the node that was specified by 'click'. */ <*>"href" return 'HREF'; -/* ----interactivity command--- -'call' adds a callback to the specified node. 'call' can only be specified when -the line was introduced with 'click'. -'call ()' attaches the function 'callback_name' with the specified -arguments to the node that was specified by 'click'. -Function arguments are optional: 'call ()' simply executes 'callback_name' without any arguments. -*/ -<*>"call"[\s]+ this.begin("callback_name"); -\([\s]*\) this.popState(); -\( this.popState(); this.begin("callback_args"); -[^(]* return 'CALLBACK_NAME'; -\) this.popState(); -[^)]* return 'CALLBACK_ARGS'; [~] this.popState(); [^~]* return "GENERICTYPE"; -"~" this.begin("generic"); +<*>"~" this.begin("generic"); [`] this.popState(); [^`]+ return "BQUOTE_STR";