-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPigeon.g4
95 lines (71 loc) · 2.27 KB
/
Pigeon.g4
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
grammar Pigeon;
/*
Parser Rules
*/
script
: pigeoncommands+
(arccommands+)?
EOF
;
pigeoncommands
: promoter
| repressor
| codingseq
| transcription
| stop
| operator
| degredationtag
| righttriangle
| lefttriangle
| bar
| three
| five
| gene
| fseq
| zring
| xbar
| box
| scar
| vector
;
promoter : (invert 'p' | 'p') WS? label? WS? color? WS? ignorecolor? NL+ ;
repressor : (invert 'r' | 'r') WS? label? WS? color? WS? ignorecolor? NL+ ;
codingseq : (invert 'c' | 'c') WS? label? WS? color? WS? ignorecolor? NL+ ;
transcription : (invert 't' | 't') WS? label? WS? color? WS? ignorecolor? NL+ ;
gene : (invert 'g' | 'g') WS? label? WS? color? WS? ignorecolor? NL+ ;
fseq : (invert 'f' | 'f') WS? label? WS? color? WS? ignorecolor? NL+ ;
stop : 's' WS* label? WS* color? WS* ignorecolor? NL+;
operator : 'o' WS* label? WS* color? WS* ignorecolor? NL+;
degredationtag : 'd' WS* label? WS* color? WS* ignorecolor? NL+;
righttriangle : '>' WS* label? WS* color? WS* ignorecolor? NL+ ; // not sure this need labels
lefttriangle : '<' WS* label? WS* color? WS* ignorecolor? NL+ ; // not sure this needs labels
bar : '|' WS* label? WS* color? WS* ignorecolor? NL+ ;
three : invert? '3' WS* label? WS* color? WS* ignorecolor? NL+ ;
five : invert? '5' WS* label? WS* color? WS* ignorecolor? NL+ ;
zring : invert? 'z' WS* label? WS* color? WS* ignorecolor? NL+ ;
xbar : 'x' WS* label? WS* color? WS* ignorecolor? NL+ ;
box : '?' WS* label? WS* color? WS* ignorecolor? NL+ ;
scar: '=' WS* label? WS* color? WS* ignorecolor? NL+ ;
vector: 'v' WS? label? NL+;
invert : '<';
color: (INT | '3' | '5');
label: ( ID INT? ID? | INT ID | commands INT | commands '3' | commands '5' | '<' ID | '>' ID);
ignorecolor : 'nl';
commands : ('?'|'3'|'5'|'p'|'r'|'c'|'g'|'f'
|'t'|'s'|'o'|'>'|'<'|'|'|'z'|'x'|'d');
arccommands
: rep
| ind
| rep2
;
rep : label WS 'rep' WS label NL+;
rep2: label WS 'rep' WS label'-'label NL+;
ind : label WS 'ind' WS label NL+;
/*
Lexer Rules
*/
ID : ('a'..'z'|'A'..'Z'| '_'| '-'| '[' | ']')('a'..'z'|'A'..'Z'|'0'..'9'| '_'| '-'| '[' | ']')* ;
INT : [0-9]+ ;
LINE_COMMENT : '#' ~[\r\n]* -> skip;
WS : ' '+;
NL : ( '\r' ? '\n' | '\r' )+;