author | Michael Krelin <hacker@klever.net> | 2005-03-31 13:27:36 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-03-31 13:27:36 (UTC) |
commit | ef14961fe10614eb15c71dd5b0b83f292bd7a5b0 (patch) (unidiff) | |
tree | 2be43fc5d441070db94c6e9881948d6ba2a87b04 /lib/sitecing_parser.ll | |
parent | 9c755a29c43bcf4a3a1bbd55ae7e590fc6ff2e21 (diff) | |
download | sitecing-ef14961fe10614eb15c71dd5b0b83f292bd7a5b0.zip sitecing-ef14961fe10614eb15c71dd5b0b83f292bd7a5b0.tar.gz sitecing-ef14961fe10614eb15c71dd5b0b83f292bd7a5b0.tar.bz2 |
minor improvements to code aesthetics
-rw-r--r-- | lib/sitecing_parser.ll | 159 |
1 files changed, 81 insertions, 78 deletions
diff --git a/lib/sitecing_parser.ll b/lib/sitecing_parser.ll index 8ba8673..9514ce4 100644 --- a/lib/sitecing_parser.ll +++ b/lib/sitecing_parser.ll | |||
@@ -102,459 +102,462 @@ NOIDCHAR [^A-Za-z0-9_] | |||
102 | <<EOF>>{ | 102 | <<EOF>>{ |
103 | assert(modi.size()==1); | 103 | assert(modi.size()==1); |
104 | M().modify(modus_operandi::modus_preop); | 104 | M().modify(modus_operandi::modus_preop); |
105 | LexerOutput(";",1); | 105 | LexerOutput(";",1); |
106 | return 0; | 106 | return 0; |
107 | } | 107 | } |
108 | } | 108 | } |
109 | <<EOF>>throw preprocessor_error(CODEPOINT,"unexpected end of file",lineno()); | 109 | <<EOF>>throw preprocessor_error(CODEPOINT,"unexpected end of file",lineno()); |
110 | 110 | ||
111 | <CODEBLOCK,CODEMETHODBLOCK>{ | 111 | <CODEBLOCK,CODEMETHODBLOCK>{ |
112 | "<%output>"{ | 112 | "<%output>"{ |
113 | anchor(); | 113 | anchor(); |
114 | yy_push_state(OUTPUTBLOCK); | 114 | yy_push_state(OUTPUTBLOCK); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | <PRAGMALINE>{ | 118 | <PRAGMALINE>{ |
119 | {WHITESPACE}+{ | 119 | {WHITESPACE}+{ |
120 | modus_operandi& m = M(); | 120 | modus_operandi& m = M(); |
121 | if(!m.output.empty()) { | 121 | if(!m.output.empty()) { |
122 | string::size_type eq = m.output.find('='); | 122 | string::size_type eq = m.output.find('='); |
123 | if(eq==string::npos) { | 123 | if(eq==string::npos) { |
124 | pragmas[m.output]=m.output; | 124 | pragmas[m.output]=m.output; |
125 | }else{ | 125 | }else{ |
126 | pragmas[m.output.substr(0,eq)] = m.output.substr(eq+1); | 126 | pragmas[m.output.substr(0,eq)] = m.output.substr(eq+1); |
127 | } | 127 | } |
128 | m.output.erase(); | 128 | m.output.erase(); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | \n { | 131 | \n { |
132 | modus_operandi& m = M(); | 132 | modus_operandi& m = M(); |
133 | if(!m.output.empty()) { | 133 | if(!m.output.empty()) { |
134 | string::size_type eq = m.output.find('='); | 134 | string::size_type eq = m.output.find('='); |
135 | if(eq==string::npos) { | 135 | if(eq==string::npos) { |
136 | pragmas[m.output]=m.output; | 136 | pragmas[m.output]=m.output; |
137 | }else{ | 137 | }else{ |
138 | pragmas[m.output.substr(0,eq)] = m.output.substr(eq+1); | 138 | pragmas[m.output.substr(0,eq)] = m.output.substr(eq+1); |
139 | } | 139 | } |
140 | m.output.erase(); | 140 | m.output.erase(); |
141 | } | 141 | } |
142 | modi.pop_front(); | 142 | modi.pop_front(); |
143 | BEGIN(INITIAL); | 143 | BEGIN(INITIAL); |
144 | anchor(); | 144 | anchor(); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | <METHODLINE>{ | 148 | <METHODLINE>{ |
149 | {WHITESPACE}+{ | 149 | {WHITESPACE}+{ |
150 | modus_operandi& m = modi.front(); | 150 | modus_operandi& m = M(); |
151 | if(!m.output.empty()) { | 151 | if(!m.output.empty()) { |
152 | if(!m._lastid.empty()) { | 152 | if(!m._lastid.empty()) { |
153 | if(!m._type.empty()) m._type += ' '; | 153 | if(!m._type.empty()) m._type += ' '; |
154 | m._type += m._lastid; | 154 | m._type += m._lastid; |
155 | } | 155 | } |
156 | m._lastid = m.output; | 156 | m._lastid = m.output; |
157 | m.output.clear(); | 157 | m.output.clear(); |
158 | } | 158 | } |
159 | } | 159 | } |
160 | \*{ | 160 | \*{ |
161 | modus_operandi& m = modi.front(); | 161 | modus_operandi& m = M(); |
162 | ECHO; | 162 | ECHO; |
163 | if(!m._lastid.empty()) { | 163 | if(!m._lastid.empty()) { |
164 | if(!m._type.empty()) m._type += ' '; | 164 | if(!m._type.empty()) m._type += ' '; |
165 | m._type += m._lastid; | 165 | m._type += m._lastid; |
166 | } | 166 | } |
167 | m._lastid = m.output; | 167 | m._lastid = m.output; |
168 | m.output.clear(); | 168 | m.output.clear(); |
169 | } | 169 | } |
170 | \({ | 170 | \({ |
171 | modus_operandi& m = modi.front(); | 171 | modus_operandi& m = M(); |
172 | if(m.output.empty()) { | 172 | if(m.output.empty()) { |
173 | m._name=m._lastid; | 173 | m._name=m._lastid; |
174 | }else{ | 174 | }else{ |
175 | if(!m._lastid.empty()) { // XXX: lastid, I believe should never be emtpy... | 175 | if(!m._lastid.empty()) { // XXX: lastid, I believe should never be emtpy... |
176 | if(!m._type.empty()) m._type += ' '; | 176 | if(!m._type.empty()) m._type += ' '; |
177 | m._type += m._lastid; | 177 | m._type += m._lastid; |
178 | } | 178 | } |
179 | m._name = m.output; | 179 | m._name = m.output; |
180 | m.output.clear(); | 180 | m.output.clear(); |
181 | } | 181 | } |
182 | ECHO; | 182 | ECHO; |
183 | BEGIN(METHODARGS); | 183 | BEGIN(METHODARGS); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | <METHODARGS>{ | 186 | <METHODARGS>{ |
187 | \%\>{ | 187 | \%\>{ |
188 | modus_operandi& m = modi.front(); | 188 | modus_operandi& m = M(); |
189 | m._args = m.output; | 189 | m._args = m.output; |
190 | m.output.clear(); | 190 | m.output.clear(); |
191 | anchor(); | 191 | anchor(); |
192 | BEGIN(METHODBLOCK); | 192 | BEGIN(METHODBLOCK); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | <INITIAL,METHODBLOCK,OUTPUTBLOCK>{ | 196 | <INITIAL,METHODBLOCK,OUTPUTBLOCK>{ |
197 | \<\%{WHITESPACE}+{ | 197 | \<\%{WHITESPACE}+{ |
198 | M().modify(modus_operandi::modus_postop); | 198 | M().modify(modus_operandi::modus_postop); |
199 | anchor(); | 199 | anchor(); |
200 | LexerOutput("(",1); | 200 | LexerOutput("(",1); |
201 | yy_push_state(INLINE); | 201 | yy_push_state(INLINE); |
202 | } | 202 | } |
203 | ^\%{WHITESPACE}{ | 203 | ^\%{WHITESPACE}{ |
204 | M().modify(modus_operandi::modus_code); | 204 | M().modify(modus_operandi::modus_code); |
205 | anchor(); | 205 | anchor(); |
206 | yy_push_state(CODELINE); | 206 | yy_push_state(CODELINE); |
207 | } | 207 | } |
208 | \<\%code\>{ | 208 | \<\%code\>{ |
209 | M().modify(modus_operandi::modus_code); | 209 | M().modify(modus_operandi::modus_code); |
210 | anchor(); | 210 | anchor(); |
211 | yy_push_state(CODEBLOCK); | 211 | yy_push_state(CODEBLOCK); |
212 | } | 212 | } |
213 | "</%output>" { | 213 | "</%output>" { |
214 | if(YY_START!=OUTPUTBLOCK) throw preprocessor_error(CODEPOINT,"unexpected tag",lineno()); | 214 | if(YY_START!=OUTPUTBLOCK) throw preprocessor_error(CODEPOINT,"unexpected tag",lineno()); |
215 | M().modify(modus_operandi::modus_code); | 215 | M().modify(modus_operandi::modus_code); |
216 | anchor(); | 216 | anchor(); |
217 | yy_pop_state(); | 217 | yy_pop_state(); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | <INLINE>\%\>LexerOutput(")",1); M().modus=modus_operandi::modus_preop; yy_pop_state(); | 221 | <INLINE>\%\>LexerOutput(")",1); M().modus=modus_operandi::modus_preop; yy_pop_state(); |
222 | <CODELINE>\nyy_pop_state(); | 222 | <CODELINE>\nyy_pop_state(); |
223 | 223 | ||
224 | <CODEMETHODLINE>{ | 224 | <CODEMETHODLINE>{ |
225 | {WHITESPACE}+{ | 225 | {WHITESPACE}+{ |
226 | modus_operandi& m = modi.front(); | 226 | modus_operandi& m = M(); |
227 | if(!m.output.empty()) { | 227 | if(!m.output.empty()) { |
228 | if(!m._lastid.empty()) { | 228 | if(!m._lastid.empty()) { |
229 | if(!m._type.empty()) m._type += ' '; | 229 | if(!m._type.empty()) m._type += ' '; |
230 | m._type += m._lastid; | 230 | m._type += m._lastid; |
231 | } | 231 | } |
232 | m._lastid = m.output; | 232 | m._lastid = m.output; |
233 | m.output.clear(); | 233 | m.output.clear(); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | \*{ | 236 | \*{ |
237 | modus_operandi& m = modi.front(); | 237 | modus_operandi& m = M(); |
238 | ECHO; | 238 | ECHO; |
239 | if(!m._lastid.empty()) { | 239 | if(!m._lastid.empty()) { |
240 | if(!m._type.empty()) m._type += ' '; | 240 | if(!m._type.empty()) m._type += ' '; |
241 | m._type += m._lastid; | 241 | m._type += m._lastid; |
242 | } | 242 | } |
243 | m._lastid = m.output; | 243 | m._lastid = m.output; |
244 | m.output.clear(); | 244 | m.output.clear(); |
245 | } | 245 | } |
246 | \({ | 246 | \({ |
247 | modus_operandi& m = modi.front(); | 247 | modus_operandi& m = M(); |
248 | if(m.output.empty()) { | 248 | if(m.output.empty()) { |
249 | m._name=m._lastid; | 249 | m._name=m._lastid; |
250 | }else{ | 250 | }else{ |
251 | if(!m._lastid.empty()) { // XXX: lastid, I believe should never be emtpy... | 251 | if(!m._lastid.empty()) { // XXX: lastid, I believe should never be emtpy... |
252 | if(!m._type.empty()) m._type += ' '; | 252 | if(!m._type.empty()) m._type += ' '; |
253 | m._type += m._lastid; | 253 | m._type += m._lastid; |
254 | } | 254 | } |
255 | m._name = m.output; | 255 | m._name = m.output; |
256 | m.output.clear(); | 256 | m.output.clear(); |
257 | } | 257 | } |
258 | ECHO; | 258 | ECHO; |
259 | BEGIN(CODEMETHODARGS); | 259 | BEGIN(CODEMETHODARGS); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | <CODEMETHODARGS>{ | 262 | <CODEMETHODARGS>{ |
263 | \%\>{ | 263 | \%\>{ |
264 | modus_operandi& m = modi.front(); | 264 | modus_operandi& m = M(); |
265 | m._args = m.output; | 265 | m._args = m.output; |
266 | m.output.clear(); | 266 | m.output.clear(); |
267 | m.flags=0; | 267 | m.flags=0; |
268 | anchor(); | 268 | anchor(); |
269 | BEGIN(CODEMETHODBLOCK); | 269 | BEGIN(CODEMETHODBLOCK); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | <IMPORTLINE>{ | 273 | <IMPORTLINE>{ |
274 | {WHITESPACE}+{ } | 274 | {WHITESPACE}+{ } |
275 | {ID}{ | 275 | {ID}{ |
276 | if(!modi.front()._name.empty()) | 276 | modus_operandi& m = M(); |
277 | throw preprocessor_error(CODEPOINT,"syntax error",lineno()); | 277 | if(!m._name.empty()) |
278 | modi.front()._name = yytext; | 278 | throw preprocessor_error(CODEPOINT,"syntax error",lineno()); |
279 | } | 279 | m._name = yytext; |
280 | } | ||
280 | \= { | 281 | \= { |
281 | modi.front().output.clear(); | 282 | M().output.clear(); |
282 | BEGIN(IMPORTCOMPONENT); | 283 | BEGIN(IMPORTCOMPONENT); |
283 | } | 284 | } |
284 | } | 285 | } |
285 | <IMPORTCOMPONENT>{ | 286 | <IMPORTCOMPONENT>{ |
286 | {WHITESPACE}+{ } | 287 | {WHITESPACE}+{ } |
287 | \n{ | 288 | \n{ |
288 | modus_operandi& m = M(); | 289 | modus_operandi& m = M(); |
289 | string::size_type t = m.output.find_first_not_of(" \t"); | 290 | string::size_type t = m.output.find_first_not_of(" \t"); |
290 | if(t!=string::npos) | 291 | if(t!=string::npos) |
291 | m.output.erase(0,t); | 292 | m.output.erase(0,t); |
292 | t = m.output.find_last_not_of(" \t;"); | 293 | t = m.output.find_last_not_of(" \t;"); |
293 | if(t!=string::npos) | 294 | if(t!=string::npos) |
294 | m.output.erase(t+1); | 295 | m.output.erase(t+1); |
295 | if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') { | 296 | if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') { |
296 | m.output.erase(0,1); | 297 | m.output.erase(0,1); |
297 | m.output.erase(m.output.length()-1); | 298 | m.output.erase(m.output.length()-1); |
298 | } | 299 | } |
299 | string c = combine_path(component_basename,m.output); | 300 | string c = combine_path(component_basename,m.output); |
300 | member_variables.push_back(member_variable(m._type,m._name,normalize_path(c,strip_leading_slash),true)); | 301 | member_variables.push_back(member_variable(m._type,m._name,normalize_path(c,strip_leading_slash),true)); |
301 | modi.pop_front(); | 302 | modi.pop_front(); |
302 | BEGIN(INITIAL); | 303 | BEGIN(INITIAL); |
303 | } | 304 | } |
304 | } | 305 | } |
305 | 306 | ||
306 | <IMPORTTYPELINE>{ | 307 | <IMPORTTYPELINE>{ |
307 | {WHITESPACE}+{ } | 308 | {WHITESPACE}+{ } |
308 | {ID}{ | 309 | {ID}{ |
309 | if(!modi.front()._name.empty()) | 310 | modus_operandi& m = M(); |
310 | throw preprocessor_error(CODEPOINT,"syntax error",lineno()); | 311 | if(!m._name.empty()) |
311 | modi.front()._name = yytext; | 312 | throw preprocessor_error(CODEPOINT,"syntax error",lineno()); |
312 | } | 313 | m._name = yytext; |
314 | } | ||
313 | \= { | 315 | \= { |
314 | modi.front().output.clear(); | 316 | M().output.clear(); |
315 | BEGIN(IMPORTTYPECOMPONENT); | 317 | BEGIN(IMPORTTYPECOMPONENT); |
316 | } | 318 | } |
317 | } | 319 | } |
318 | <IMPORTTYPECOMPONENT>{ | 320 | <IMPORTTYPECOMPONENT>{ |
319 | {WHITESPACE}+{ } | 321 | {WHITESPACE}+{ } |
320 | \n{ | 322 | \n{ |
321 | modus_operandi& m = M(); | 323 | modus_operandi& m = M(); |
322 | string::size_type t = m.output.find_first_not_of(" \t"); | 324 | string::size_type t = m.output.find_first_not_of(" \t"); |
323 | if(t!=string::npos) | 325 | if(t!=string::npos) |
324 | m.output.erase(0,t); | 326 | m.output.erase(0,t); |
325 | t = m.output.find_last_not_of(" \t;"); | 327 | t = m.output.find_last_not_of(" \t;"); |
326 | if(t!=string::npos) | 328 | if(t!=string::npos) |
327 | m.output.erase(t+1); | 329 | m.output.erase(t+1); |
328 | if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') { | 330 | if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') { |
329 | m.output.erase(0,1); | 331 | m.output.erase(0,1); |
330 | m.output.erase(m.output.length()-1); | 332 | m.output.erase(m.output.length()-1); |
331 | } | 333 | } |
332 | string c = combine_path(component_basename,m.output); | 334 | string c = combine_path(component_basename,m.output); |
333 | member_variables.push_back(member_variable(m._type,m._name,normalize_path(c,strip_leading_slash),true,true)); | 335 | member_variables.push_back(member_variable(m._type,m._name,normalize_path(c,strip_leading_slash),true,true)); |
334 | modi.pop_front(); | 336 | modi.pop_front(); |
335 | BEGIN(INITIAL); | 337 | BEGIN(INITIAL); |
336 | } | 338 | } |
337 | } | 339 | } |
338 | 340 | ||
339 | <DERIVELINE>{ | 341 | <DERIVELINE>{ |
340 | {WHITESPACE}+{ } | 342 | {WHITESPACE}+{ } |
341 | {ID}{ | 343 | {ID}{ |
342 | if(!modi.front()._name.empty()) | 344 | modus_operandi& m = M(); |
343 | throw preprocessor_error(CODEPOINT,"syntax_error",lineno()); | 345 | if(!m._name.empty()) |
344 | modi.front()._name = yytext; | 346 | throw preprocessor_error(CODEPOINT,"syntax_error",lineno()); |
345 | } | 347 | m._name = yytext; |
348 | } | ||
346 | \= { | 349 | \= { |
347 | modi.front().output.clear(); | 350 | M().output.clear(); |
348 | BEGIN(DERIVECOMPONENT); | 351 | BEGIN(DERIVECOMPONENT); |
349 | } | 352 | } |
350 | } | 353 | } |
351 | <DERIVECOMPONENT>{ | 354 | <DERIVECOMPONENT>{ |
352 | {WHITESPACE}+{ } | 355 | {WHITESPACE}+{ } |
353 | \n { | 356 | \n { |
354 | modus_operandi& m = M(); | 357 | modus_operandi& m = M(); |
355 | string::size_type t = m.output.find_first_not_of(" \t"); | 358 | string::size_type t = m.output.find_first_not_of(" \t"); |
356 | if(t!=string::npos) | 359 | if(t!=string::npos) |
357 | m.output.erase(0,t); | 360 | m.output.erase(0,t); |
358 | t = m.output.find_last_not_of(" \t;"); | 361 | t = m.output.find_last_not_of(" \t;"); |
359 | if(t!=string::npos) | 362 | if(t!=string::npos) |
360 | m.output.erase(t+1); | 363 | m.output.erase(t+1); |
361 | if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') { | 364 | if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') { |
362 | m.output.erase(0,1); | 365 | m.output.erase(0,1); |
363 | m.output.erase(m.output.length()-1); | 366 | m.output.erase(m.output.length()-1); |
364 | } | 367 | } |
365 | string c = combine_path(component_basename,m.output); | 368 | string c = combine_path(component_basename,m.output); |
366 | ancestor_classes.push_back(ancestor_class(m._name,normalize_path(c,strip_leading_slash))); | 369 | ancestor_classes.push_back(ancestor_class(m._name,normalize_path(c,strip_leading_slash))); |
367 | modi.pop_front(); | 370 | modi.pop_front(); |
368 | BEGIN(INITIAL); | 371 | BEGIN(INITIAL); |
369 | } | 372 | } |
370 | } | 373 | } |
371 | 374 | ||
372 | <VARLINE>{ | 375 | <VARLINE>{ |
373 | {WHITESPACE}+{ | 376 | {WHITESPACE}+{ |
374 | modus_operandi& m = modi.front(); | 377 | modus_operandi& m = M(); |
375 | if(!m.output.empty()) { | 378 | if(!m.output.empty()) { |
376 | if(!m._lastid.empty()) { | 379 | if(!m._lastid.empty()) { |
377 | if(!m._type.empty()) m._type += ' '; | 380 | if(!m._type.empty()) m._type += ' '; |
378 | m._type += m._lastid; | 381 | m._type += m._lastid; |
379 | } | 382 | } |
380 | m._lastid = m.output; | 383 | m._lastid = m.output; |
381 | m.output.clear(); | 384 | m.output.clear(); |
382 | } | 385 | } |
383 | } | 386 | } |
384 | \*{ | 387 | \*{ |
385 | modus_operandi& m = modi.front(); | 388 | modus_operandi& m = M(); |
386 | ECHO; | 389 | ECHO; |
387 | if(!m._lastid.empty()) { | 390 | if(!m._lastid.empty()) { |
388 | if(!m._type.empty()) m._type += ' '; | 391 | if(!m._type.empty()) m._type += ' '; |
389 | m._type += m._lastid; | 392 | m._type += m._lastid; |
390 | } | 393 | } |
391 | m._lastid = m.output; | 394 | m._lastid = m.output; |
392 | m.output.clear(); | 395 | m.output.clear(); |
393 | } | 396 | } |
394 | \;|\n|\={ | 397 | \;|\n|\={ |
395 | modus_operandi& m = modi.front(); | 398 | modus_operandi& m = M(); |
396 | if(m.output.empty()) { | 399 | if(m.output.empty()) { |
397 | m._name=m._lastid; | 400 | m._name=m._lastid; |
398 | }else{ | 401 | }else{ |
399 | if(!m._lastid.empty()) { // XXX: lastid should never be emtpy, I believe? | 402 | if(!m._lastid.empty()) { // XXX: lastid should never be emtpy, I believe? |
400 | if(!m._type.empty()) m._type += ' '; | 403 | if(!m._type.empty()) m._type += ' '; |
401 | m._type += m._lastid; | 404 | m._type += m._lastid; |
402 | } | 405 | } |
403 | m._name=m.output; | 406 | m._name=m.output; |
404 | m.output.clear(); | 407 | m.output.clear(); |
405 | } | 408 | } |
406 | BEGIN(VARINIT); | 409 | BEGIN(VARINIT); |
407 | if(*yytext!='=') | 410 | if(*yytext!='=') |
408 | unput('\n'); | 411 | unput('\n'); |
409 | } | 412 | } |
410 | } | 413 | } |
411 | <VARINIT>{ | 414 | <VARINIT>{ |
412 | \n{ | 415 | \n{ |
413 | modus_operandi& m = modi.front(); | 416 | modus_operandi& m = M(); |
414 | string::size_type t = m.output.find_first_not_of(" \t"); | 417 | string::size_type t = m.output.find_first_not_of(" \t"); |
415 | if(t!=string::npos) | 418 | if(t!=string::npos) |
416 | m.output.erase(0,t); | 419 | m.output.erase(0,t); |
417 | t = m.output.find_last_not_of(" \t;"); | 420 | t = m.output.find_last_not_of(" \t;"); |
418 | if(t!=string::npos) | 421 | if(t!=string::npos) |
419 | m.output.erase(t+1); | 422 | m.output.erase(t+1); |
420 | member_variables.push_back(member_variable(m._type,m._name,m.output)); | 423 | member_variables.push_back(member_variable(m._type,m._name,m.output)); |
421 | if(!m.output.empty()) | 424 | if(!m.output.empty()) |
422 | have_initializers=true; | 425 | have_initializers=true; |
423 | modi.pop_front(); | 426 | modi.pop_front(); |
424 | BEGIN(INITIAL); | 427 | BEGIN(INITIAL); |
425 | } | 428 | } |
426 | } | 429 | } |
427 | <DECLLINE>\n{ | 430 | <DECLLINE>\n{ |
428 | ECHO; | 431 | ECHO; |
429 | decl += modi.front().output; | 432 | decl += M().output; |
430 | modi.pop_front(); | 433 | modi.pop_front(); |
431 | BEGIN(INITIAL); | 434 | BEGIN(INITIAL); |
432 | } | 435 | } |
433 | <IMPLLINE>\n{ | 436 | <IMPLLINE>\n{ |
434 | ECHO; | 437 | ECHO; |
435 | impl += modi.front().output; | 438 | impl += M().output; |
436 | modi.pop_front(); | 439 | modi.pop_front(); |
437 | BEGIN(INITIAL); | 440 | BEGIN(INITIAL); |
438 | } | 441 | } |
439 | <CLASSLINE>\n{ | 442 | <CLASSLINE>\n{ |
440 | class_name = modi.front().output; | 443 | class_name = M().output; |
441 | modi.pop_front(); | 444 | modi.pop_front(); |
442 | BEGIN(INITIAL); | 445 | BEGIN(INITIAL); |
443 | } | 446 | } |
444 | <CLASSLINE,DECLLINE,IMPLLINE,VARLINE,VARINIT,IMPORTLINE,IMPORTCOMPONENT,CODEMETHODLINE,CODEMETHODARGS,INLINE,METHODLINE,METHODARGS,DECLBLOCK,IMPLBLOCK,CONSTRUCTOR,DESTRUCTOR,CODEMETHODBLOCK,CODELINE,CODEBLOCK,PRAGMALINE>{ | 447 | <CLASSLINE,DECLLINE,IMPLLINE,VARLINE,VARINIT,IMPORTLINE,IMPORTCOMPONENT,CODEMETHODLINE,CODEMETHODARGS,INLINE,METHODLINE,METHODARGS,DECLBLOCK,IMPLBLOCK,CONSTRUCTOR,DESTRUCTOR,CODEMETHODBLOCK,CODELINE,CODEBLOCK,PRAGMALINE>{ |
445 | "/*"{ | 448 | "/*"{ |
446 | yy_push_state(SLASHSTAR_COMMENT); | 449 | yy_push_state(SLASHSTAR_COMMENT); |
447 | if(!M().devour_comments()) { | 450 | if(!M().devour_comments()) { |
448 | ECHO; | 451 | ECHO; |
449 | } | 452 | } |
450 | } | 453 | } |
451 | "//"{ | 454 | "//"{ |
452 | yy_push_state(SLASHSLASH_COMMENT); | 455 | yy_push_state(SLASHSLASH_COMMENT); |
453 | if(!M().devour_comments()) { | 456 | if(!M().devour_comments()) { |
454 | ECHO; | 457 | ECHO; |
455 | } | 458 | } |
456 | } | 459 | } |
457 | \" { | 460 | \" { |
458 | yy_push_state(STRING); | 461 | yy_push_state(STRING); |
459 | ECHO; | 462 | ECHO; |
460 | } | 463 | } |
461 | \'\\.\'{ | 464 | \'\\.\'{ |
462 | ECHO; | 465 | ECHO; |
463 | } | 466 | } |
464 | } | 467 | } |
465 | 468 | ||
466 | <INITIAL,METHODBLOCK,OUTPUTBLOCK>{ | 469 | <INITIAL,METHODBLOCK,OUTPUTBLOCK>{ |
467 | \"soft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\\"",2); | 470 | \"soft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\\"",2); |
468 | \nsoft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\n",2); | 471 | \nsoft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\n",2); |
469 | \rsoft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\r",2); | 472 | \rsoft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\r",2); |
470 | \tsoft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\t",2); | 473 | \tsoft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\t",2); |
471 | \bsoft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\b",2); | 474 | \bsoft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\b",2); |
472 | \asoft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\a",2); | 475 | \asoft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\a",2); |
473 | .soft_anchor(); M().modify(modus_operandi::modus_text); ECHO; | 476 | .soft_anchor(); M().modify(modus_operandi::modus_text); ECHO; |
474 | {WHITESPACE}+soft_anchor(); M().modify(modus_operandi::modus_text); ECHO; | 477 | {WHITESPACE}+soft_anchor(); M().modify(modus_operandi::modus_text); ECHO; |
475 | } | 478 | } |
476 | 479 | ||
477 | <DECLBLOCK,IMPLBLOCK,CONSTRUCTOR,DESTRUCTOR,CODEMETHODBLOCK,METHODBLOCK,CODEBLOCK>{ | 480 | <DECLBLOCK,IMPLBLOCK,CONSTRUCTOR,DESTRUCTOR,CODEMETHODBLOCK,METHODBLOCK,CODEBLOCK>{ |
478 | \<\/\%decl\>{ | 481 | \<\/\%decl\>{ |
479 | if(YY_START!=DECLBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); | 482 | if(YY_START!=DECLBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); |
480 | decl += modi.front().output; | 483 | decl += M().output; |
481 | modi.pop_front(); | 484 | modi.pop_front(); |
482 | BEGIN(INITIAL); | 485 | BEGIN(INITIAL); |
483 | } | 486 | } |
484 | \<\/\%impl\>{ | 487 | \<\/\%impl\>{ |
485 | if(YY_START!=IMPLBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); | 488 | if(YY_START!=IMPLBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); |
486 | impl += modi.front().output; | 489 | impl += M().output; |
487 | modi.pop_front(); | 490 | modi.pop_front(); |
488 | BEGIN(INITIAL); | 491 | BEGIN(INITIAL); |
489 | } | 492 | } |
490 | \<\/\%constructor\>{ | 493 | \<\/\%constructor\>{ |
491 | if(YY_START!=CONSTRUCTOR) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); | 494 | if(YY_START!=CONSTRUCTOR) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); |
492 | member_functions.push_back(member_function("","","",modi.front().output)); | 495 | member_functions.push_back(member_function("","","",M().output)); |
493 | have_constructor = true; | 496 | have_constructor = true; |
494 | modi.pop_front(); | 497 | modi.pop_front(); |
495 | BEGIN(INITIAL); | 498 | BEGIN(INITIAL); |
496 | } | 499 | } |
497 | \<\/\%destructor\>{ | 500 | \<\/\%destructor\>{ |
498 | if(YY_START!=DESTRUCTOR) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); | 501 | if(YY_START!=DESTRUCTOR) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); |
499 | member_functions.push_back(member_function("","~","",modi.front().output)); | 502 | member_functions.push_back(member_function("","~","",M().output)); |
500 | modi.pop_front(); | 503 | modi.pop_front(); |
501 | BEGIN(INITIAL); | 504 | BEGIN(INITIAL); |
502 | } | 505 | } |
503 | \<\/\%codemethod\>{ | 506 | \<\/\%codemethod\>{ |
504 | if(YY_START!=CODEMETHODBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); | 507 | if(YY_START!=CODEMETHODBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); |
505 | modus_operandi& m = modi.front(); | 508 | modus_operandi& m = M(); |
506 | member_functions.push_back(member_function(m._type,m._name,m._args,m.output)); | 509 | member_functions.push_back(member_function(m._type,m._name,m._args,m.output)); |
507 | modi.pop_front(); | 510 | modi.pop_front(); |
508 | BEGIN(INITIAL); | 511 | BEGIN(INITIAL); |
509 | } | 512 | } |
510 | \<\/%method\> { | 513 | \<\/%method\> { |
511 | if(YY_START!=METHODBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); | 514 | if(YY_START!=METHODBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); |
512 | modus_operandi& m = modi.front(); | 515 | modus_operandi& m = M(); |
513 | m.modify(modus_operandi::modus_code); | 516 | m.modify(modus_operandi::modus_code); |
514 | member_functions.push_back(member_function(m._type,m._name,m._args,m.output)); | 517 | member_functions.push_back(member_function(m._type,m._name,m._args,m.output)); |
515 | modi.pop_front(); | 518 | modi.pop_front(); |
516 | BEGIN(INITIAL); | 519 | BEGIN(INITIAL); |
517 | } | 520 | } |
518 | \<\/%code\> { | 521 | \<\/%code\> { |
519 | if(YY_START!=CODEBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); | 522 | if(YY_START!=CODEBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno()); |
520 | yy_pop_state(); | 523 | yy_pop_state(); |
521 | } | 524 | } |
522 | \n ECHO; | 525 | \n ECHO; |
523 | } | 526 | } |
524 | 527 | ||
525 | <SLASHSTAR_COMMENT>{ | 528 | <SLASHSTAR_COMMENT>{ |
526 | "*/"{ | 529 | "*/"{ |
527 | if(!M().devour_comments()) { | 530 | if(!M().devour_comments()) { |
528 | ECHO; | 531 | ECHO; |
529 | } | 532 | } |
530 | yy_pop_state(); | 533 | yy_pop_state(); |
531 | unput(' '); | 534 | unput(' '); |
532 | } | 535 | } |
533 | \n{ | 536 | \n{ |
534 | if(!M().devour_comments()) { | 537 | if(!M().devour_comments()) { |
535 | ECHO; | 538 | ECHO; |
536 | } | 539 | } |
537 | } | 540 | } |
538 | } | 541 | } |
539 | <SLASHSLASH_COMMENT>{ | 542 | <SLASHSLASH_COMMENT>{ |
540 | \n{ | 543 | \n{ |
541 | if(!M().devour_comments()) { | 544 | if(!M().devour_comments()) { |
542 | ECHO; | 545 | ECHO; |
543 | } | 546 | } |
544 | yy_pop_state(); | 547 | yy_pop_state(); |
545 | if(YY_START!=CODEBLOCK && YY_START!=CODEMETHODBLOCK && YY_START!=IMPLBLOCK && YY_START!=DECLBLOCK) | 548 | if(YY_START!=CODEBLOCK && YY_START!=CODEMETHODBLOCK && YY_START!=IMPLBLOCK && YY_START!=DECLBLOCK) |
546 | unput('\n'); | 549 | unput('\n'); |
547 | } | 550 | } |
548 | } | 551 | } |
549 | <SLASHSTAR_COMMENT,SLASHSLASH_COMMENT>.{ | 552 | <SLASHSTAR_COMMENT,SLASHSLASH_COMMENT>.{ |
550 | if(!M().devour_comments()) { | 553 | if(!M().devour_comments()) { |
551 | ECHO; | 554 | ECHO; |
552 | } | 555 | } |
553 | } | 556 | } |
554 | <STRING>{ | 557 | <STRING>{ |
555 | \\.ECHO; | 558 | \\.ECHO; |
556 | \"ECHO; yy_pop_state(); | 559 | \"ECHO; yy_pop_state(); |
557 | .ECHO; | 560 | .ECHO; |
558 | } | 561 | } |
559 | 562 | ||
560 | {WHITESPACE}+{ | 563 | {WHITESPACE}+{ |