xxxxxxxxxx
import std.stdio;
enum SymbolKindEnum {
S_YYEMPTY = -2, /* No symbol. */
S_YYEOF = 0, /* "end of file" */
S_YYerror = 1, /* error */
/* ... */
S_input = 14, /* input */
S_line = 15, /* line */
S_exp = 16, /* exp */
}
string toString(SymbolKindEnum kind) pure
{
final switch (kind) with(SymbolKindEnum) {
case S_YYEMPTY:
assert(false, "Tried representing no symbol as a string.");
case S_YYEOF:
return `"end of file"`;
case S_YYerror:
return `error`;
/*...*/
case S_input:
return `input`;
case S_line:
return `line`;
case S_exp:
return `exp`;
}
}
void main()
{
auto kind = SymbolKindEnum.S_YYEOF;
writeln(kind.toString); // "end of file"
}