| 1 |
#include "production.ih" |
| 2 |
|
| 3 |
void Production::insertAction(Production const *prod, std::ostream &out, |
| 4 |
bool lineDirectives, size_t indent) |
| 5 |
|
| 6 |
{ |
| 7 |
if (! prod->hasAction()) |
| 8 |
return; |
| 9 |
|
| 10 |
out << setw(indent) << "" << "case " << prod->nr() << ":\n"; |
| 11 |
size_t begin = 0; |
| 12 |
Block const &block = prod->action(); |
| 13 |
|
| 14 |
if (lineDirectives) |
| 15 |
out << "#line " << block.lineNr() << " \"" << block.source() << |
| 16 |
"\"\n"; |
| 17 |
|
| 18 |
while (true) |
| 19 |
{ |
| 20 |
size_t end = block.find_first_of('\n', begin); |
| 21 |
out << setw(indent) << "" << |
| 22 |
block.substr(begin, end - begin) << "\n"; |
| 23 |
if (end == string::npos) |
| 24 |
break; |
| 25 |
begin = end + 1; |
| 26 |
} |
| 27 |
out << setw(indent) << "" << "break;\n" |
| 28 |
"\n"; |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|