summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2005-03-30 21:58:44 (UTC)
committer Michael Krelin <hacker@klever.net>2005-03-30 21:58:44 (UTC)
commit5c757590c7561f6d85b3f9011aa0695c4111b379 (patch) (side-by-side diff)
treee0bf20ca58b3e7bd9cc4eda54db5674ba1d71db0
parent3ddbfeafde93d1aab16a710498d86eef4e787406 (diff)
downloadsitecing-5c757590c7561f6d85b3f9011aa0695c4111b379.zip
sitecing-5c757590c7561f6d85b3f9011aa0695c4111b379.tar.gz
sitecing-5c757590c7561f6d85b3f9011aa0695c4111b379.tar.bz2
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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--include/sitecing/sitecing_enflesher.h9
-rw-r--r--include/sitecing/sitecing_parser.h8
-rw-r--r--lib/component_factory.cc2
-rw-r--r--lib/sitecing_enflesher.ll8
-rw-r--r--lib/sitecing_parser.ll49
5 files changed, 72 insertions, 4 deletions
diff --git a/include/sitecing/sitecing_enflesher.h b/include/sitecing/sitecing_enflesher.h
index 8bc43a0..db15bc3 100644
--- a/include/sitecing/sitecing_enflesher.h
+++ b/include/sitecing/sitecing_enflesher.h
@@ -74,4 +74,13 @@ class sitecing_enflesher : public sitecing_enflesherFlexLexer {
* @see outs_filename
+ * @see outs_close
*/
void outs_open(const string& nfile);
+ /**
+ * Close previously opened output stream, and rename to the 'correct'
+ * destination filename, if needed.
+ * @see outs_open
+ * @see outs
+ * @see outs_filename
+ */
+ void outs_close();
};
diff --git a/include/sitecing/sitecing_parser.h b/include/sitecing/sitecing_parser.h
index 22d716f..a8474f3 100644
--- a/include/sitecing/sitecing_parser.h
+++ b/include/sitecing/sitecing_parser.h
@@ -293,2 +293,10 @@ class sitecing_parser : public sitecing_parserFlexLexer {
component_factory& factory;
+ /**
+ * Pragma map type.
+ */
+ typedef map<string,string> pragmas_t;
+ /**
+ * Pragma's found in the component.
+ */
+ pragmas_t pragmas;
diff --git a/lib/component_factory.cc b/lib/component_factory.cc
index b8f5a16..1253111 100644
--- a/lib/component_factory.cc
+++ b/lib/component_factory.cc
@@ -321,3 +321,3 @@ namespace sitecing {
if(!ifs.good())
- throw konforka::exception(CODEPOINT,"filed to access component .ancestors");
+ throw konforka::exception(CODEPOINT,string("failed to access component '")+component+"' .ancestors");
rv.clear();
diff --git a/lib/sitecing_enflesher.ll b/lib/sitecing_enflesher.ll
index 46489c7..bb667be 100644
--- a/lib/sitecing_enflesher.ll
+++ b/lib/sitecing_enflesher.ll
@@ -181,2 +181,3 @@ void sitecing_enflesher::enflesh() {
yylex();
+ outs_close();
}
@@ -190,3 +191,3 @@ void sitecing_enflesher::anchor() {
-void sitecing_enflesher::outs_open(const string& nfile) {
+void sitecing_enflesher::outs_close() {
if(!outs_filename.empty()) {
@@ -246,2 +247,7 @@ void sitecing_enflesher::outs_open(const string& nfile) {
}
+ outs_filename.erase();
+}
+
+void sitecing_enflesher::outs_open(const string& nfile) {
+ outs_close();
outs_filename = nfile;
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
@@ -25,2 +25,3 @@ using namespace sitecing;
%x CODEMETHODBLOCK INLINE METHODLINE METHODARGS METHODBLOCK CODEBLOCK OUTPUTBLOCK
+%x PRAGMALINE
%option 8bit c++ verbose noyywrap yyclass="sitecing_parser" prefix="sitecing_parser" stack yylineno
@@ -96,2 +97,6 @@ NOIDCHAR [^A-Za-z0-9_]
}
+ ^\%\%pragma{WHITESPACE}+ {
+ modi.push_front(modus_operandi(modus_operandi::flag_devour_comments));
+ BEGIN(PRAGMALINE);
+ }
<<EOF>> {
@@ -112,2 +117,32 @@ NOIDCHAR [^A-Za-z0-9_]
+<PRAGMALINE>{
+ {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();
+ }
+}
+
<METHODLINE>{
@@ -408,3 +443,3 @@ NOIDCHAR [^A-Za-z0-9_]
}
-<CLASSLINE,DECLLINE,IMPLLINE,VARLINE,VARINIT,IMPORTLINE,IMPORTCOMPONENT,CODEMETHODLINE,CODEMETHODARGS,INLINE,METHODLINE,METHODARGS,DECLBLOCK,IMPLBLOCK,CONSTRUCTOR,DESTRUCTOR,CODEMETHODBLOCK,CODELINE,CODEBLOCK>{
+<CLASSLINE,DECLLINE,IMPLLINE,VARLINE,VARINIT,IMPORTLINE,IMPORTCOMPONENT,CODEMETHODLINE,CODEMETHODARGS,INLINE,METHODLINE,METHODARGS,DECLBLOCK,IMPLBLOCK,CONSTRUCTOR,DESTRUCTOR,CODEMETHODBLOCK,CODELINE,CODEBLOCK,PRAGMALINE>{
"/*" {
@@ -548,3 +583,13 @@ void sitecing_parser::preprocess(const string& in) {
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)