FermionOperator.g4 671 Bytes
Newer Older
1
2
grammar FermionOperator;

3
fermionSrc : term ( plusorminus term ) *;
4
5
6
7
8
9
10

plusorminus : '+' | '-';

term : coeff ? (fermion) *;

fermion : op;

11
12
13
op : INT carat?;

carat : '^';
14

15
coeff : complex | real ;
16

17
complex : '('(real | INT | scientific)','(real | INT | scientific)')';
18

19
real : REAL | scientific;
20
21
22
23
24
25
26
27

comment : COMMENT;

COMMENT : '#' ~[\r\n] * EOL;

/* Real number */
REAL : ('-') ? INT ? '.' INT;

28
29
30
/* scientific notation */
scientific : REAL ? ('e'|'E') ? INT;

31
/* Non-negative integer */
32
INT : ('-') ? ('0'..'9') + ;
33
34
35
36
37
38
39
40

/* Strings include numbers and slashes */

/* Whitespaces, we skip'em */
WS : [ \t\r\n]->skip;

/* This is the end of the line, boys */
EOL : '\r' ? '\n';