class body grammer apply to class stetement only

This commit is contained in:
Kazuki Tsunemi 2023-03-09 21:14:30 +09:00
parent 273a9e7ad6
commit c1df62638d

View File

@ -19,6 +19,8 @@
%x acc_title %x acc_title
%x acc_descr %x acc_descr
%x acc_descr_multiline %x acc_descr_multiline
%x class
%x class-body
%% %%
\%\%\{ { this.begin('open_directive'); return 'open_directive'; } \%\%\{ { this.begin('open_directive'); return 'open_directive'; }
.*direction\s+TB[^\n]* return 'direction_tb'; .*direction\s+TB[^\n]* return 'direction_tb';
@ -41,35 +43,30 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
\s*(\r?\n)+ return 'NEWLINE'; \s*(\r?\n)+ return 'NEWLINE';
\s+ /* skip whitespace */ \s+ /* skip whitespace */
"classDiagram-v2" return 'CLASS_DIAGRAM'; "classDiagram-v2" return 'CLASS_DIAGRAM';
"classDiagram" return 'CLASS_DIAGRAM'; "classDiagram" return 'CLASS_DIAGRAM';
[{] { this.begin("struct"); /*console.log('Starting struct');*/ return 'STRUCT_START';} "[*]" return 'EDGE_STATE';
<INITIAL,struct>"[*]" { /*console.log('EDGE_STATE=',yytext);*/ return 'EDGE_STATE';}
<struct><<EOF>> return "EOF_IN_STRUCT";
<struct>[{] return "OPEN_IN_STRUCT";
<struct>[}] { /*console.log('Ending struct');*/this.popState(); return 'STRUCT_STOP';}}
<struct>[\n] /* nothing */
<struct>[^{}\n]* { /*console.log('lex-member: ' + yytext);*/ return "MEMBER";}
"class" return 'CLASS'; "class" { this.begin('class'); return 'CLASS';}
"cssClass" return 'CSSCLASS'; <class>\s*(\r?\n)+ { this.popState(); return 'NEWLINE'; }
"callback" return 'CALLBACK'; <class>\s+ /* skip whitespace */
"link" return 'LINK'; <class>[{] { this.begin("class-body"); return 'STRUCT_START';}
"click" return 'CLICK'; <class-body>[}] { this.popState(); return 'STRUCT_STOP'; }
"note for" return 'NOTE_FOR'; <class-body><<EOF>> return "EOF_IN_STRUCT";
"note" return 'NOTE'; <class-body>"[*]" { return 'EDGE_STATE';}
"<<" return 'ANNOTATION_START'; <class-body>[{] return "OPEN_IN_STRUCT";
">>" return 'ANNOTATION_END'; <class-body>[\n] /* nothing */
[~] this.begin("generic"); <class-body>[^{}\n]* { return "MEMBER";}
<generic>[~] this.popState();
<generic>[^~]* return "GENERICTYPE";
["] this.begin("string");
<string>["] this.popState();
<string>[^"]* return "STR";
[`] this.begin("bqstring"); <*>"cssClass" return 'CSSCLASS';
<bqstring>[`] this.popState(); <*>"callback" return 'CALLBACK';
<bqstring>[^`]+ return "BQUOTE_STR"; <*>"link" return 'LINK';
<*>"click" return 'CLICK';
<*>"note for" return 'NOTE_FOR';
<*>"note" return 'NOTE';
<*>"<<" return 'ANNOTATION_START';
<*>">>" return 'ANNOTATION_END';
/* /*
---interactivity command--- ---interactivity command---
@ -77,7 +74,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
line was introduced with 'click'. line was introduced with 'click'.
'href "<link>"' attaches the specified link to the node that was specified by 'click'. 'href "<link>"' attaches the specified link to the node that was specified by 'click'.
*/ */
"href"[\s]+["] this.begin("href"); <*>"href"[\s]+["] this.begin("href");
<href>["] this.popState(); <href>["] this.popState();
<href>[^"]* return 'HREF'; <href>[^"]* return 'HREF';
@ -89,41 +86,53 @@ the line was introduced with 'click'.
arguments to the node that was specified by 'click'. arguments to the node that was specified by 'click'.
Function arguments are optional: 'call <callback_name>()' simply executes 'callback_name' without any arguments. Function arguments are optional: 'call <callback_name>()' simply executes 'callback_name' without any arguments.
*/ */
"call"[\s]+ this.begin("callback_name"); <*>"call"[\s]+ this.begin("callback_name");
<callback_name>\([\s]*\) this.popState(); <callback_name>\([\s]*\) this.popState();
<callback_name>\( this.popState(); this.begin("callback_args"); <callback_name>\( this.popState(); this.begin("callback_args");
<callback_name>[^(]* return 'CALLBACK_NAME'; <callback_name>[^(]* return 'CALLBACK_NAME';
<callback_args>\) this.popState(); <callback_args>\) this.popState();
<callback_args>[^)]* return 'CALLBACK_ARGS'; <callback_args>[^)]* return 'CALLBACK_ARGS';
"_self" return 'LINK_TARGET'; <generic>[~] this.popState();
"_blank" return 'LINK_TARGET'; <generic>[^~]* return "GENERICTYPE";
"_parent" return 'LINK_TARGET'; <*>[~] this.begin("generic");
"_top" return 'LINK_TARGET';
\s*\<\| return 'EXTENSION'; <string>["] this.popState();
\s*\|\> return 'EXTENSION'; <string>[^"]* return "STR";
\s*\> return 'DEPENDENCY'; <*>["] this.begin("string");
\s*\< return 'DEPENDENCY';
\s*\* return 'COMPOSITION'; <bqstring>[`] this.popState();
\s*o return 'AGGREGATION'; <bqstring>[^`]+ return "BQUOTE_STR";
\s*\(\) return 'LOLLIPOP'; <*>[`] this.begin("bqstring");
\-\- return 'LINE';
\.\. return 'DOTTED_LINE'; <*>"_self" return 'LINK_TARGET';
":"{1}[^:\n;]+ return 'LABEL'; <*>"_blank" return 'LINK_TARGET';
":"{3} return 'STYLE_SEPARATOR'; <*>"_parent" return 'LINK_TARGET';
\- return 'MINUS'; <*>"_top" return 'LINK_TARGET';
"." return 'DOT';
\+ return 'PLUS'; <*>\s*\<\| return 'EXTENSION';
\% return 'PCT'; <*>\s*\|\> return 'EXTENSION';
"=" return 'EQUALS'; <*>\s*\> return 'DEPENDENCY';
\= return 'EQUALS'; <*>\s*\< return 'DEPENDENCY';
\w+ return 'ALPHA'; <*>\s*\* return 'COMPOSITION';
"[" return 'SQS'; <*>\s*o return 'AGGREGATION';
"]" return 'SQE'; <*>\s*\(\) return 'LOLLIPOP';
[!"#$%&'*+,-.`?\\/] return 'PUNCTUATION'; <*>\-\- return 'LINE';
[0-9]+ return 'NUM'; <*>\.\. return 'DOTTED_LINE';
[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]| <*>":"{1}[^:\n;]+ return 'LABEL';
<*>":"{3} return 'STYLE_SEPARATOR';
<*>\- return 'MINUS';
<*>"." return 'DOT';
<*>\+ return 'PLUS';
<*>\% return 'PCT';
<*>"=" return 'EQUALS';
<*>\= return 'EQUALS';
<*>\w+ return 'ALPHA';
<*>"[" return 'SQS';
<*>"]" return 'SQE';
<*>[!"#$%&'*+,-.`?\\/] return 'PUNCTUATION';
<*>[0-9]+ return 'NUM';
<*>[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|
[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]| [\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|
[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]| [\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|
[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]| [\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|
@ -184,9 +193,9 @@ Function arguments are optional: 'call <callback_name>()' simply executes 'callb
[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]| [\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|
[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]| [\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|
[\uFFD2-\uFFD7\uFFDA-\uFFDC] [\uFFD2-\uFFD7\uFFDA-\uFFDC]
return 'UNICODE_TEXT'; return 'UNICODE_TEXT';
\s return 'SPACE'; <*>\s return 'SPACE';
<<EOF>> return 'EOF'; <*><<EOF>> return 'EOF';
/lex /lex