2 mala.c - standalone MaLa interpreter
4 Copyright (C) 2004, Christian Thaeter <chth@gmx.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, contact me.
25 mala_actioninit my_actions
[] =
27 MALA_SUBSTITUTE_PARSER("--MALA-VERSION","MaLa 0.2 ("__DATE__
" "__TIME__
")"),
28 MALA_SUBSTITUTE_PARSER("-V","--version"),
29 MALA_EXPAND_PARSER("--version",("--PRINTL", "--MALA-VERSION")),
35 main(int argc
, char * argv
[])
40 my_engine
= mala_engine_new ();
41 if (getenv ("MALA_GCTRACE"))
42 *my_engine
->gc_trace
= MALA_TRACE
;
43 if (getenv ("MALA_TRACE"))
44 my_engine
->engine_trace
= MALA_TRACE
;
45 mala_module_std_init (my_engine
);
46 mala_engine_actions_register (my_engine
, my_actions
);
47 mala_engine_ppexpand_define (my_engine
, "--COMMANDLINE", argc
- 1, argv
+ 1);
48 mala_engine_pushback_word (my_engine
, "--COMMANDLINE");
49 mala_engine_run (my_engine
);
50 if (my_engine
->engine_trace
)
52 fprintf (stderr
, "%-8s:\n", mala_engine_state_str (my_engine
));
54 ret
= mala_engine_state_get (my_engine
);
55 if (ret
> MALA_EFAULT
)
57 mala_engine_dumpprogram (my_engine
, stderr
, "", " ");
60 else if (! mala_stringlist_is_empty (&my_engine
->arguments
))
62 mala_engine_dumpargs (my_engine
, stdout
, "", " ");
65 mala_engine_free (my_engine
);
66 return ret
== MALA_CONTINUE
? 0 : ret
;
74 // c-file-style: "gnu"
76 // arch-tag: 0aebb81a-80ba-46d5-9738-4af8f3ceffc9