2 #ifndef __CODE_HELPER_CC 3 #define __CODE_HELPER_CC 13 #define SAVEP(X) "(" << X << ")" 15 #define OB(X) hlp.openBrace(X) //shortcut nomenclature to open the Xth curly brace { plus a new line 16 #define CB(X) hlp.closeBrace(X) //shortcut nomenclature to close the Xth curly brace } plus a new line 17 #define ENDL hlp.endl()//shortcut nomenclature to generate a newline followed correct number of indentation characters for the current level 29 braces.push_back(level);
30 if (verbose) printf(
"%sopen %u.\n",indentBy(braces.size() - 1).c_str(),level);
31 string result =
" {\n";
32 result.append(indentBy(braces.size() - 1));
37 if (braces.back()==level) {
38 if (verbose) printf(
"%sclose %u.\n",indentBy(braces.size() - 1).c_str(),level);
40 string result =
"}\n";
41 result.append(indentBy(braces.size() - 1));
44 cerr <<
"Code generation error: Attempted to close brace " << level <<
", expecting brace " << braces.back() <<
"\n" ;
52 result.append(indentBy(braces.size() - 1));
57 string indentBy(
unsigned int numIndents)
const{
59 for (
int i = 0; i < numIndents; i++) {
65 vector<unsigned int> braces;
Definition: CodeHelper.h:19
CodeHelper hlp
Definition: generateALL.cc:42
string openBrace(unsigned int level)
Definition: CodeHelper.h:28
string closeBrace(unsigned int level)
Definition: CodeHelper.h:36
string endl() const
Definition: CodeHelper.h:49
void setVerbose(bool isVerbose)
Definition: CodeHelper.h:25
CodeHelper()
Definition: CodeHelper.h:21