-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.g4
More file actions
50 lines (40 loc) · 1.49 KB
/
Graph.g4
File metadata and controls
50 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
grammar Graph;
import Expression;
// Parser rules
diagram : STARTUML diagramName? diagramBody ENDUML ;
diagramName : graphOrInterfaceName ;
diagramBody : (transition | stateDeclaration | pseudostateDeclaration | comment | NEWLINE)* ;
transition : stateReference ARROW stateReference (COLON transitionLabel)? NEWLINE ;
stateDeclaration : stateReference COLON assignment NEWLINE
| 'state' stateReference LBRACE diagramBody RBRACE NEWLINE
;
pseudostateDeclaration : 'state' pseudostateName PSEUDOSTATE NEWLINE ;
pseudostateName : NAME_CAMEL_CASE | NAME_ALL_LOWERCASE ;
stateReference : INITIAL_STATE_NAME | pseudostateName | stateName ;
stateName : NAME_UPPER_SNAKE_CASE | NAME_ALL_UPPERCASE ;
transitionLabel : priority? labelText ;
priority : LBRACK INT RBRACK ;
labelText : expression? ;
comment : COMMENT ;
termReference : (NAME_PASCAL_CASE | NAME_ALL_UPPERCASE) ;
// Override the atom rule to allow a direct term name (NAME)
atom
: '(' expression ')'
| comparison
| termReference
;
// Lexer rules
STARTUML : '@startuml' WS* ;
ENDUML : '@enduml' WS* ;
ARROW : '-->' | '-left->' | '-right->' | '-up->' | '-down->' | '\u2192' ;
COLON : ':' ;
LBRACK : '[' ;
RBRACK : ']' ;
LBRACE : '{';
RBRACE : '}';
INITIAL_STATE_NAME : '[*]' ;
INT : [0-9]+ ;
COMMENT : '//' ~[\r\n]* ;
NEWLINE : ('\r'? '\n')+ ;
WS : [ \t]+ -> skip ;
PSEUDOSTATE : '<<choice>>' ;