diff -r dbcc3b784234 -r 66993500719f parser.cxx --- a/parser.cxx Sat Jul 14 17:39:43 2012 +0300 +++ b/parser.cxx Sat Jul 14 18:03:37 2012 +0300 @@ -168,6 +168,12 @@ if (!g_stateSpawnDefined) ParserError ("script must have a state named `stateSpawn`!"); + // If the last state did not have a main loop, define a dummy one now. + if (!gotMainLoop) { + w->Write (DH_MAINLOOP); + w->Write (DH_ENDMAINLOOP); + } + /* // State w->WriteState ("stateSpawn"); @@ -192,9 +198,6 @@ if (g_CurMode == MODE_TOPLEVEL) ParserError ("no commands allowed at top level!"); - w->Write (DH_COMMAND); - w->Write (comm->number); - w->Write (comm->maxargs); MustNext ("("); int curarg = 0; while (1) { @@ -220,6 +223,7 @@ ParserError ("argument %d (`%s`) is not a number", curarg, token.chars()); int i = atoi (token.chars ()); + w->Write (DH_PUSHNUMBER); w->Write (i); if (curarg < comm->numargs - 1) { @@ -240,7 +244,12 @@ // If the script skipped any optional arguments, fill in defaults. while (curarg < comm->maxargs) { + w->Write (DH_PUSHNUMBER); w->Write (comm->defvals[curarg]); curarg++; } + + w->Write (DH_COMMAND); + w->Write (comm->number); + w->Write (comm->maxargs); } \ No newline at end of file