108 |
%x PREPROC_SET_COND PREPROC_RESET_COND PREPROC_IF PREPROC_IF_NOT PREPROC_BODY_EAT PREPROC_PRE_BODY_USE PREPROC_PRE_BODY_EAT |
%x PREPROC_SET_COND PREPROC_RESET_COND PREPROC_IF PREPROC_IF_NOT PREPROC_BODY_EAT PREPROC_PRE_BODY_USE PREPROC_PRE_BODY_EAT |
109 |
|
|
110 |
DIGIT [0-9] |
DIGIT [0-9] |
111 |
ID [a-zA-Z0-9_]+ |
ID [a-zA-Z][a-zA-Z0-9_]* |
112 |
|
METRIC (k|h|(da)|d|c|m|u) |
113 |
|
UNIT (s|(Hz)|B) |
114 |
|
|
115 |
%% |
%% |
116 |
|
|
128 |
return INTEGER; |
return INTEGER; |
129 |
} |
} |
130 |
|
|
131 |
|
{DIGIT}+({METRIC}{1,2}|({METRIC}{0,2}{UNIT}?)) { |
132 |
|
int pos = 0; |
133 |
|
|
134 |
|
// parse number portion |
135 |
|
vmint value = 0; |
136 |
|
for (; yytext[pos] >= '0' && yytext[pos] <= '9'; ++pos) { |
137 |
|
value *= 10; |
138 |
|
value += yytext[pos] - '0'; |
139 |
|
} |
140 |
|
yylval->iUnitValue.iValue = value; |
141 |
|
|
142 |
|
// parse metric prefix portion |
143 |
|
for (int i = 0; i < 2; ++i, ++pos) { |
144 |
|
switch (yytext[pos]) { |
145 |
|
case 'k': yylval->iUnitValue.prefix[i] = VM_KILO; continue; |
146 |
|
case 'h': yylval->iUnitValue.prefix[i] = VM_HECTO; continue; |
147 |
|
case 'c': yylval->iUnitValue.prefix[i] = VM_CENTI; continue; |
148 |
|
case 'm': yylval->iUnitValue.prefix[i] = VM_MILLI; continue; |
149 |
|
case 'u': yylval->iUnitValue.prefix[i] = VM_MICRO; continue; |
150 |
|
case 'd': |
151 |
|
if (yytext[pos+1] == 'a') { |
152 |
|
yylval->iUnitValue.prefix[i] = VM_DECA; |
153 |
|
++pos; |
154 |
|
} else { |
155 |
|
yylval->iUnitValue.prefix[i] = VM_DECI; |
156 |
|
} |
157 |
|
continue; |
158 |
|
default: |
159 |
|
yylval->iUnitValue.prefix[i] = VM_NO_PREFIX; |
160 |
|
goto parseStdUnit; |
161 |
|
} |
162 |
|
} |
163 |
|
|
164 |
|
parseStdUnit: |
165 |
|
|
166 |
|
// parse standard measurement unit |
167 |
|
switch (yytext[pos]) { |
168 |
|
case 's': yylval->iUnitValue.unit = VM_SECOND; break; |
169 |
|
case 'H': yylval->iUnitValue.unit = VM_HERTZ; break; |
170 |
|
case 'B': yylval->iUnitValue.unit = VM_BEL; break; |
171 |
|
default: yylval->iUnitValue.unit = VM_NO_UNIT; break; |
172 |
|
} |
173 |
|
|
174 |
|
return INTEGER_UNIT; |
175 |
|
} |
176 |
|
|
177 |
/* there is currently no support for floating point numbers in NKSP yet */ |
/* there is currently no support for floating point numbers in NKSP yet */ |
178 |
/*{DIGIT}+"."{DIGIT}* { |
/*{DIGIT}+"."{DIGIT}* { |
179 |
printf("A float: %s (%g)\n", yytext, atof(yytext)); |
printf("A float: %s (%g)\n", yytext, atof(yytext)); |
319 |
"call" return CALL; |
"call" return CALL; |
320 |
"synchronized" return SYNCHRONIZED; |
"synchronized" return SYNCHRONIZED; |
321 |
|
|
322 |
[&,()[\]<>=*+#/-] { |
[&,!()[\]<>=*+#\/-] { |
323 |
return *yytext; |
return *yytext; |
324 |
} |
} |
325 |
|
|