Application of common header gramnmar for class and sequence diagrams

This commit is contained in:
Knut Sveidqvist
2025-09-22 14:23:00 +02:00
parent c98da4d022
commit fa75f8de77
2 changed files with 8 additions and 4 deletions

View File

@@ -1,4 +1,6 @@
lexer grammar ClassLexer;
import HeaderCommon;
tokens {
ACC_TITLE_VALUE,
@@ -28,13 +30,13 @@ fragment NOT_DQUOTE: ~[""];
// Comments and whitespace
COMMENT: '%%' ~[\r\n]* -> skip;
NEWLINE: ('\r'? '\n')+ { this.clearPendingScopes(); };
WS: [ \t]+ -> skip;
// Diagram title declaration
CLASS_DIAGRAM_V2: 'classDiagram-v2' -> type(CLASS_DIAGRAM);
CLASS_DIAGRAM: 'classDiagram';
CLASS_DIAGRAM_V2: 'classDiagram-v2' { this.headerMode = false; } -> type(CLASS_DIAGRAM);
CLASS_DIAGRAM: 'classDiagram' { this.headerMode = false; };
// Directions
DIRECTION_TB: 'direction' WS_INLINE+ 'TB';

View File

@@ -1,4 +1,6 @@
lexer grammar FlowLexer;
import HeaderCommon;
// Virtual tokens for parser
tokens {
@@ -25,7 +27,7 @@ HREF: 'href' WS;
CLICK: 'click' WS+ [A-Za-z0-9_]+ -> pushMode(CLICK_MODE);
// Graph declaration tokens - these trigger direction mode
GRAPH: ('flowchart-elk' | 'graph' | 'flowchart') -> pushMode(DIR_MODE);
GRAPH: ('flowchart-elk' | 'graph' | 'flowchart') { this.headerMode = false; } -> pushMode(DIR_MODE);
SUBGRAPH: 'subgraph';
END: 'end';