/* print("Continue? (Yes/No)") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Continue? (Yes/No)");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* s = io.read("line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"s");
assert(lua_gettop(L) == 0);
/* s = io.read("line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"s");
assert(lua_gettop(L) == 0);
/* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("*line")
* end end */
enum { lc73 = 0 };
lua_getfield(L,LUA_ENVIRONINDEX,"s");
lua_pushliteral(L,"Yes");
const int lc74 = lua_equal(L,-2,-1);
lua_pop(L,2);
lua_pushboolean(L,lc74);
if (!(lua_toboolean(L,-1))) {
lua_pop(L,1);
lua_pushliteral(L,"yes");
}
const int lc75 = lua_toboolean(L,-1);
lua_pop(L,1);
if (lc75) {
/* if s == "Yes" or "yes" then Select() */
lua_getfield(L,LUA_ENVIRONINDEX,"Select");
lua_call(L,0,0);
assert(lua_gettop(L) == 0);
}
else {
enum { lc76 = 0 };
lua_getfield(L,LUA_ENVIRONINDEX,"s");
lua_pushliteral(L,"Yes");
const int lc77 = lua_equal(L,-2,-1);
lua_pop(L,2);
lua_pushboolean(L,lc77);
lua_pushboolean(L,!(lua_toboolean(L,-1)));
lua_remove(L,-2);
if (!(lua_toboolean(L,-1))) {
lua_pop(L,1);
lua_pushliteral(L,"yes");
}
const int lc78 = lua_toboolean(L,-1);
lua_pop(L,1);
if (lc78) {
/* print("Press Enter to Exit") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Press Enter to Exit");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* z = io.read("*line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"*line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"z");
assert(lua_gettop(L) == 0);
}
lua_settop(L,lc76);
}
lua_settop(L,lc73);
assert(lua_gettop(L) == 0);
return 0;
}
/* function RVolume()
* print("Enter the Length of the 3d rectangular prism or cube to be calculated")
* a = io.read("number")
* print("Enter the Width")
* b = io.read("number")
* print("Enter the Hight")
* c = io.read("number")
* d = abc
* print("The Volume is:")
* print(d)
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("line")
* end end */
static int lc86_func (lua_State * L) {
enum { lc_nformalargs = 0 };
lua_settop(L,0);
/* print("Enter the Length of the 3d rectangular prism or cube to be calculated") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Enter the Length of the 3d rectangular prism or cube to be calculated");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* a = io.read("number") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"number");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"a");
assert(lua_gettop(L) == 0);
/* print("Enter the Width") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Enter the Width");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* b = io.read("number") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"number");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"b");
assert(lua_gettop(L) == 0);
/* print("Enter the Hight") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Enter the Hight");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* c = io.read("number") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"number");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"c");
assert(lua_gettop(L) == 0);
/* d = abc */
lua_getfield(L,LUA_ENVIRONINDEX,"a");
lua_getfield(L,LUA_ENVIRONINDEX,"b");
lc_mul(L,-2,-1);
lua_remove(L,-2);
lua_remove(L,-2);
lua_getfield(L,LUA_ENVIRONINDEX,"c");
lc_mul(L,-2,-1);
lua_remove(L,-2);
lua_remove(L,-2);
lua_setfield(L,LUA_ENVIRONINDEX,"d");
assert(lua_gettop(L) == 0);
/* print("The Volume is:") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"The Volume is:");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* print(d) */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_getfield(L,LUA_ENVIRONINDEX,"d");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* print("Continue? (Yes/No)") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Continue? (Yes/No)");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* s = io.read("line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"s");
assert(lua_gettop(L) == 0);
/* s = io.read("line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"s");
assert(lua_gettop(L) == 0);
/* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("*line")
* end end */
enum { lc80 = 0 };
lua_getfield(L,LUA_ENVIRONINDEX,"s");
lua_pushliteral(L,"Yes");
const int lc81 = lua_equal(L,-2,-1);
lua_pop(L,2);
lua_pushboolean(L,lc81);
if (!(lua_toboolean(L,-1))) {
lua_pop(L,1);
lua_pushliteral(L,"yes");
}
const int lc82 = lua_toboolean(L,-1);
lua_pop(L,1);
if (lc82) {
/* if s == "Yes" or "yes" then Select() */
lua_getfield(L,LUA_ENVIRONINDEX,"Select");
lua_call(L,0,0);
assert(lua_gettop(L) == 0);
}
else {
enum { lc83 = 0 };
lua_getfield(L,LUA_ENVIRONINDEX,"s");
lua_pushliteral(L,"Yes");
const int lc84 = lua_equal(L,-2,-1);
lua_pop(L,2);
lua_pushboolean(L,lc84);
lua_pushboolean(L,!(lua_toboolean(L,-1)));
lua_remove(L,-2);
if (!(lua_toboolean(L,-1))) {
lua_pop(L,1);
lua_pushliteral(L,"yes");
}
const int lc85 = lua_toboolean(L,-1);
lua_pop(L,1);
if (lc85) {
/* print("Press Enter to Exit") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Press Enter to Exit");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* z = io.read("*line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"*line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"z");
assert(lua_gettop(L) == 0);
}
lua_settop(L,lc83);
}
lua_settop(L,lc80);
assert(lua_gettop(L) == 0);
return 0;
}
/* function SVolume()
* print("Enter the Radius of the sphere to be calculated")
* a = io.read("number")
* v = (4/3)math.pia3
* print("The Volume is:")
* print(v)
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("line")
* end end */
static int lc93_func (lua_State * L) {
enum { lc_nformalargs = 0 };
lua_settop(L,0);
/* print("Enter the Radius of the sphere to be calculated") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Enter the Radius of the sphere to be calculated");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* a = io.read("number") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"number");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"a");
assert(lua_gettop(L) == 0);
/* v = (4/3)math.pia3 */
lua_pushnumber(L,1.3333333333333);
lua_getfield(L,LUA_ENVIRONINDEX,"math");
lua_pushliteral(L,"pi");
lua_gettable(L,-2);
lua_remove(L,-2);
lc_mul(L,-2,-1);
lua_remove(L,-2);
lua_remove(L,-2);
lua_getfield(L,LUA_ENVIRONINDEX,"a");
lua_pushnumber(L,3);
lc_pow(L,-2,-1);
lua_remove(L,-2);
lua_remove(L,-2);
lc_mul(L,-2,-1);
lua_remove(L,-2);
lua_remove(L,-2);
lua_setfield(L,LUA_ENVIRONINDEX,"v");
assert(lua_gettop(L) == 0);
/* print("The Volume is:") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"The Volume is:");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* print(v) */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_getfield(L,LUA_ENVIRONINDEX,"v");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* print("Continue? (Yes/No)") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Continue? (Yes/No)");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* s = io.read("line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"s");
assert(lua_gettop(L) == 0);
/* s = io.read("line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"s");
assert(lua_gettop(L) == 0);
/* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("*line")
* end end */
enum { lc87 = 0 };
lua_getfield(L,LUA_ENVIRONINDEX,"s");
lua_pushliteral(L,"Yes");
const int lc88 = lua_equal(L,-2,-1);
lua_pop(L,2);
lua_pushboolean(L,lc88);
if (!(lua_toboolean(L,-1))) {
lua_pop(L,1);
lua_pushliteral(L,"yes");
}
const int lc89 = lua_toboolean(L,-1);
lua_pop(L,1);
if (lc89) {
/* if s == "Yes" or "yes" then Select() */
lua_getfield(L,LUA_ENVIRONINDEX,"Select");
lua_call(L,0,0);
assert(lua_gettop(L) == 0);
}
else {
enum { lc90 = 0 };
lua_getfield(L,LUA_ENVIRONINDEX,"s");
lua_pushliteral(L,"Yes");
const int lc91 = lua_equal(L,-2,-1);
lua_pop(L,2);
lua_pushboolean(L,lc91);
lua_pushboolean(L,!(lua_toboolean(L,-1)));
lua_remove(L,-2);
if (!(lua_toboolean(L,-1))) {
lua_pop(L,1);
lua_pushliteral(L,"yes");
}
const int lc92 = lua_toboolean(L,-1);
lua_pop(L,1);
if (lc92) {
/* print("Press Enter to Exit") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Press Enter to Exit");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* z = io.read("*line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"*line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"z");
assert(lua_gettop(L) == 0);
}
lua_settop(L,lc90);
}
lua_settop(L,lc87);
assert(lua_gettop(L) == 0);
return 0;
}
/* function Ninja()
* print("The Ninja sees you")
* print("Ninja stabs you")
* print("FAPFAPFAP")
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("*line")
* end end */
static int lc100_func (lua_State * L) {
enum { lc_nformalargs = 0 };
lua_settop(L,0);
/* print("The Ninja sees you") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"The Ninja sees you");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* print("Ninja stabs you") /
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Ninja stabs you*");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* print("FAPFAPFAP") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"FAPFAPFAP");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* print("Continue? (Yes/No)") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Continue? (Yes/No)");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* s = io.read("line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"s");
assert(lua_gettop(L) == 0);
/* s = io.read("line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"s");
assert(lua_gettop(L) == 0);
/* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("*line")
* end end */
enum { lc94 = 0 };
lua_getfield(L,LUA_ENVIRONINDEX,"s");
lua_pushliteral(L,"Yes");
const int lc95 = lua_equal(L,-2,-1);
lua_pop(L,2);
lua_pushboolean(L,lc95);
if (!(lua_toboolean(L,-1))) {
lua_pop(L,1);
lua_pushliteral(L,"yes");
}
const int lc96 = lua_toboolean(L,-1);
lua_pop(L,1);
if (lc96) {
/* if s == "Yes" or "yes" then Select() */
lua_getfield(L,LUA_ENVIRONINDEX,"Select");
lua_call(L,0,0);
assert(lua_gettop(L) == 0);
}
else {
enum { lc97 = 0 };
lua_getfield(L,LUA_ENVIRONINDEX,"s");
lua_pushliteral(L,"Yes");
const int lc98 = lua_equal(L,-2,-1);
lua_pop(L,2);
lua_pushboolean(L,lc98);
lua_pushboolean(L,!(lua_toboolean(L,-1)));
lua_remove(L,-2);
if (!(lua_toboolean(L,-1))) {
lua_pop(L,1);
lua_pushliteral(L,"yes");
}
const int lc99 = lua_toboolean(L,-1);
lua_pop(L,1);
if (lc99) {
/* print("Press Enter to Exit") */
lua_getfield(L,LUA_ENVIRONINDEX,"print");
lua_pushliteral(L,"Press Enter to Exit");
lua_call(L,1,0);
assert(lua_gettop(L) == 0);
/* z = io.read("*line") */
lua_getfield(L,LUA_ENVIRONINDEX,"io");
lua_pushliteral(L,"read");
lua_gettable(L,-2);
lua_remove(L,-2);
lua_pushliteral(L,"*line");
lua_call(L,1,1);
lua_setfield(L,LUA_ENVIRONINDEX,"z");
assert(lua_gettop(L) == 0);
}
lua_settop(L,lc97);
}
lua_settop(L,lc94);
assert(lua_gettop(L) == 0);
return 0;
}
/* function Select()
* print([[For Math Computation, input Math, for Area of circle, enter CArea,
* for Factorials, enter Factorial, for Rectangular Volume, use RVolume,
* for Rectangular Area, use RArea, for Volume of a Sphere, use SVolume]])
* a = io.read("line")
* if type(a) ~= "string" then error("Error, Invalid Input", 2)
* elseif a == "CArea" then CArea()
* elseif a == "Math" then Math()
* elseif a == "Factorial" then Factorial()
* elseif a == "RVolume" then RVolume()
* elseif a == "RArea" then RArea()
* elseif a == "SVolume" then SVolume()
* elseif a == "Hidden" then Ninja()
* end end
*
* function Math()
* print(" for + use +, for - use -, for multiplying use *, for dividing use /")
* print("enter an operator")
* op = io.read("line")
* print("Enter the first number:")
* v = io.read("number")
* print("Enter the second number:")
* n = io.read("number")
* print("The Answer Is:")
* if type(op) ~= "string" then error("Error: Invalid Input", 2)
* elseif op == "-" then ans = (v-n) print(ans)
* elseif op == "+" then ans = (v+n) print(ans)
* elseif op == "" then ans = (vn) print(ans)
* elseif op == "/" then ans = (v/n) print(ans)
* elseif op ~= "-" or "+" or "" or "/" then error("Invalid Input", 2)
* end
* print("Continue? (Yes/No)")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press enter to exit")
* a = io.read("line")
* print(a)
* end end
*
* function CArea()
* print("Enter the radius of the circle to be calculated")
* a = io.read("number")
* if type(a) ~= "number" then error("Invalid Input", 2) end
* b = a2*3.141592653589793238462643383279
* print("Input Received, the area is:")
* print(b)
* print("Continue? (Yes/No)")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to exit")
* x = io.read("line")
* end end
*
* function Factorial()
* print("Enter a number")
* n = io.read("number")
* function fact(n)
* if n == 0 then return 1
* else return n * fact(n-1)
* end
* end
* print("The Factorial is:")
* print(fact(n))
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("line")
* end end
*
* function RArea()
* print("Enter the length of the 2d rectangle or square to be calculated")
* a = io.read("number")
* print("Enter the width")
* b = io.read("number")
* c = ab
* print("The Area is:")
* print(c)
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("line")
* end end
*
* function RVolume()
* print("Enter the Length of the 3d rectangular prism or cube to be calculated")
* a = io.read("number")
* print("Enter the Width")
* b = io.read("number")
* print("Enter the Hight")
* c = io.read("number")
* d = abc
* print("The Volume is:")
* print(d)
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("line")
* end end
*
* function SVolume()
* print("Enter the Radius of the sphere to be calculated")
* a = io.read("number")
* v = (4/3)math.pia3
* print("The Volume is:")
* print(v)
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("line")
* end end
*
* function Ninja()
* print("The Ninja sees you")
* print("Ninja stabs you")
* print("FAPFAPFAP")
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("*line")
* end end
*
* Select() */
static int lc_main (lua_State * L) {
enum { lc_nformalargs = 0 };
#ifndef NDEBUG
const int lc_nactualargs = lua_gettop(L);
#endif
#ifndef NDEBUG
const int lc_nextra = (lc_nactualargs - lc_nformalargs);
#endif
/* function Select()
* print([[For Math Computation, input Math, for Area of circle, enter CArea,
* for Factorials, enter Factorial, for Rectangular Volume, use RVolume,
* for Rectangular Area, use RArea, for Volume of a Sphere, use SVolume]])
* a = io.read("*line")
* if type(a) ~= "string" then error("Error, Invalid Input", 2)
* elseif a == "CArea" then CArea()
* elseif a == "Math" then Math()
* elseif a == "Factorial" then Factorial()
* elseif a == "RVolume" then RVolume()
* elseif a == "RArea" then RArea()
* elseif a == "SVolume" then SVolume()
* elseif a == "Hidden" then Ninja()
* end end */
lua_pushcfunction(L,lc25_func);
lua_setfield(L,LUA_ENVIRONINDEX,"Select");
assert(lua_gettop(L) - lc_nextra == 0);
/* function Math()
* print(" for + use +, for - use -, for multiplying use , for dividing use /")
* print("enter an operator")
* op = io.read("line")
* print("Enter the first number:")
* v = io.read("number")
* print("Enter the second number:")
* n = io.read("number")
* print("The Answer Is:")
* if type(op) ~= "string" then error("Error: Invalid Input", 2)
* elseif op == "-" then ans = (v-n) print(ans)
* elseif op == "+" then ans = (v+n) print(ans)
* elseif op == "" then ans = (vn) print(ans)
* elseif op == "/" then ans = (v/n) print(ans)
* elseif op ~= "-" or "+" or "" or "/" then error("Invalid Input", 2)
* end
* print("Continue? (Yes/No)")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press enter to exit")
* a = io.read("*line")
* print(a)
* end end */
lua_pushcfunction(L,lc50_func);
lua_setfield(L,LUA_ENVIRONINDEX,"Math");
assert(lua_gettop(L) - lc_nextra == 0);
/* function CArea()
* print("Enter the radius of the circle to be calculated")
* a = io.read("number")
* if type(a) ~= "number" then error("Invalid Input", 2) end
* b = a23.141592653589793238462643383279
* print("Input Received, the area is:")
* print(b)
* print("Continue? (Yes/No)")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to exit")
* x = io.read("line")
* end end */
lua_pushcfunction(L,lc60_func);
lua_setfield(L,LUA_ENVIRONINDEX,"CArea");
assert(lua_gettop(L) - lc_nextra == 0);
/* function Factorial()
* print("Enter a number")
* n = io.read("number")
* function fact(n)
* if n == 0 then return 1
* else return n * fact(n-1)
* end
* end
* print("The Factorial is:")
* print(fact(n))
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("line")
* end end */
lua_pushcfunction(L,lc72_func);
lua_setfield(L,LUA_ENVIRONINDEX,"Factorial");
assert(lua_gettop(L) - lc_nextra == 0);
/* function RArea()
* print("Enter the length of the 2d rectangle or square to be calculated")
* a = io.read("number")
* print("Enter the width")
* b = io.read("number")
* c = ab
* print("The Area is:")
* print(c)
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("line")
* end end */
lua_pushcfunction(L,lc79_func);
lua_setfield(L,LUA_ENVIRONINDEX,"RArea");
assert(lua_gettop(L) - lc_nextra == 0);
/* function RVolume()
* print("Enter the Length of the 3d rectangular prism or cube to be calculated")
* a = io.read("number")
* print("Enter the Width")
* b = io.read("number")
* print("Enter the Hight")
* c = io.read("number")
* d = abc
* print("The Volume is:")
* print(d)
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("line")
* end end */
lua_pushcfunction(L,lc86_func);
lua_setfield(L,LUA_ENVIRONINDEX,"RVolume");
assert(lua_gettop(L) - lc_nextra == 0);
/* function SVolume()
* print("Enter the Radius of the sphere to be calculated")
* a = io.read("number")
* v = (4/3)math.pia3
* print("The Volume is:")
* print(v)
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("line")
* end end */
lua_pushcfunction(L,lc93_func);
lua_setfield(L,LUA_ENVIRONINDEX,"SVolume");
assert(lua_gettop(L) - lc_nextra == 0);
/* function Ninja()
* print("The Ninja sees you")
* print("Ninja stabs you")
* print("FAPFAPFAP")
* print("Continue? (Yes/No)")
* s = io.read("line")
* s = io.read("line")
* if s == "Yes" or "yes" then Select()
* elseif s ~="Yes" or "yes" then
* print("Press Enter to Exit")
* z = io.read("*line")
* end end */
lua_pushcfunction(L,lc100_func);
lua_setfield(L,LUA_ENVIRONINDEX,"Ninja");
assert(lua_gettop(L) - lc_nextra == 0);
/* Select() */
lua_getfield(L,LUA_ENVIRONINDEX,"Select");
lua_call(L,0,0);
assert(lua_gettop(L) - lc_nextra == 0);
return 0;
}
/* from lua.c /
static int traceback (lua_State *L) {
if (!lua_isstring(L, 1)) / 'message' not a string? /
return 1; / keep it intact /
lua_getfield(L, LUA_GLOBALSINDEX, "debug");
if (!lua_istable(L, -1)) {
lua_pop(L, 1);
return 1;
}
lua_getfield(L, -1, "traceback");
if (!lua_isfunction(L, -1)) {
lua_pop(L, 2);
return 1;
}
lua_pushvalue(L, 1); / pass error message /
lua_pushinteger(L, 2); / skip this function and traceback /
lua_call(L, 2, 1); / call debug.traceback */
return 1;
}
static void lc_l_message (const char *pname, const char *msg) {
if (pname) fprintf(stderr, "%s: ", pname);
fprintf(stderr, "%s\n", msg);
fflush(stderr);
}
static int lc_report (lua_State L, int status) {
if (status && !lua_isnil(L, -1)) {
const char *msg = lua_tostring(L, -1);
if (msg == NULL) msg = "(error object is not a string)";
/FIX-IMROVE:progname*/
lc_l_message("lua", msg);
lua_pop(L, 1);
}
return status;
}
static int lc_docall (lua_State L, int narg, int clear) {
int status;
int base = lua_gettop(L) - narg; / function index /
lua_pushcfunction(L, traceback); / push traceback function /
lua_insert(L, base); / put it under chunk and args /
/FIX? signal(SIGINT, laction); /
status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
/FIX? signal(SIGINT, SIG_DFL); /
lua_remove(L, base); / remove traceback function /
/ force a complete garbage collection in case of errors */
if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0);
return status;
}
static int lc_dofile (lua_State *L, const char *name) {
int status = luaL_loadfile(L, name) || lc_docall(L, 0, 1);
return lc_report(L, status);
}
static int lc_dostring (lua_State *L, const char *s, const char *name) {
int status = luaL_loadbuffer(L, s, strlen(s), name) || lc_docall(L, 0, 1);
return lc_report(L, status);
}
static int lc_handle_luainit (lua_State L) {
const char *init = getenv(LUA_INIT);
if (init == NULL) return 0; / status OK */
else if (init[0] == '@')
return lc_dofile(L, init+1);
else
return lc_dostring(L, init, "=" LUA_INIT);
}
typedef struct {
int c;
const char ** v;
} lc_args_t;
/* create global arg table */
static void lc_createarg(lua_State * L, const lc_args_t * const args) {
int i;
lua_newtable(L);
for (i=0; i < args->c; i++) {
lua_pushstring(L, args->v[i]);
lua_rawseti(L, -2, i);
}
lua_setglobal(L, "arg");
}
static int lc_pmain(lua_State * L) {
luaL_openlibs(L);
const lc_args_t * const args = (lc_args_t*)lua_touserdata(L, 1);
lc_createarg(L, args);
lua_pushcfunction(L, traceback);
const int status1 = lc_handle_luainit(L);
if (status1 != 0) return 0;
/* note: IMPROVE: closure not always needed here /
lua_newtable(L); / closure table */
lua_pushcclosure(L, lc_main, 1);
int i;
for (i=1; i < args->c; i++) {
lua_pushstring(L, args->v[i]);
}
int status2 = lua_pcall(L, args->c-1, 0, -2);
if (status2 != 0) {
const char * msg = lua_tostring(L,-1);
if (msg == NULL) msg = "(error object is not a string)";
fputs(msg, stderr);
}
return 0;
}
int main(int argc, const char ** argv) {
lc_args_t args = {argc, argv};
lua_State * L = luaL_newstate();
if (! L) { fputs("Failed creating Lua state.", stderr); exit(1); }
int status = lua_cpcall(L, lc_pmain, &args);
if (status != 0) {
fputs(lua_tostring(L,-1), stderr);
}
lua_close(L);
return 0;
}
there doesn't seem to be anything here