static void PrintActions(std::wostream& os, Grammar& g, bool virt) { #if 0 os << L"/*Forward declarations for actions*/\n"; os << L"struct Eval_Context;\n"; os << L"\n"; os << L" " << g.GetLanguageName() << L"_Actions{\n"; const wchar_t * psz0 = L" int (*{ACTION})( {LANG}_Context* ctx);\n"; std::wstring ws0(psz0); find_replace(ws0, L"{LANG}", g.GetLanguageName()); for (int i = 0; i < g.GetNumberOfActions(); i++) { std::wstring ws(ws0); find_replace(ws, L"{ACTION}", g.GetActionName(i)); os << ws; } os << L"};\n"; #else os << L"typedef enum \n"; os << L"{\n"; for (int i = 0; i < g.GetNumberOfActions(); i++) { os << L" " << g.GetActionName(i) << L",\n"; } os << g.GetLanguageName() << L"_OnError\n"; os << L"}" << g.GetLanguageName() << L"_Actions;\n"; #endif }
static void PrintActionsNames(std::wostream& os, Grammar& g, bool virt) { os << L"//\n"; os << L"const char* " << g.GetLanguageName() << L"_Actions_Text("; os << L"" << g.GetLanguageName() << L"_Actions e)\n"; os << L"{\n"; os << L" switch(e)\n"; os << L" {\n"; for (int i = 0; i < g.GetNumberOfActions(); i++) { os << L" case " << g.GetActionName(i) << L": return \"" << g.GetActionName(i) << L"\";\n"; } os << L" }\n"; os << L" return \"\";\n"; os << L"};\n"; }