diff options
author | Adrian Thurston <thurston@complang.org> | 2012-05-22 20:09:55 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2012-05-22 20:09:55 -0400 |
commit | aa01add5ba8ea59850b4db058f6a0e53ab9c41fe (patch) | |
tree | ed652332ea7bd4b02231330f8b10e17cf2d961af | |
parent | 82ebe66edf90112f0370dde9460aa86dad3eb813 (diff) | |
download | colm-aa01add5ba8ea59850b4db058f6a0e53ab9c41fe.tar.gz |
added text_notrim() to the C++ interface.
The text_notrim() functions retrieve the text of a token without automatically
trimming off whitespace.
-rw-r--r-- | colm/codegen.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/colm/codegen.cc b/colm/codegen.cc index 400e4b9a..b6adc935 100644 --- a/colm/codegen.cc +++ b/colm/codegen.cc @@ -74,10 +74,10 @@ void ParseData::generateExports() "\n"; out << - "inline std::string printTreeStr( ColmProgram *prg, ColmTree *tree )\n" + "inline std::string printTreeStr( ColmProgram *prg, ColmTree *tree, bool trim )\n" "{\n" " std::string str;\n" - " ColmPrintArgs printArgs = { &str, 1, 0, 1, &appendString, \n" + " ColmPrintArgs printArgs = { &str, 1, 0, trim, &appendString, \n" " &printNull, &printTermTree, &printNull };\n" " printTreeArgs( prg, vm_root(prg), &printArgs, tree );\n" " return str;\n" @@ -97,7 +97,8 @@ void ParseData::generateExports() openNameSpace( out, lel->nspace ); out << "struct " << lel->fullName << "\n"; out << "{\n"; - out << " std::string text() { return printTreeStr( prg, tree ); }\n"; + out << " std::string text() { return printTreeStr( prg, tree, true ); }\n"; + out << " std::string text_notrim() { return printTreeStr( prg, tree, false ); }\n"; out << " operator ColmTree *() { return tree; }\n"; out << " ColmProgram *prg;\n"; out << " ColmTree *tree;\n"; |