1 /* $NetBSD: min.c,v 1.1.1.2 2012/03/15 00:08:14 alnsn Exp $ */
4 * min.c -- a minimal Lua interpreter
5 * loads stdin only with minimal error handling.
6 * no interaction, and no standard library, only a "print" function.
14 static int print(lua_State
*L
)
20 if (i
>1) printf("\t");
21 if (lua_isstring(L
,i
))
22 printf("%s",lua_tostring(L
,i
));
23 else if (lua_isnil(L
,i
))
25 else if (lua_isboolean(L
,i
))
26 printf("%s",lua_toboolean(L
,i
) ? "true" : "false");
28 printf("%s:%p",luaL_typename(L
,i
),lua_topointer(L
,i
));
36 lua_State
*L
=lua_open();
37 lua_register(L
,"print",print
);
38 if (luaL_dofile(L
,NULL
)!=0) fprintf(stderr
,"%s\n",lua_tostring(L
,-1));