Adjust parser to not malloc when a thrown error might prevent allocations from being freed

Imported from elua trunk, adapted to #ifdef LUA_EGC stuff.
This does seem to slightly improve memory leakage behaviour:
in 20KB RAM you can press Enter 17 times before getting "not enough memory"
instead of 16. It also makes the code 48 bytes smaller :-)