-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmixf.jison
136 lines (109 loc) · 2.26 KB
/
cmixf.jison
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
%lex
%%
. return yytext;
/lex
%start quantity_value
%options easy_keyword_rules
%% /* language grammar */
quantity_value
: real
| real " " unit
| real "." unit
| real unit
{$$=$1;}
;
unit
: unit_product
| unit_product '/' single_unit
;
unit_product
: single_unit
| unit_product '.' single_unit
;
single_unit
: punit
| punit '^' uxponent
| '(' unit ')'
| '(' unit ')^' uxponent
;
uxponent
: uinteger
| '-' uinteger
| '(' uinteger '/' uinteger ')'
| '(-' uinteger '/' uinteger ')'
;
punit
: decimal_multiple_prefix unit_p_symbol
| decimal_submultiple_prefix unit_n_symbol
| decimal_multiple_prefix unit_b_symbol
| decimal_submultiple_prefix unit_b_symbol
| binary_prefix 'B'
| binary_prefix 'bit'
| unit_p_symbol
| unit_n_symbol
| unit_b_symbol
| unit___symbol
;
decimal_multiple_prefix
: 'E' | 'G' | 'M' | 'P' | 'T' | 'Y' | 'Z' | 'da' | 'h' | 'k'
;
decimal_submultiple_prefix
: 'a' | 'c' | 'd' | 'f' | 'm' | 'n' | 'p' | 'u' | 'y' | 'z'
;
binary_prefix
: 'Ei' | 'Gi' | 'Ki' | 'Mi' | 'Pi' | 'Ti'
;
unit_p_symbol
: 'B' | 'Bd' | 'r' | 't'
;
unit_n_symbol
: 'L' | 'Np' | 'o' | 'oC' | 'rad' | 'sr'
;
unit_b_symbol
: 'A' | 'Bq' | 'C' | 'F' | 'Gy' | 'H' | 'Hz' | 'J' | 'K' | 'N'
| 'Ohm' | 'Pa' | 'S' | 'Sv' | 'T' | 'V' | 'W' | 'Wb' | 'bit'
| 'cd' | 'eV' | 'g' | 'kat' | 'lm' | 'lx' | 'm' | 'mol' | 's'
| currency_symbol
;
unit___symbol
: 'd' | 'dB' | 'h' | 'min' | 'u'
;
currency_symbol
: upper_letter upper_letter upper_letter
;
upper_letter
: 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J'
| 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T'
| 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z'
;
real
: ureal
| '-' ureal
;
ureal
: numerical_value
| numerical_value suffix
;
numerical_value
: uinteger
| dot uinteger
| uinteger dot uinteger
| uinteger dot
;
dot
: '.' | ','
;
uinteger
: uinteger digit
| digit
;
suffix
: exponent_marker uinteger
| exponent_marker '-' uinteger
;
exponent_marker
: 'e' | 'E'
;
digit
: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
;