diff options
author | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1993-12-17 16:41:19 -0200 |
---|---|---|
committer | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1993-12-17 16:41:19 -0200 |
commit | d443840846d1cba599dea822697b672c55903e5e (patch) | |
tree | bdbe260f5ac779dd822104f0cd179f07508dfe3b | |
parent | 69bee7a3d16169dcd06cd4a98ef012be0d0029f2 (diff) | |
download | lua-d443840846d1cba599dea822697b672c55903e5e.tar.gz lua-d443840846d1cba599dea822697b672c55903e5e.tar.bz2 lua-d443840846d1cba599dea822697b672c55903e5e.zip |
Linguagem para Usuarios de Aplicacao
-rw-r--r-- | lua.c | 41 |
1 files changed, 9 insertions, 32 deletions
@@ -1,54 +1,31 @@ | |||
1 | /* | 1 | /* |
2 | ** lua.c | 2 | ** lua.c |
3 | ** Linguagem para Usuarios de Aplicacao | 3 | ** Linguagem para Usuarios de Aplicacao |
4 | ** TeCGraf - PUC-Rio | ||
5 | ** 28 Apr 93 | ||
6 | */ | 4 | */ |
7 | 5 | ||
6 | char *rcs_lua="$Id: $"; | ||
7 | |||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | 9 | ||
10 | #include "lua.h" | 10 | #include "lua.h" |
11 | #include "lualib.h" | 11 | #include "lualib.h" |
12 | 12 | ||
13 | 13 | ||
14 | void test (void) | ||
15 | { | ||
16 | lua_pushobject(lua_getparam(1)); | ||
17 | lua_call ("c", 1); | ||
18 | } | ||
19 | |||
20 | |||
21 | static void callfunc (void) | ||
22 | { | ||
23 | lua_Object obj = lua_getparam (1); | ||
24 | if (lua_isstring(obj)) lua_call(lua_getstring(obj),0); | ||
25 | } | ||
26 | |||
27 | static void execstr (void) | ||
28 | { | ||
29 | lua_Object obj = lua_getparam (1); | ||
30 | if (lua_isstring(obj)) lua_dostring(lua_getstring(obj)); | ||
31 | } | ||
32 | |||
33 | void main (int argc, char *argv[]) | 14 | void main (int argc, char *argv[]) |
34 | { | 15 | { |
35 | int i; | 16 | int i; |
36 | if (argc < 2) | ||
37 | { | ||
38 | puts ("usage: lua filename [functionnames]"); | ||
39 | return; | ||
40 | } | ||
41 | lua_register ("callfunc", callfunc); | ||
42 | lua_register ("execstr", execstr); | ||
43 | lua_register ("test", test); | ||
44 | iolib_open (); | 17 | iolib_open (); |
45 | strlib_open (); | 18 | strlib_open (); |
46 | mathlib_open (); | 19 | mathlib_open (); |
47 | lua_dofile (argv[1]); | 20 | if (argc < 2) |
48 | for (i=2; i<argc; i++) | ||
49 | { | 21 | { |
50 | lua_call (argv[i],0); | 22 | char buffer[250]; |
23 | while (gets(buffer) != 0) | ||
24 | lua_dostring(buffer); | ||
51 | } | 25 | } |
26 | else | ||
27 | for (i=1; i<argc; i++) | ||
28 | lua_dofile (argv[i]); | ||
52 | } | 29 | } |
53 | 30 | ||
54 | 31 | ||