Simple string passing through nodes in Bison/Yacc
问题 I have to concatenate strings in semantic rules of my yacc file: %union { stringstream sstream; } %type<sstream> node1 node2 --- node1 : node2 { $$ << $1 << " goodbye" } node2 : final { $$ << "hello" } However, as stringstream or even string are not allowed in unions, I don't find any easy way to mix char * , int , and make nodes transport a string that I can manipulate everywhere. How should I do it ? 回答1: I don't remember bison / yacc details, but you sure can use pointer and new it. Just