summaryrefslogtreecommitdiffabout
path: root/lib/sitecing_parser.ll
Unidiff
Diffstat (limited to 'lib/sitecing_parser.ll') (more/less context) (show whitespace changes)
-rw-r--r--lib/sitecing_parser.ll13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/sitecing_parser.ll b/lib/sitecing_parser.ll
index 4fd6709..8dd8d5f 100644
--- a/lib/sitecing_parser.ll
+++ b/lib/sitecing_parser.ll
@@ -1,33 +1,34 @@
1%{ 1%{
2 /* 2 /*
3 * XXX: I have a strong feeling that this parser should be completely rewritten. 3 * XXX: I have a strong feeling that this parser should be completely rewritten.
4 */ 4 */
5#include <iostream> 5#include <iostream>
6#include <fstream> 6#include <fstream>
7#include <cassert> 7#include <cassert>
8#include <stdexcept> 8#include <stdexcept>
9using namespace std; 9using namespace std;
10#include <konforka/util.h>
10#include "sitecing/sitecing_util.h" 11#include "sitecing/sitecing_util.h"
11#include "sitecing/sitecing_exception.h" 12#include "sitecing/sitecing_exception.h"
12using namespace sitecing; 13using namespace sitecing;
13#define sitecing_parser_flexlexer_once 14#define sitecing_parser_flexlexer_once
14#include "sitecing/sitecing_parser.h" 15#include "sitecing/sitecing_parser.h"
15#include "sitecing/sitecing_enflesher.h" 16#include "sitecing/sitecing_enflesher.h"
16#undef yyFlexLexer 17#undef yyFlexLexer
17#define yyFlexLexer sitecing_parserFlexLexer 18#define yyFlexLexer sitecing_parserFlexLexer
18%} 19%}
19%x SLASHSTAR_COMMENT SLASHSLASH_COMMENT STRING 20%x SLASHSTAR_COMMENT SLASHSLASH_COMMENT STRING
20%x CODELINE CLASSLINE DECLLINE IMPLLINE DECLBLOCK IMPLBLOCK VARLINE VARINIT 21%x CODELINE CLASSLINE DECLLINE IMPLLINE DECLBLOCK IMPLBLOCK VARLINE VARINIT
21%x IMPORTLINE IMPORTCOMPONENT 22%x IMPORTLINE IMPORTCOMPONENT
22%x IMPORTTYPELINE IMPORTTYPECOMPONENT 23%x IMPORTTYPELINE IMPORTTYPECOMPONENT
23%x DERIVELINE DERIVECOMPONENT 24%x DERIVELINE DERIVECOMPONENT
24%x CONSTRUCTOR DESTRUCTOR CODEMETHODLINE CODEMETHODARGS 25%x CONSTRUCTOR DESTRUCTOR CODEMETHODLINE CODEMETHODARGS
25%x CODEMETHODBLOCK INLINE METHODLINE METHODARGS METHODBLOCK CODEBLOCK OUTPUTBLOCK 26%x CODEMETHODBLOCK INLINE METHODLINE METHODARGS METHODBLOCK CODEBLOCK OUTPUTBLOCK
26%x PRAGMALINE 27%x PRAGMALINE
27%option 8bit c++ verbose noyywrap yyclass="sitecing_parser" prefix="sitecing_parser" stack yylineno 28%option 8bit c++ verbose noyywrap yyclass="sitecing_parser" prefix="sitecing_parser" stack yylineno
28 29
29 WHITESPACE[ \t] 30 WHITESPACE[ \t]
30 ID [A-Za-z_][A-Za-z0-9_]* 31 ID [A-Za-z_][A-Za-z0-9_]*
31 NOIDCHAR[^A-Za-z0-9_] 32 NOIDCHAR[^A-Za-z0-9_]
32 33
33%% 34%%
@@ -276,118 +277,118 @@ NOIDCHAR [^A-Za-z0-9_]
276 modus_operandi& m = M(); 277 modus_operandi& m = M();
277 if(!m._name.empty()) 278 if(!m._name.empty())
278 throw preprocessor_error(CODEPOINT,"syntax error",lineno()); 279 throw preprocessor_error(CODEPOINT,"syntax error",lineno());
279 m._name = yytext; 280 m._name = yytext;
280 } 281 }
281 \= { 282 \= {
282 M().output.clear(); 283 M().output.clear();
283 BEGIN(IMPORTCOMPONENT); 284 BEGIN(IMPORTCOMPONENT);
284 } 285 }
285} 286}
286<IMPORTCOMPONENT>{ 287<IMPORTCOMPONENT>{
287 {WHITESPACE}+{ } 288 {WHITESPACE}+{ }
288 \n{ 289 \n{
289 modus_operandi& m = M(); 290 modus_operandi& m = M();
290 string::size_type t = m.output.find_first_not_of(" \t"); 291 string::size_type t = m.output.find_first_not_of(" \t");
291 if(t!=string::npos) 292 if(t!=string::npos)
292 m.output.erase(0,t); 293 m.output.erase(0,t);
293 t = m.output.find_last_not_of(" \t;"); 294 t = m.output.find_last_not_of(" \t;");
294 if(t!=string::npos) 295 if(t!=string::npos)
295 m.output.erase(t+1); 296 m.output.erase(t+1);
296 if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') { 297 if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') {
297 m.output.erase(0,1); 298 m.output.erase(0,1);
298 m.output.erase(m.output.length()-1); 299 m.output.erase(m.output.length()-1);
299 } 300 }
300 string c = combine_path(component_basename,m.output); 301 string c = konforka::combine_path(component_basename,m.output);
301 member_variables.push_back(member_variable(m._type,m._name,normalize_path(c,strip_leading_slash),true)); 302 member_variables.push_back(member_variable(m._type,m._name,konforka::normalize_path(c,konforka::strip_leading_slash),true));
302 modi.pop_front(); 303 modi.pop_front();
303 BEGIN(INITIAL); 304 BEGIN(INITIAL);
304 } 305 }
305} 306}
306 307
307<IMPORTTYPELINE>{ 308<IMPORTTYPELINE>{
308 {WHITESPACE}+{ } 309 {WHITESPACE}+{ }
309 {ID}{ 310 {ID}{
310 modus_operandi& m = M(); 311 modus_operandi& m = M();
311 if(!m._name.empty()) 312 if(!m._name.empty())
312 throw preprocessor_error(CODEPOINT,"syntax error",lineno()); 313 throw preprocessor_error(CODEPOINT,"syntax error",lineno());
313 m._name = yytext; 314 m._name = yytext;
314 } 315 }
315 \= { 316 \= {
316 M().output.clear(); 317 M().output.clear();
317 BEGIN(IMPORTTYPECOMPONENT); 318 BEGIN(IMPORTTYPECOMPONENT);
318 } 319 }
319} 320}
320<IMPORTTYPECOMPONENT>{ 321<IMPORTTYPECOMPONENT>{
321 {WHITESPACE}+{ } 322 {WHITESPACE}+{ }
322 \n{ 323 \n{
323 modus_operandi& m = M(); 324 modus_operandi& m = M();
324 string::size_type t = m.output.find_first_not_of(" \t"); 325 string::size_type t = m.output.find_first_not_of(" \t");
325 if(t!=string::npos) 326 if(t!=string::npos)
326 m.output.erase(0,t); 327 m.output.erase(0,t);
327 t = m.output.find_last_not_of(" \t;"); 328 t = m.output.find_last_not_of(" \t;");
328 if(t!=string::npos) 329 if(t!=string::npos)
329 m.output.erase(t+1); 330 m.output.erase(t+1);
330 if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') { 331 if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') {
331 m.output.erase(0,1); 332 m.output.erase(0,1);
332 m.output.erase(m.output.length()-1); 333 m.output.erase(m.output.length()-1);
333 } 334 }
334 string c = combine_path(component_basename,m.output); 335 string c = konforka::combine_path(component_basename,m.output);
335 member_variables.push_back(member_variable(m._type,m._name,normalize_path(c,strip_leading_slash),true,true)); 336 member_variables.push_back(member_variable(m._type,m._name,konforka::normalize_path(c,konforka::strip_leading_slash),true,true));
336 modi.pop_front(); 337 modi.pop_front();
337 BEGIN(INITIAL); 338 BEGIN(INITIAL);
338 } 339 }
339} 340}
340 341
341<DERIVELINE>{ 342<DERIVELINE>{
342 {WHITESPACE}+{ } 343 {WHITESPACE}+{ }
343 {ID}{ 344 {ID}{
344 modus_operandi& m = M(); 345 modus_operandi& m = M();
345 if(!m._name.empty()) 346 if(!m._name.empty())
346 throw preprocessor_error(CODEPOINT,"syntax_error",lineno()); 347 throw preprocessor_error(CODEPOINT,"syntax_error",lineno());
347 m._name = yytext; 348 m._name = yytext;
348 } 349 }
349 \= { 350 \= {
350 M().output.clear(); 351 M().output.clear();
351 BEGIN(DERIVECOMPONENT); 352 BEGIN(DERIVECOMPONENT);
352 } 353 }
353} 354}
354<DERIVECOMPONENT>{ 355<DERIVECOMPONENT>{
355 {WHITESPACE}+{ } 356 {WHITESPACE}+{ }
356 \n { 357 \n {
357 modus_operandi& m = M(); 358 modus_operandi& m = M();
358 string::size_type t = m.output.find_first_not_of(" \t"); 359 string::size_type t = m.output.find_first_not_of(" \t");
359 if(t!=string::npos) 360 if(t!=string::npos)
360 m.output.erase(0,t); 361 m.output.erase(0,t);
361 t = m.output.find_last_not_of(" \t;"); 362 t = m.output.find_last_not_of(" \t;");
362 if(t!=string::npos) 363 if(t!=string::npos)
363 m.output.erase(t+1); 364 m.output.erase(t+1);
364 if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') { 365 if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') {
365 m.output.erase(0,1); 366 m.output.erase(0,1);
366 m.output.erase(m.output.length()-1); 367 m.output.erase(m.output.length()-1);
367 } 368 }
368 string c = combine_path(component_basename,m.output); 369 string c = konforka::combine_path(component_basename,m.output);
369 ancestor_classes.push_back(ancestor_class(m._name,normalize_path(c,strip_leading_slash))); 370 ancestor_classes.push_back(ancestor_class(m._name,konforka::normalize_path(c,konforka::strip_leading_slash)));
370 modi.pop_front(); 371 modi.pop_front();
371 BEGIN(INITIAL); 372 BEGIN(INITIAL);
372 } 373 }
373} 374}
374 375
375<VARLINE>{ 376<VARLINE>{
376 {WHITESPACE}+{ 377 {WHITESPACE}+{
377 modus_operandi& m = M(); 378 modus_operandi& m = M();
378 if(!m.output.empty()) { 379 if(!m.output.empty()) {
379 if(!m._lastid.empty()) { 380 if(!m._lastid.empty()) {
380 if(!m._type.empty()) m._type += ' '; 381 if(!m._type.empty()) m._type += ' ';
381 m._type += m._lastid; 382 m._type += m._lastid;
382 } 383 }
383 m._lastid = m.output; 384 m._lastid = m.output;
384 m.output.clear(); 385 m.output.clear();
385 } 386 }
386 } 387 }
387 \*{ 388 \*{
388 modus_operandi& m = M(); 389 modus_operandi& m = M();
389 ECHO; 390 ECHO;
390 if(!m._lastid.empty()) { 391 if(!m._lastid.empty()) {
391 if(!m._type.empty()) m._type += ' '; 392 if(!m._type.empty()) m._type += ' ';
392 m._type += m._lastid; 393 m._type += m._lastid;
393 } 394 }