CVersionInfoür·Dr. Detlef Meyer-EltzP©úÀParsergenerator and Interpreter1.4.1.0 Tetra.exe+Copyright © 2002 - 08 Dr. Detlef Meyer-Eltz Tetra.exeTextTransformer1.4.1.0BSEOLCTokenüдBSEOL\\\s*CHARCToken¬k´CHAR@L?'(\\([abfnrtv"'\\?]|[0-7]([0-7][0-7]?)?|x[[:xdigit:]]+)|[^'])' DECIMALINTCTokentÓ´ DECIMALINT \d+[fFlL]*DEFINEDCTokenTñ·DEFINED>assert preference before MACRO_CALL_BEGIN with two parenthesis(defined)(\s*)\(EOLCTokenò·EOL\r?\nFLOATCTokenÜò·FLOATa\d+\.\d*[eE][+-]?\d+[fFdD]? \ |\.\d+[eE][+-]?\d+[fFdD]? \ |\d+[eE][+-]?\d+[fFdD]? \ |\d+[fFdD]HEXADECIMALINTCToken»HEXADECIMALINT"0[xX][[:xdigit:]]+(u|ul|U|UL|l|L)?IDCTokenÔ»ID\w+ IGNORE_CPPCToken¨» IGNORE_CPP¡([ \t] \// spaces, but not line break |/( \// begin of a comment /[^\r\n]*$ \// line comment |\*[^*]*\*+([^/*][^*]*\*+)*/ \// block comment ) \ )+ LINE_COMMENTCTokenÌ» LINE_COMMENT //[^\r\n]*$MACRO_CALL_BEGINCToken »MACRO_CALL_BEGIN may be blank before parenthesis! (\w+)\s*\(MACRO_DEF_BEGINCTokent»MACRO_DEF_BEGINno blank before parenthesis!(\w+)\(NOT_OTHER_PP_TOKEN_CHARCTokenH»NOT_OTHER_PP_TOKEN_CHAR')' als literale Alternative[^ \\\r\n\t\)|&%?:#]NUMBERCToken»NUMBER\d+OCTADECIMALLINTCTokenð»OCTADECIMALLINT0[0-7]+(u|ul|U|UL|l|L)? PD_DEFINECTokenÄ» PD_DEFINE #\s*definePD_DEFINE_SIMPLECToken˜ »PD_DEFINE_SIMPLE%#\s*define\s+([^\r\n\t ]+)[ \t]*\r?\nPD_ELIFCTokenl »PD_ELIF#\s*elifPD_ELSECToken@ »PD_ELSE#\s*elsePD_ENDIFCToken »PD_ENDIF #\s*endifPD_ERRORCTokenè »PD_ERROR #\s*errorPD_IFCToken¼ »PD_IF#\s*ifPD_IFDEFCToken»PD_IFDEF #\s*ifdef\s+ PD_IFNDEFCTokend» PD_IFNDEF #\s*ifndef PD_INCLUDECToken8» PD_INCLUDE##\s*include\s*("([^"]+)"|<([^>]+)>)PD_LINECToken »PD_LINE#\s*line PD_PRAGMACTokenà» PD_PRAGMA #\s*pragmaPD_UNDEFCToken´»PD_UNDEF #\s*undef PD_WARNINGCTokenˆ» PD_WARNING #\s*warningSTRINGCToken\»STRING"L?"([^"\\\r\n]*(\\.[^"\\\r\n]*)*)"UNSIGNEDCToken0»UNSIGNED (\d+)[uU]*:add_exprCProduction_LINK4»add_exprümultiply_expr[xiIsDefined] ( {{int iIsDefined;}} ( "+" multiply_expr[iIsDefined] {{xiIsDefined = xiIsDefined + iIsDefined; }} | "-" multiply_expr[iIsDefined] {{xiIsDefined = xiIsDefined - iIsDefined; }} ) )* int& xiIsDefined IGNORE_CPPand_exprCProduction_LINKl»and_expr•equality_expr[xiIsDefined] ( {{int iIsDefined;}} "&" equality_expr[iIsDefined] {{xiIsDefined = xiIsDefined & iIsDefined; }} )* int& xiIsDefined IGNORE_CPP block_commentCProduction_LINKÔ» block_comment"/*" SKIP* "*/" \t\n\r CommentcommentCProduction_LINKè»comment\( ( block_comment | LINE_COMMENT //line_comment ) {{out << " "; }} )+ Þ`\t\n\r CommentconstantCProduction_LINKü!»constant´( CHAR | DECIMALINT | HEXADECIMALINT | OCTADECIMALLINT | FLOAT ) {{ xiIsDefined = xState.itg(); }} int& xiIsDefined const_exprCProduction_LINK¤%» const_exprg log_or_expr[xiIsDefined] ( "?" const_expr[xiIsDefined] ":" const_expr[xiIsDefined] )? int& xiIsDefined control_lineCProduction_LINK¬:» control_lineX definition | undef_line | pragma_line | error_line | warning_line | line_line cpp_operatorCProduction_LINK°<» cpp_operator  ":" | "?" | "->" | "{" | "}" | "[" | "]" | "*" | "==" | "!=" | "<=" | "<" | ">=" | ">" | "/" | "++" | "--" | "%" | ">>" | "<<" | "&&" | "||" | "&" | "^" | "." | "->*" | ".*" | "::" | "|" | "+" | "-" | "~" | "=" | "*=" | "/=" | "%=" | "+=" | "-=" | ">>=" | "<<=" | "&=" | "^=" | "|=" | "!" | "..."  definitionCProduction_LINK Fê definitionfPD_DEFINE ( object_like_macro | function_like_macro ) IGNORABLEelif_begin_lineCProduction_LINK4Hêelif_begin_line#PD_ELIF const_expr[xiIsDefined] int& xiIsDefined elif_sectionCProduction_LINKdJê elif_section°{{ int iIsDefined = xiIsDefined; }} elif_begin_line[iIsDefined] groups[xbPrint, xiIsDefined && iIsDefined, xiLevel] if_end[xbPrint, xiIsDefined && !iIsDefined, xiLevel] *bool xbPrint, int xiIsDefined, int xiLevelelse_begin_lineCProduction_LINKNêelse_begin_line5PD_ELSE pp_tokens[xbPrint && xiIsDefined]? bool xbPrint, int xiIsDefined else_sectionCProduction_LINK4Pê else_sectionZelse_begin_line[xbPrint, xiIsDefined] groups[xbPrint, xiIsDefined, xiLevel] PD_ENDIF +bool xbPrint, bool xiIsDefined, int xiLevel equality_exprCProduction_LINKdRê equality_expr relational_expr[xiIsDefined] ( {{int iIsDefined;}} ( "==" relational_expr[iIsDefined] {{xiIsDefined = xiIsDefined == iIsDefined; }} | "!=" relational_expr[iIsDefined] {{xiIsDefined = xiIsDefined != iIsDefined; }} ) )* int& xiIsDefined IGNORE_CPP error_lineCProduction_LINK´Vê error_lineMPD_ERROR pp_tokens[false]? EOL {{ throw CTT_Error(xState.lp_copy()); }} exclusive_or_exprCProduction_LINKÈXêexclusive_or_expr‹and_expr[xiIsDefined] ( {{int iIsDefined;}} "^" and_expr[iIsDefined] {{xiIsDefined = xiIsDefined ^ iIsDefined; }} )* int& xiIsDefined IGNORE_CPPfunction_like_macroCProduction_LINK\êfunction_like_macroL{{ node nPattern; mstrstr mDef; int iCount = 0; bool bIncludeGap = false; str s; }} MACRO_DEF_BEGIN {{ nPattern.setLabel(xState.str(1)); //log << "macro: " << xState.str(1) << endl; }} ( macro_token {{ mDef.add(xState.str(), itos(iCount++)); }} ( "," macro_token {{ mDef.add(xState.str(), itos(iCount++)); }} )* )? ")" ( ( macro_token | ")" | "(" // in IF macro kann "(" als Anfänger erkannt werden // can begin with the name of an argument (see conditionparser.cpp) | MACRO_CALL_BEGIN ) {{ if(mDef.findKey(xState.str())) { if(bIncludeGap) nPattern.add("gap", xState.str(-1)); nPattern.add(xState.str(), mDef.value()); } else { if(bIncludeGap) nPattern.add("Text", xState.copy()); else nPattern.add("Text", xState.str()); } bIncludeGap = true; }} | "#" {{ nPattern.add("#", xState.str(-1)); bIncludeGap = false; }} | "##" {{ nPattern.add("##", "##"); bIncludeGap = false; }} | BSEOL )* EOL {{ if(m_Makros.findKey(nPattern.label())) { AddWarning(nPattern.label() + " found again"); log << nPattern.label() << " found again" << endl; } nPattern.setAttrib("arguments", itos(iCount)); m_Makros[nPattern.label()] = nPattern; }} IGNORE_CPPgroupCProduction_LINKÔhêgroup¦ if_section[xbPrint, xiLevel] | control_line | include_line[xbPrint, xiLevel] | pp_tokens[xbPrint] | EOL {{ if( xbPrint ) out << xState.copy(); }} bool xbPrint, int xiLevelgroupsCProduction_LINK°kêgroupsPIF(xiIsDefined) group[xbPrint, xiLevel]* ELSE EOL skip_group END *bool xbPrint, int xiIsDefined, int xiLevel IGNORE_CPPheaderCProduction_LINKàmêheader# outer_group[xbPrint, xiLevel] bool xbPrint, int xiLevel IGNORE_CPP ifdef_lineCProduction_LINK@ê ifdef_lineW PD_IFDEF ID {{ xiIsDefined = xiIsDefined && IsDefined(State, State.str()); }} int& xiIsDefined ifndef_lineCProduction_LINK,^ê ifndef_lineZ PD_IFNDEF ID {{ xiIsDefined = xiIsDefined && !IsDefined(State, State.str()); }} int& xiIsDefinedif_beginCProduction_LINK0`êif_beginS ifdef_line[xiIsDefined] | if_line[xiIsDefined] | ifndef_line[xiIsDefined] int& xiIsDefinedif_endCProduction_LINKpêif_endm elif_section[xbPrint, xbIsDefined, xiLevel] | else_section[xbPrint, xbIsDefined, xiLevel] | PD_ENDIF +bool xbPrint, bool xbIsDefined, int xiLevelif_lineCProduction_LINKrêif_line%PD_IF const_expr[xiIsDefined] int& xiIsDefined if_sectionCProduction_LINKhˆê if_section…{{ int iIsDefined = true; }} if_begin[iIsDefined] groups[xbPrint, iIsDefined, xiLevel] if_end[xbPrint, !iIsDefined, xiLevel] bool xbPrint, int xiLevel IncludePathsCProduction_LINK$‹ê IncludePaths[( SKIP {{ m_vIncludeDirs.push_back(trim_copy(xState.str())); }} ( EOL | EOF ) )* ßà include_lineCProduction_LINK8ê include_lineìPD_INCLUDE {{ if(scan_include_file(xiLevel)) { // include really if(xbPrint) out << xState.str(-1); } else { if(xbPrint) out << xState.copy(); } }} EOL {{ if(xbPrint) out << xState.copy(); }} bool xbPrint, int xiLevelinclusive_or_exprCProduction_LINKP‘êinclusive_or_exprœexclusive_or_expr[xiIsDefined] ( {{int iIsDefined;}} "|" exclusive_or_expr[iIsDefined] {{xiIsDefined = xiIsDefined | iIsDefined; }} )* int& xiIsDefined IGNORE_CPP line_commentCProduction_LINKÈ”ê line_comment"//" SKIP? ( EOL | EOF ) line_lineCProduction_LINK—ê line_line! PD_LINE pp_tokens[false]? EOL log_and_exprCProduction_LINK€™ê log_and_exprŸinclusive_or_expr[xiIsDefined] ( {{int iIsDefined;}} "&&" inclusive_or_expr[iIsDefined] {{xiIsDefined = xiIsDefined && iIsDefined; }} )* int& xiIsDefined log_or_exprCProduction_LINK¨œê log_or_exprŒlog_and_expr[xiIsDefined] ( {{int iIsDefined;}} "||" log_and_expr[iIsDefined] {{xiIsDefined = xiIsDefined || iIsDefined; }} )* int& xiIsDefined macro_callCProduction_LINKT ê macro_call {{ node nMacroDef; mstrstr m; vstr v; int iCount = 0, iCommas = 0; str s; bool bUsed = false; xs = xState.str(-1); }} // e.g.: va_arg(pointer,mode) {{ if(m_Makros.findKey(xState.str(1))) // prevent cycle { nMacroDef = m_Makros.value(); // e.g.: #define va_arg(list, mode) ((mode *)(list = (char *)list + sizeof (mode)))[-1] bUsed = nMacroDef.id(); nMacroDef.setId(1); } if(bUsed) xs += xState.copy(); }} macro_tokens[s] // 1. parameter e.g. pointer {{ if(bUsed) xs += s; else m.add(itos(iCount++), s); // e.g. m[0] = "mode" s = ""; }} ( "," {{ if(bUsed) xs += xState.copy(); }} macro_tokens[s] // next parameter e.g. numbers {{ iCommas++; if(bUsed) xs += s; else m.add(itos(iCount++), s); // e.g. m[1] = "numbers" s = ""; }} )* ")" {{ if(bUsed) { xs += xState.copy(); return; } int iArguments = stoi(nMacroDef.attrib("arguments")); if(iArguments != iCommas + 1 && !(iArguments == 0 && iCommas == 0)) if(iArguments < iCommas + 1) xsErrorMsg = str(" // macro \"") + nMacroDef.label() + "\" passed " + itos(iCommas + 1) + " arguments, but takes just " + nMacroDef.attrib("arguments"); else xsErrorMsg = str(" // macro \"") + nMacroDef.label() + "\" requires " + nMacroDef.attrib("arguments") + " arguments, but only " + itos(iCommas + 1) + " given"; node nPos = nMacroDef.firstChild(); while(nPos != node::npos) { if(nPos.label() == "##") { nPos = nPos.nextSibling(); v.reset(); v.gotoPrev(); if(v.isValid()) { if(m.findKey(nPos.value())) v.setValue(v.value() + m.value()); else v.setValue(v.value() + nPos.value()); //log << "## " << v.value() << endl; //log << "## " << nPos.value() << endl; } else throw CTT_Error("macro may not begin with ##"); } else if(nPos.label() == "#") { v.push_back(nPos.value()); // gap nPos = nPos.nextSibling(); if(m.findKey(nPos.value())) v.push_back( MakeString(m.value())); else v.push_back( MakeString(nPos.value())); } else { if(m.findKey(nPos.value()) && nPos.label() != "Text") // e.g. m.findKey(0) { v.push_back( m.value()); // keine Ersetzung nach ## // e.g. v.push_back("pointer") } else { v.push_back( nPos.value()); // e.g. v.push_back("= (char *)") } } nPos = nPos.nextSibling(); } }} {{ vstr::cursor cr = v.getCursor(); cr.reset(); while(cr.gotoNext()) { xs += RePreproc(cr.value()); } nMacroDef.setId(0); }} str& xs, str& xsErrorMsg macro_call_beginCProduction_LINK¸êmacro_call_begin³ MACRO_CALL_BEGIN IF(m_Makros.findKey(xState.str(1))) {{str xsErrorMsg; }} macro_call[xs, xsErrorMsg] {{ str s; re_macro_call(xs, s, xvUsed); xs = s + " "; // #define foo() bar ==> foo()baz ==> bar baz _not_ ==> barbaz xs += xsErrorMsg; }} ELSE {{ xs += xState.str(-1); if(m_Predefined.findKey(xState.str(1))) xs += m_Predefined.value(); else if(m_Defines.findKey(xState.str(1)) && m_Defines.value().id() == 0) { m_Defines.value().setId(1); xs += RePreproc(m_Defines.value().value()); m_Defines.value().setId(0); } else xs += xState.str(1); xs += "("; }} END str& xs, vstr& xvUsedmacro_parenthesisCProduction_LINKpºêmacro_parenthesisE{{ str s; }} macro_tokens[s] ")" {{ xs = s + xState.copy(); }} str& xs macro_tokenCProduction_LINK¼¢ê macro_token+ohne ')', das das Ende des macros darstellt‘( cpp_operator | CHAR | STRING | FLOAT | DECIMALINT | HEXADECIMALINT | OCTADECIMALLINT | ID | UNSIGNED | NOT_OTHER_PP_TOKEN_CHAR ) IGNORE_CPP macro_tokensCProduction_LINKÀ¤ê macro_tokens½{{ str s; }} ( macro_token {{ if(xs.empty()) xs = xState.str(); // because of possible replacement, if defined else xs += xState.copy(); }} | "(" {{ xs += xState.copy(); }} macro_parenthesis[s] {{ xs += s; s.clear(); }} // | macro_call_begin[s] {{ xs += xState.lp_copy(); s.clear(); }} | MACRO_CALL_BEGIN {{ xs += xState.copy(); }} macro_parenthesis[s] {{ xs += s; s.clear(); }} | BSEOL | "#" {{ xs += xState.str(); }} | "##" {{ xs += xState.str(); }} | EOL {{ xs += xState.copy(); }} )* str& xs multiply_exprCProduction_LINKĦê multiply_exprŸunary_expr[xiIsDefined] ( {{int iIsDefined;}} ( "*" unary_expr[iIsDefined] {{xiIsDefined = xiIsDefined * iIsDefined; }} | "/" unary_expr[iIsDefined] {{ if(iIsDefined == 0) throw CTT_Error("division by 0"); xiIsDefined = xiIsDefined / iIsDefined; }} | "%" unary_expr[iIsDefined] {{xiIsDefined = xiIsDefined % iIsDefined; }} ) )* int& xiIsDefined IGNORE_CPPobject_like_macroCProduction_LINKdÃêobject_like_macro_{{ str s, sTmp, sName; vstr vUsed; }} ID {{sName = xState.str();}} ( BSEOL // ignore | macro_call_begin[sTmp, vUsed] {{ s += sTmp; sTmp = ""; }} | ( ID | "(" | ")" | cpp_operator | CHAR | STRING | FLOAT | DECIMALINT | HEXADECIMALINT | OCTADECIMALLINT | UNSIGNED | NOT_OTHER_PP_TOKEN_CHAR ) {{ s += xState.copy(); }} )* EOL {{ m_Defines[sName] = node(sName, trim_copy(s)); }} outer_groupCProduction_LINK„Êê outer_groupgroup[xbPrint, xiLevel]* bool xbPrint, int xiLevel IGNORE_CPP pp_tokensCProduction_LINKÍê pp_tokens€{{ str s, sTmp; vstr vUsed; }} ( macro_call_begin[sTmp, vUsed] {{ if(xbPrint) {s += sTmp; sTmp.clear(); } }} | BSEOL // ignore | ID {{ if(xbPrint) { s += xState.str(-1); if(m_Predefined.findKey(xState.str())) s += m_Predefined.value(); else if(m_Defines.findKey(xState.str()) && m_Defines.value().id() == 0) { m_Defines.value().setId(1); s += RePreproc(m_Defines.value().value()); m_Defines.value().setId(0); } else s += xState.str(); } }} | ( cpp_operator | CHAR | STRING | FLOAT | DECIMALINT | HEXADECIMALINT | OCTADECIMALLINT | UNSIGNED | NOT_OTHER_PP_TOKEN_CHAR | ")" | "(" ) {{ if(xbPrint) s += xState.copy(); }} )+ {{ if( xbPrint ) out << s; }} bool xbPrint IGNORE_CPP pragma_lineCProduction_LINKœÚê pragma_line# PD_PRAGMA pp_tokens[false]? EOL preprocess_fileCProduction_LINKÝêpreprocess_fileB{{ Init(); }} outer_group[true, 0] {- statistics(); -} prim_exprCProduction_LINKlßê prim_expr( constant[xiIsDefined] | ID {{ xiIsDefined = GetDefineInt(State.str()); }} | "defined" ( "(" const_expr[xiIsDefined] ")" | ID {{ xiIsDefined = GetDefineInt(State.str()); }} ) ) | "(" const_expr[xiIsDefined] ")" int& xiIsDefinedrelational_exprCProduction_LINK äêrelational_exprßshift_expr[xiIsDefined] ( {{int iIsDefined;}} ( "<=" shift_expr[iIsDefined] {{xiIsDefined = xiIsDefined <= iIsDefined; }} | ">=" shift_expr[iIsDefined] {{iIsDefined = 3; }} {{xiIsDefined = xiIsDefined >= iIsDefined; }} | "<" shift_expr[iIsDefined] {{xiIsDefined = xiIsDefined < iIsDefined; }} | ">" shift_expr[iIsDefined] {{xiIsDefined = xiIsDefined > iIsDefined; }} ) )* int& xiIsDefined IGNORE_CPP re_macro_callCProduction_LINKlêê re_macro_call{{ str sTmp; }} ( re_pp_tokens[sTmp, xvUsed] {{ xs += sTmp; }} | EOL {{ xs += "\n"; }} )+ str& xs, vstr& xvUsed IGNORE_CPP re_pp_tokensCProduction_LINK„íê re_pp_tokens…{{ xs = ""; str sTmp; }} ( macro_call_begin[sTmp, xvUsed] {{ xs += sTmp; sTmp.clear(); }} | BSEOL // ignore | ID {{ xs += xState.str(-1); if(m_Predefined.findKey(xState.str())) xs += m_Predefined.value(); else if(m_Defines.findKey(xState.str()) ) { if(m_Defines.value().id() == 0) { xs += m_Defines.value().value(); m_Defines.value().setId(1); xvUsed.push_back(m_Defines.value().value()); } else xs += xState.str(); } else xs += xState.str(); }} | ( cpp_operator | CHAR | STRING | FLOAT | DECIMALINT | HEXADECIMALINT | OCTADECIMALLINT | UNSIGNED | NOT_OTHER_PP_TOKEN_CHAR | ")" | "(" ) {{ xs += xState.copy(); }} )+ str& xs, vstr& xvUsed IGNORE_CPP shift_exprCProduction_LINK¼Åê shift_exprðadd_expr[xiIsDefined] ( {{int iIsDefined;}} ( "<<" add_expr[iIsDefined] {{xiIsDefined = xiIsDefined << iIsDefined; }} | ">>" add_expr[iIsDefined] {{xiIsDefined = xiIsDefined >> iIsDefined; }} ) )* int& xiIsDefined IGNORE_CPPskip_elif_sectionCProduction_LINKûêskip_elif_section$PD_ELIF skip_group* skip_if_end IGNORE_CPPskip_else_sectionCProduction_LINKýêskip_else_section%PD_ELSE skip_group* PD_ENDIF EOL IGNORE_CPP skip_groupCProduction_LINKë skip_group/( SKIP | skip_if_section )* IGNORE_CPP skip_if_beginCProduction_LINKhë skip_if_begin& PD_IFDEF | PD_IF | PD_IFNDEF IGNORE_CPP skip_if_endCProduction_LINKÐë skip_if_end< skip_elif_section | skip_else_section | PD_ENDIF EOL? IGNORE_CPPskip_if_sectionCProduction_LINK8ëskip_if_section)skip_if_begin skip_group* skip_if_end IGNORE_CPP unary_exprCProduction_LINK  ë unary_exprD prim_expr[xiIsDefined] | "+" unary_expr[xiIsDefined] {{ /*xiIsDefined = + xiIsDefined;*/ }} | "-" unary_expr[xiIsDefined] {{xiIsDefined = - xiIsDefined; }} | "~" unary_expr[xiIsDefined] {{xiIsDefined = ~ xiIsDefined; }} | "!" unary_expr[xiIsDefined] {{xiIsDefined = ! xiIsDefined; }} int& xiIsDefined IGNORE_CPP undef_lineCProduction_LINKp$ë undef_line1PD_UNDEF ID {{ Undefine(xState.str()); }} warning_lineCProduction_LINKØ&ë warning_line;PD_WARNING SKIP {{ AddWarning(xState.copy()); }} EOL IGNORE_CPP GetDefineIntCElementScript$» GetDefineInt²{{ if(m_Predefined.findKey(xs)) return stoi(m_Predefined.value()); if(m_Defines.containsKey(xs)) return 1; if(m_Makros.containsKey(xs)) return 1; return 0; }} const str& xsintInitCElementScriptˆ*ëInitÔ{{ IncludePaths(ConfigParam()); if(!SourceRoot().empty()) m_vIncludeDirs.push_back(SourceRoot()); m_bReallyIncludeAll = true; m_vFiles.push_back(basename(SourceName()) + extension(SourceName())); }} IsDefinedCElementScriptT+ë IsDefined£{{ if(m_Predefined.containsKey(xs)) return true; if(m_Defines.containsKey(xs)) return true; if(m_Makros.containsKey(xs)) return true; return false; }} const str& xsboolIsHeaderToSourceCElementScript¼-ëIsHeaderToSourcexiLevel already is incremented–{{ if(xiLevel > 1) return false; if(change_extension(SourceName(), extension(xsPath)) == xsPath) return true; else return false; }} int xiLevel, const str& xsPathbool log_QuotedCElementScriptø/ë log_Quoted6{{ str s = "'"; s += xs; s += "'"; return s; }} const str& xsstr MakeStringCElementScriptü0ë MakeStringô{{ str sResult = "\""; str sFindWhat = "\\\""; unsigned int oldpos = 0; unsigned int pos = xs.find_first_of(sFindWhat); while(pos != str::npos) { sResult += xs.substr(oldpos, pos - oldpos); switch(xs[pos]) { case '\\': sResult += "\\\\"; break; case '\"': sResult += "\\\""; break; } oldpos = pos + 1; pos = xs.find_first_of(sFindWhat, oldpos); } sResult += xs.substr(oldpos); sResult += "\""; //log << xs << " : " << sResult << endl; return sResult; }} const str& xsstrm_bReallyIncludeAllCElementScriptø5ëm_bReallyIncludeAll&{{ m_bReallyIncludeAll = false; }} bool m_DefinesCElementScriptà6ë m_Definesmstrnodem_MakrosCElementScriptÈ7ëm_Makrosmstrnodem_mHeaderPathsCElementScript°8ëm_mHeaderPathsmstrstrm_mNotFoundHeadersCElementScript˜9ëm_mNotFoundHeadersmstrnode m_PredefinedCElementScript€:ë m_PredefinedZ{{ m_Predefined["__LINE__"] = "1"; // always defined m_Predefined["__FILE__"] = "1"; // always defined m_Predefined["__DATE__"] = "1"; // always defined m_Predefined["__TIME__"] = "1"; // always defined m_Predefined["__cplusplus"] = "1"; // always defined //m_Predefined["__STDC__"] = "1"; // depends on the implementation }} {- int borland_version = 0x0560; int architecture = 0x12c; m_Predefined["__BORLANDC__"] = itos(borland_version); m_Predefined["__BCPLUSPLUS__"] = itos(borland_version); m_Predefined["__TCPLUSPLUS__"] = itos(borland_version); m_Predefined["__TEMPLATES__"] = "1"; m_Predefined["__TLS__ "] = "1"; m_Predefined["__TURBOC__"] = itos(borland_version); m_Predefined["_WCHAR_T"] = "1"; m_Predefined["_M_IX86"] = itos(architecture); m_Predefined["_Windows"] = "1"; m_Predefined["__WIN32__"] = "1"; -} mstrstrm_vFilesCElementScripth;ëm_vFilesvstrm_vIncludeDirsCElementScriptP<ëm_vIncludeDirs vstr ReallyIncludeCElementScript8=ë ReallyInclude {{ if(m_bReallyIncludeAll) return true; if(extension(xsPath) != ".h" && extension(xsPath) != ".hpp") return true; else return false; }} int xiLevel, const str& xsPathbool RePreprocCElementScriptä>ë RePreproc{{ if(xs.empty()) return xs; str sOutput = xs, sInput; vstr vUsed; while(sInput != sOutput) { sInput = sOutput; //log << "RePreproc " << sInput << endl; re_pp_tokens(sInput, sOutput, vUsed); } ResetUse(vUsed); return sOutput; }} const str& xsstrResetUseCElementScriptȨêResetUse{{ vstr::cursor cr = xvUsed.getCursor(); while(cr.gotoNext()) { m_Defines.findKey(cr.value()); m_Defines.value().setId(0); } }} vstr xvUsedscan_include_fileCElementScriptLêscan_include_file(wird nur für bDefined == true aufgerufenl{{ bool bFound = false; bool bReallyInclude = false; str sInclude; if(xState.matched(2)) sInclude = xState.str(2); // "..." else sInclude = xState.str(3); // system header <...> // e.g. sInclude == "stl/_prolog.h" str sIncludeFile = basename(sInclude) + extension(sInclude); str sIncludeFilePath = sInclude.substr(0, sInclude.size() - sIncludeFile.size()); log << "tried to include: " << sInclude << " on level: " << xiLevel << endl; if(//!m_mHeaderPaths.containsKey(sInclude) && // should be managed by the sentinel !m_mNotFoundHeaders.containsKey(sInclude)) { vstr::cursor cr = m_vIncludeDirs.getCursor(); cr.reset(); while(cr.gotoNext()) { str sPath; str sIncludePath = append_path(cr.value(), sIncludeFilePath); bReallyInclude = false; if(!is_directory(cr.value())) throw CTT_Error(sIncludePath + " is not a directory"); if(find_file(sIncludePath, sIncludeFile, sPath)) { bFound = true; m_mHeaderPaths[sInclude] = sPath; str buf; //log << sPath << " isHeader " << IsHeaderToSouce(xiLevel, sPath) << endl; log << "including: " << sPath << endl; if(load_file(buf, sPath)) { bReallyInclude = ReallyInclude(xiLevel + 1, sPath); //log << sPath << "really included = " << bReallyInclude << endl; m_vFiles.push_back(basename(sIncludeFile) + extension(sIncludeFile)); header(buf, bReallyInclude, xiLevel + 1); m_vFiles.pop_back(); } else { AddError(sPath + " could not be loaded!"); } break; } } if(!bFound && m_vFiles.size() ) m_mNotFoundHeaders[sInclude] = node(m_vFiles.back(), itos(xiLevel)); } return bReallyInclude; }} int xiLevelbool statisticsCElementScriptOë statistics›{- log << endl << "NEW DEFINES" << endl << "-----------"<< endl << endl; mstrnode::cursor crd = m_Defines.getCursor(); while(crd.gotoNext()) log << log_Quoted(crd.key()) << "\t\t" << crd.value().value() << endl; log << endl << "MAKROS" << endl << "------" << endl << endl; mstrnode::cursor crm = m_Makros.getCursor(); crm.reset(); while(crm.gotoNext()) { log << log_Quoted(crm.key()) << "\t\t"; node pos = crm.value().firstChild(); while(pos != node::npos) { log << pos.value(); pos = pos.nextSibling(); } log << endl; } log << endl << "HEADER" << endl << "------" << endl << endl; log << "found :" << endl << endl; format fFound("%||%|20t|%||\n"); mstrstr::cursor cr1 = m_mHeaderPaths.getCursor(); while(cr1.gotoPrev()) // most basic units at first log << fFound % cr1.key() % cr1.value(); log << endl << endl << "not found:" << endl << endl; format fNotFound("%||%|20t| in: %||%|45T.| level: %||\n"); mstrnode::cursor cr2 = m_mNotFoundHeaders.getCursor(); while(cr2.gotoNext()) log << fNotFound % cr2.key() % cr2.value().label() % cr2.value().value(); -} UndefineCElementScriptYëUndefinen{{ if(m_Predefined.findKey(xs)) m_Predefined.remove(); if(m_Defines.findKey(xs)) m_Defines.remove(); }} const str& xs& concatenation CTestScriptøYë concatenationpreprocess_file j struct command commands[] = { {"quit",quit_command } , {"help",help_command } , ... }; Œ#define COMMAND(NAME) { #NAME, NAME ## _command } struct command commands[] = { COMMAND (quit), COMMAND (help), ... }; pffunction_like1 CTestScriptä[ëfunction_like1preprocess_file () c_init()() .#define lang_init () c_init() lang_init()pffunction_like10 CTestScript¨\ëfunction_like10preprocess_file  1#define min(X, Y) ((X) < (Y) ? (X) : (Y)) min()pffunction_like11 CTestScriptl]ëfunction_like11preprocess_file  3#define min(X, Y) ((X) < (Y) ? (X) : (Y)) min(,,)pffunction_like12 CTestScript0^ëfunction_like12preprocess_file bar, "x" !#define foo2(x) x, "x" foo2(bar)pffunction_like2 CTestScriptô^ëfunction_like2preprocess_file c_init() -#define lang_init() c_init() lang_init()pffunction_like3 CTestScript¸_ëfunction_like3preprocess_file x = ((a) < (b) ? (a) : (b)) ; :#define min(X, Y) ((X) < (Y) ? (X) : (Y)) x = min(a, b);pffunction_like4 CTestScript|`ëfunction_like4preprocess_file y = ((1) < (2) ? (1) : (2)) ; :#define min(X, Y) ((X) < (Y) ? (X) : (Y)) y = min(1, 2);pffunction_like5 CTestScript@aëfunction_like5preprocess_file +z = ((a + 28) < (*p) ? (a + 28) : (*p)) ; @#define min(X, Y) ((X) < (Y) ? (X) : (Y)) z = min(a + 28, *p);pffunction_like6 CTestScriptbëfunction_like6preprocess_file (() < (b) ? () : (b)) 4#define min(X, Y) ((X) < (Y) ? (X) : (Y)) min(, b)pffunction_like7 CTestScriptÈbëfunction_like7preprocess_file ((a) < () ? (a) : ()) 4#define min(X, Y) ((X) < (Y) ? (X) : (Y)) min(a, )pffunction_like8 CTestScript€zëfunction_like8preprocess_file (() < () ? () : ()) 2#define min(X, Y) ((X) < (Y) ? (X) : (Y)) min(,)pffunction_like9 CTestScriptD{ëfunction_like9preprocess_file (((,)) < () ? ((,)) : ()) 5#define min(X, Y) ((X) < (Y) ? (X) : (Y)) min((,),)pf macro_macro1 CTestScript|ë macro_macro1preprocess_file X_BUFSIZE #define AFTERX(x) X_ ## x #define XAFTERX(x) AFTERX(x) #define TABLESIZE 1024 #define BUFSIZE TABLESIZE AFTERX(BUFSIZE)pf macro_macro2 CTestScriptÌ|ë macro_macro2preprocess_file X_1024 €#define AFTERX(x) X_ ## x #define XAFTERX(x) AFTERX(x) #define TABLESIZE 1024 #define BUFSIZE TABLESIZE XAFTERX(BUFSIZE)pf misnesting1 CTestScript ~ë misnesting1preprocess_file (2*(1)) L#define twice(x) (2*(x)) #define call_with_1(x) x(1) call_with_1 (twice)pf misnesting2 CTestScriptdë misnesting2preprocess_file "fprintf(stderr, "%s %d", p, 35) F#define strange(file) fprintf (file, "%s %d", strange(stderr) p, 35)pf object_like1 CTestScriptà}ë object_like1preprocess_file foo = (char *) malloc(1024); ?#define BUFFER_SIZE 1024 foo = (char *) malloc (BUFFER_SIZE);pf object_like2 CTestScriptˆ.ë object_like2preprocess_file int x[] = { 1,2,3 }; V#define NUMBERS 1, \ 2, \ 3 int x[] = { NUMBERS };pf object_like3 CTestScript\ÿ´ object_like3preprocess_file foo = X; bar = 4; foo = X; #define X 4 bar = X;pf object_like4 CTestScriptt¼ê object_like4preprocess_file 1024 <#define TABLESIZE BUFSIZE #define BUFSIZE 1024 TABLESIZEpf object_like5 CTestScriptxLê object_like5?preprocess_file  37 b#define BUFSIZE 1020 #define TABLESIZE BUFSIZE #undef BUFSIZE #define BUFSIZE 37 TABLESIZEpfprecedence_problem1 CTestScriptd»precedence_problem1preprocess_file /a = (b & c + sizeof(int) - 1) / sizeof(int) ; L#define ceil_div(x, y) (x + y - 1) / y a = ceil_div (b & c, sizeof (int));pfprecedence_problem2 CTestScriptBêprecedence_problem2preprocess_file 7a = ((b & c) + ( sizeof(int)) - 1) / ( sizeof(int)) ; R#define ceil_div(x, y) ((x) + (y) - 1) / (y) a = ceil_div (b & c, sizeof (int));pfredefine CTestScriptÔáêredefinepreprocess_file x = 5; )#define FOO 4 #define FOO 5 x = FOO; pfself_referential1 CTestScriptPâêself_referential1preprocess_file (4 + foo) #define foo (4 + foo) foopfself_referential2 CTestScriptPbêself_referential2preprocess_file EPERM #define EPERM EPERM EPERMpfself_referential3 CTestScriptcêself_referential3preprocess_file (4 + (2 * x)) )#define x (4 + y) #define y (2 * x) xpfself_referential4 CTestScriptì>»self_referential4preprocess_file (2 * (4 + y)) )#define x (4 + y) #define y (2 * x) ypf sideeffect CTestScriptÀê sideeffectpreprocess_file 6next = ((x + y) < ( foo(z)) ? (x + y) : ( foo(z))) ; I#define min(X, Y) ((X) < (Y) ? (X) : (Y)) next = min (x + y, foo (z));pfstringification1 CTestScript|Àêstringification1preprocess_file Gdo { if(x == 0)fprintf(stderr, "Warning: ""x == 0" "\n"); }while(0) ; w#define WARN_IF(EXP) \ do { if (EXP) \ fprintf (stderr, "Warning: " #EXP "\n"); } \ while (0) WARN_IF (x == 0); pfstringification2 CTestScriptˆæêstringification2preprocess_file "p = \"foo\\n\";" 5#define STRINGIFY(EXP) #EXP STRINGIFY (p = "foo\n";)pfstringification3 CTestScriptçêstringification3preprocess_file "foo" F#define xstr(s) str(s) #define str(s) #s #define foo 4 str (foo)pfstringification4 CTestScript¸çêstringification4preprocess_file "4" G#define xstr(s) str(s) #define str(s) #s #define foo 4 xstr (foo)pf Tokenization CTestScriptäšë Tokenizationpreprocess_file bar baz #define foo() bar foo()bazpfundefine CTestScript¨›ëundefinepreprocess_file x = FOO; %#define FOO 4 #undef FOO x = FOO; pfunshielded_comma1 CTestScriptlœëunshielded_comma1preprocess_file lose(a,b) P#define foo a,b #define bar(x) lose(x) #define lose(x) (1 + (x)) bar(foo)unshielded_comma2 CTestScriptëunshielded_comma2preprocess_file (1 + ((a,b))) P#define bar(x) lose(x) #define lose(x) (1 + (x)) #define foo (a,b) bar(foo)COptionsProjectˆË¶ProjectOptionsProjectOptionsCOptionSection`žëProjectOptions CaseSensitiveCScript¼žë CaseSensitive1 CommentToCodeCScript Ÿë CommentToCode0 ConfigParamCScript„Ÿë ConfigParam""Cpp_PrjParserHeaderCScriptèŸëCpp_PrjParserHeader%D:\Tetra\Projects\Cpp\C_pp\C_pp_h.frmCpp_PrjParserSourceCScriptL ëCpp_PrjParserSource%D:\Tetra\Projects\Cpp\C_pp\C_pp_c.frmCreateInterfaceCScript° ëCreateInterface0 ExportableCScript¡ë Exportable1 ExtraParamCScriptx¡ë ExtraParam""GlobalLiteralScannerCScriptÜ¡ëGlobalLiteralScanner1GlobalRegexScannerCScript@¢ëGlobalRegexScanner0 IgnoreCharsCScript¤¢ë IgnoreChars\tIgnoreWhiteSpaceCScript£ëIgnoreWhiteSpace1 InclusionProdCScriptl£ë InclusionProdcomment InterpretableCScriptУë Interpretable1IsNullableWarningCScript4¤ëIsNullableWarning0 MaxStackSizeCScript˜¤ë MaxStackSize300NeatlessCScriptü¤ëNeatless1 PreprocessorCScript`¥ë Preprocessor SeparatedCScriptÄ¥ë Separated1StartSuccNullableWarningCScript(¦ëStartSuccNullableWarning0 StartruleCScriptŒ¦ë Startrulepreprocess_fileTestAllLiteralsCScriptð¦ëTestAllLiterals0TestFileCScriptT§ëTestFileUseIgnoreRegexCScript¸§ëUseIgnoreRegex0UseLocalOptionsCScript¨ëUseLocalOptions0