summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--lib/sitecing_parser.ll159
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_]
<<EOF>> {
assert(modi.size()==1);
M().modify(modus_operandi::modus_preop);
LexerOutput(";",1);
return 0;
}
}
<<EOF>> throw preprocessor_error(CODEPOINT,"unexpected end of file",lineno());
<CODEBLOCK,CODEMETHODBLOCK>{
"<%output>" {
anchor();
yy_push_state(OUTPUTBLOCK);
}
}
<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>{
{WHITESPACE}+ {
- modus_operandi& m = modi.front();
- if(!m.output.empty()) {
- if(!m._lastid.empty()) {
- if(!m._type.empty()) m._type += ' ';
- m._type += m._lastid;
- }
- m._lastid = m.output;
- m.output.clear();
- }
- }
+ modus_operandi& m = M();
+ if(!m.output.empty()) {
+ if(!m._lastid.empty()) {
+ if(!m._type.empty()) m._type += ' ';
+ m._type += m._lastid;
+ }
+ m._lastid = m.output;
+ m.output.clear();
+ }
+ }
\* {
- modus_operandi& m = modi.front();
- ECHO;
- if(!m._lastid.empty()) {
- if(!m._type.empty()) m._type += ' ';
- m._type += m._lastid;
- }
- m._lastid = m.output;
- m.output.clear();
- }
+ modus_operandi& m = M();
+ ECHO;
+ if(!m._lastid.empty()) {
+ if(!m._type.empty()) m._type += ' ';
+ m._type += m._lastid;
+ }
+ m._lastid = m.output;
+ m.output.clear();
+ }
\( {
- modus_operandi& m = modi.front();
+ modus_operandi& m = M();
if(m.output.empty()) {
m._name=m._lastid;
}else{
if(!m._lastid.empty()) { // XXX: lastid, I believe should never be emtpy...
if(!m._type.empty()) m._type += ' ';
m._type += m._lastid;
}
m._name = m.output;
m.output.clear();
}
ECHO;
BEGIN(METHODARGS);
}
}
<METHODARGS>{
\%\> {
- modus_operandi& m = modi.front();
+ modus_operandi& m = M();
m._args = m.output;
m.output.clear();
anchor();
BEGIN(METHODBLOCK);
}
}
<INITIAL,METHODBLOCK,OUTPUTBLOCK>{
\<\%{WHITESPACE}+ {
M().modify(modus_operandi::modus_postop);
anchor();
LexerOutput("(",1);
yy_push_state(INLINE);
}
^\%{WHITESPACE} {
M().modify(modus_operandi::modus_code);
anchor();
yy_push_state(CODELINE);
}
\<\%code\> {
M().modify(modus_operandi::modus_code);
anchor();
yy_push_state(CODEBLOCK);
}
"</%output>" {
if(YY_START!=OUTPUTBLOCK) throw preprocessor_error(CODEPOINT,"unexpected tag",lineno());
M().modify(modus_operandi::modus_code);
anchor();
yy_pop_state();
}
}
<INLINE>\%\> LexerOutput(")",1); M().modus=modus_operandi::modus_preop; yy_pop_state();
<CODELINE>\n yy_pop_state();
<CODEMETHODLINE>{
{WHITESPACE}+ {
- modus_operandi& m = modi.front();
- if(!m.output.empty()) {
- if(!m._lastid.empty()) {
- if(!m._type.empty()) m._type += ' ';
- m._type += m._lastid;
- }
- m._lastid = m.output;
- m.output.clear();
- }
- }
+ modus_operandi& m = M();
+ if(!m.output.empty()) {
+ if(!m._lastid.empty()) {
+ if(!m._type.empty()) m._type += ' ';
+ m._type += m._lastid;
+ }
+ m._lastid = m.output;
+ m.output.clear();
+ }
+ }
\* {
- modus_operandi& m = modi.front();
- ECHO;
- if(!m._lastid.empty()) {
- if(!m._type.empty()) m._type += ' ';
- m._type += m._lastid;
- }
- m._lastid = m.output;
- m.output.clear();
- }
+ modus_operandi& m = M();
+ ECHO;
+ if(!m._lastid.empty()) {
+ if(!m._type.empty()) m._type += ' ';
+ m._type += m._lastid;
+ }
+ m._lastid = m.output;
+ m.output.clear();
+ }
\( {
- modus_operandi& m = modi.front();
+ modus_operandi& m = M();
if(m.output.empty()) {
m._name=m._lastid;
}else{
if(!m._lastid.empty()) { // XXX: lastid, I believe should never be emtpy...
if(!m._type.empty()) m._type += ' ';
m._type += m._lastid;
}
m._name = m.output;
m.output.clear();
}
ECHO;
BEGIN(CODEMETHODARGS);
}
}
<CODEMETHODARGS>{
\%\> {
- modus_operandi& m = modi.front();
+ modus_operandi& m = M();
m._args = m.output;
m.output.clear();
m.flags=0;
anchor();
BEGIN(CODEMETHODBLOCK);
}
}
<IMPORTLINE>{
{WHITESPACE}+ { }
{ID} {
- if(!modi.front()._name.empty())
- throw preprocessor_error(CODEPOINT,"syntax error",lineno());
- modi.front()._name = yytext;
- }
+ modus_operandi& m = M();
+ if(!m._name.empty())
+ throw preprocessor_error(CODEPOINT,"syntax error",lineno());
+ m._name = yytext;
+ }
\= {
- modi.front().output.clear();
+ M().output.clear();
BEGIN(IMPORTCOMPONENT);
}
}
<IMPORTCOMPONENT>{
{WHITESPACE}+ { }
\n {
modus_operandi& m = M();
string::size_type t = m.output.find_first_not_of(" \t");
if(t!=string::npos)
m.output.erase(0,t);
t = m.output.find_last_not_of(" \t;");
if(t!=string::npos)
m.output.erase(t+1);
if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') {
m.output.erase(0,1);
m.output.erase(m.output.length()-1);
}
string c = combine_path(component_basename,m.output);
member_variables.push_back(member_variable(m._type,m._name,normalize_path(c,strip_leading_slash),true));
modi.pop_front();
BEGIN(INITIAL);
}
}
<IMPORTTYPELINE>{
{WHITESPACE}+ { }
{ID} {
- if(!modi.front()._name.empty())
- throw preprocessor_error(CODEPOINT,"syntax error",lineno());
- modi.front()._name = yytext;
- }
+ modus_operandi& m = M();
+ if(!m._name.empty())
+ throw preprocessor_error(CODEPOINT,"syntax error",lineno());
+ m._name = yytext;
+ }
\= {
- modi.front().output.clear();
+ M().output.clear();
BEGIN(IMPORTTYPECOMPONENT);
}
}
<IMPORTTYPECOMPONENT>{
{WHITESPACE}+ { }
\n {
modus_operandi& m = M();
string::size_type t = m.output.find_first_not_of(" \t");
if(t!=string::npos)
m.output.erase(0,t);
t = m.output.find_last_not_of(" \t;");
if(t!=string::npos)
m.output.erase(t+1);
if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') {
m.output.erase(0,1);
m.output.erase(m.output.length()-1);
}
string c = combine_path(component_basename,m.output);
member_variables.push_back(member_variable(m._type,m._name,normalize_path(c,strip_leading_slash),true,true));
modi.pop_front();
BEGIN(INITIAL);
}
}
<DERIVELINE>{
{WHITESPACE}+ { }
{ID} {
- if(!modi.front()._name.empty())
- throw preprocessor_error(CODEPOINT,"syntax_error",lineno());
- modi.front()._name = yytext;
- }
+ modus_operandi& m = M();
+ if(!m._name.empty())
+ throw preprocessor_error(CODEPOINT,"syntax_error",lineno());
+ m._name = yytext;
+ }
\= {
- modi.front().output.clear();
+ M().output.clear();
BEGIN(DERIVECOMPONENT);
}
}
<DERIVECOMPONENT>{
{WHITESPACE}+ { }
\n {
modus_operandi& m = M();
string::size_type t = m.output.find_first_not_of(" \t");
if(t!=string::npos)
m.output.erase(0,t);
t = m.output.find_last_not_of(" \t;");
if(t!=string::npos)
m.output.erase(t+1);
if(m.output[0]=='"' && m.output[m.output.length()-1]=='"') {
m.output.erase(0,1);
m.output.erase(m.output.length()-1);
}
string c = combine_path(component_basename,m.output);
ancestor_classes.push_back(ancestor_class(m._name,normalize_path(c,strip_leading_slash)));
modi.pop_front();
BEGIN(INITIAL);
}
}
<VARLINE>{
{WHITESPACE}+ {
- modus_operandi& m = modi.front();
+ modus_operandi& m = M();
if(!m.output.empty()) {
if(!m._lastid.empty()) {
if(!m._type.empty()) m._type += ' ';
m._type += m._lastid;
}
m._lastid = m.output;
m.output.clear();
}
}
\* {
- modus_operandi& m = modi.front();
- ECHO;
- if(!m._lastid.empty()) {
- if(!m._type.empty()) m._type += ' ';
- m._type += m._lastid;
- }
- m._lastid = m.output;
- m.output.clear();
- }
+ modus_operandi& m = M();
+ ECHO;
+ if(!m._lastid.empty()) {
+ if(!m._type.empty()) m._type += ' ';
+ m._type += m._lastid;
+ }
+ m._lastid = m.output;
+ m.output.clear();
+ }
\;|\n|\= {
- modus_operandi& m = modi.front();
+ modus_operandi& m = M();
if(m.output.empty()) {
m._name=m._lastid;
}else{
if(!m._lastid.empty()) { // XXX: lastid should never be emtpy, I believe?
if(!m._type.empty()) m._type += ' ';
m._type += m._lastid;
}
m._name=m.output;
m.output.clear();
}
BEGIN(VARINIT);
if(*yytext!='=')
unput('\n');
}
}
<VARINIT>{
\n {
- modus_operandi& m = modi.front();
+ modus_operandi& m = M();
string::size_type t = m.output.find_first_not_of(" \t");
if(t!=string::npos)
m.output.erase(0,t);
t = m.output.find_last_not_of(" \t;");
if(t!=string::npos)
m.output.erase(t+1);
member_variables.push_back(member_variable(m._type,m._name,m.output));
if(!m.output.empty())
have_initializers=true;
modi.pop_front();
BEGIN(INITIAL);
}
}
<DECLLINE>\n {
ECHO;
- decl += modi.front().output;
+ decl += M().output;
modi.pop_front();
BEGIN(INITIAL);
}
<IMPLLINE>\n {
ECHO;
- impl += modi.front().output;
+ impl += M().output;
modi.pop_front();
BEGIN(INITIAL);
}
<CLASSLINE>\n {
- class_name = modi.front().output;
+ class_name = M().output;
modi.pop_front();
BEGIN(INITIAL);
}
<CLASSLINE,DECLLINE,IMPLLINE,VARLINE,VARINIT,IMPORTLINE,IMPORTCOMPONENT,CODEMETHODLINE,CODEMETHODARGS,INLINE,METHODLINE,METHODARGS,DECLBLOCK,IMPLBLOCK,CONSTRUCTOR,DESTRUCTOR,CODEMETHODBLOCK,CODELINE,CODEBLOCK,PRAGMALINE>{
"/*" {
yy_push_state(SLASHSTAR_COMMENT);
if(!M().devour_comments()) {
ECHO;
}
}
"//" {
yy_push_state(SLASHSLASH_COMMENT);
if(!M().devour_comments()) {
ECHO;
}
}
\" {
yy_push_state(STRING);
ECHO;
}
\'\\.\' {
ECHO;
}
}
<INITIAL,METHODBLOCK,OUTPUTBLOCK>{
\" soft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\\"",2);
\n soft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\n",2);
\r soft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\r",2);
\t soft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\t",2);
\b soft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\b",2);
\a soft_anchor(); M().modify(modus_operandi::modus_text); LexerOutput("\\a",2);
. soft_anchor(); M().modify(modus_operandi::modus_text); ECHO;
{WHITESPACE}+ soft_anchor(); M().modify(modus_operandi::modus_text); ECHO;
}
<DECLBLOCK,IMPLBLOCK,CONSTRUCTOR,DESTRUCTOR,CODEMETHODBLOCK,METHODBLOCK,CODEBLOCK>{
\<\/\%decl\> {
if(YY_START!=DECLBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno());
- decl += modi.front().output;
+ decl += M().output;
modi.pop_front();
BEGIN(INITIAL);
}
\<\/\%impl\> {
if(YY_START!=IMPLBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno());
- impl += modi.front().output;
+ impl += M().output;
modi.pop_front();
BEGIN(INITIAL);
}
\<\/\%constructor\> {
if(YY_START!=CONSTRUCTOR) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno());
- member_functions.push_back(member_function("","","",modi.front().output));
+ member_functions.push_back(member_function("","","",M().output));
have_constructor = true;
modi.pop_front();
BEGIN(INITIAL);
}
\<\/\%destructor\> {
if(YY_START!=DESTRUCTOR) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno());
- member_functions.push_back(member_function("","~","",modi.front().output));
+ member_functions.push_back(member_function("","~","",M().output));
modi.pop_front();
BEGIN(INITIAL);
}
\<\/\%codemethod\> {
if(YY_START!=CODEMETHODBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno());
- modus_operandi& m = modi.front();
+ modus_operandi& m = M();
member_functions.push_back(member_function(m._type,m._name,m._args,m.output));
modi.pop_front();
BEGIN(INITIAL);
}
\<\/%method\> {
if(YY_START!=METHODBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno());
- modus_operandi& m = modi.front();
+ modus_operandi& m = M();
m.modify(modus_operandi::modus_code);
member_functions.push_back(member_function(m._type,m._name,m._args,m.output));
modi.pop_front();
BEGIN(INITIAL);
}
\<\/%code\> {
if(YY_START!=CODEBLOCK) throw preprocessor_error(CODEPOINT,"tags mismatch",lineno());
yy_pop_state();
}
\n ECHO;
}
<SLASHSTAR_COMMENT>{
"*/" {
if(!M().devour_comments()) {
ECHO;
}
yy_pop_state();
unput(' ');
}
\n {
if(!M().devour_comments()) {
ECHO;
}
}
}
<SLASHSLASH_COMMENT>{
\n {
if(!M().devour_comments()) {
ECHO;
}
yy_pop_state();
if(YY_START!=CODEBLOCK && YY_START!=CODEMETHODBLOCK && YY_START!=IMPLBLOCK && YY_START!=DECLBLOCK)
unput('\n');
}
}
<SLASHSTAR_COMMENT,SLASHSLASH_COMMENT>. {
if(!M().devour_comments()) {
ECHO;
}
}
<STRING>{
\\. ECHO;
\" ECHO; yy_pop_state();
. ECHO;
}
{WHITESPACE}+ {