From 5c757590c7561f6d85b3f9011aa0695c4111b379 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Wed, 30 Mar 2005 21:58:44 +0000 Subject: 1. fixed a bug just introduced, preventing the last skeleton-generated file from being written. 2. introduced pragma directive and pragma main=class 3. minor changes of no importance --- (limited to 'lib/sitecing_parser.ll') diff --git a/lib/sitecing_parser.ll b/lib/sitecing_parser.ll index 6cb78f3..8ba8673 100644 --- a/lib/sitecing_parser.ll +++ b/lib/sitecing_parser.ll @@ -23,6 +23,7 @@ using namespace sitecing; %x DERIVELINE DERIVECOMPONENT %x CONSTRUCTOR DESTRUCTOR CODEMETHODLINE CODEMETHODARGS %x CODEMETHODBLOCK INLINE METHODLINE METHODARGS METHODBLOCK CODEBLOCK OUTPUTBLOCK +%x PRAGMALINE %option 8bit c++ verbose noyywrap yyclass="sitecing_parser" prefix="sitecing_parser" stack yylineno WHITESPACE [ \t] @@ -94,6 +95,10 @@ NOIDCHAR [^A-Za-z0-9_] anchor(); BEGIN(METHODLINE); } + ^\%\%pragma{WHITESPACE}+ { + modi.push_front(modus_operandi(modus_operandi::flag_devour_comments)); + BEGIN(PRAGMALINE); + } <> { assert(modi.size()==1); M().modify(modus_operandi::modus_preop); @@ -110,6 +115,36 @@ NOIDCHAR [^A-Za-z0-9_] } } +{ + {WHITESPACE}+ { + modus_operandi& m = M(); + if(!m.output.empty()) { + string::size_type eq = m.output.find('='); + if(eq==string::npos) { + pragmas[m.output]=m.output; + }else{ + pragmas[m.output.substr(0,eq)] = m.output.substr(eq+1); + } + m.output.erase(); + } + } + \n { + modus_operandi& m = M(); + if(!m.output.empty()) { + string::size_type eq = m.output.find('='); + if(eq==string::npos) { + pragmas[m.output]=m.output; + }else{ + pragmas[m.output.substr(0,eq)] = m.output.substr(eq+1); + } + m.output.erase(); + } + modi.pop_front(); + BEGIN(INITIAL); + anchor(); + } +} + { {WHITESPACE}+ { modus_operandi& m = modi.front(); @@ -406,7 +441,7 @@ NOIDCHAR [^A-Za-z0-9_] modi.pop_front(); BEGIN(INITIAL); } -{ +{ "/*" { yy_push_state(SLASHSTAR_COMMENT); if(!M().devour_comments()) { @@ -546,7 +581,17 @@ void sitecing_parser::preprocess(const string& in) { switch_streams(&ifs,NULL); if(yylex()) throw preprocessor_error(CODEPOINT,"unknown error"); - member_functions.push_back(member_function("void","main","(int _magic,va_list _args)",M().output)); + pragmas_t::const_iterator mp = pragmas.find("main"); + if(mp==pragmas.end()) { + member_functions.push_back(member_function("void","main","(int _magic,va_list _args)",M().output)); + }else{ + member_functions.push_back( + member_function( + "void","main","(int _magic,va_list _args)", + mp->second+"::main(_magic,_args);" + ) + ); + } if(have_initializers && !have_constructor) member_functions.push_back(member_function("","","","")); sitecing_enflesher enflesher(*this); -- cgit v0.9.0.2