if_parser fix
[mala.git] / program / mala.c
blob1fbe5c114df4db9609f4ff39461eafb854cf4861
1 /*
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.
19 #include <assert.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include "mala.h"
23 #include "std.h"
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")),
31 MALA_ACTIONS_END
34 int
35 main(int argc, char * argv[])
37 int ret;
38 MalaEngine my_engine;
40 my_engine = mala_engine_new ();
41 mala_module_std_init (my_engine);
42 mala_engine_actions_register (my_engine, my_actions);
43 mala_engine_ppexpand_define (my_engine, "--COMMANDLINE", argc - 1, argv + 1);
44 mala_engine_pushback_word (my_engine, "--COMMANDLINE");
45 mala_engine_run (my_engine);
46 if (my_engine->trace)
48 fprintf (stderr, "%-8s:\n", mala_engine_state_str (my_engine));
50 ret = mala_engine_state_get (my_engine);
51 if (ret > MALA_EFAULT)
53 mala_engine_dumpprogram (my_engine, stderr, "", " ");
54 putc ('\n', stderr);
56 else if (! mala_stringlist_is_empty (&my_engine->arguments))
58 mala_engine_dumpargs (my_engine, stdout, "", " ");
59 putc ('\n', stdout);
61 mala_engine_free (my_engine);
62 return ret == MALA_CONTINUE ? 0 : ret;
68 // Local Variables:
69 // mode: C
70 // c-file-style: "gnu"
71 // End:
72 // arch-tag: 0aebb81a-80ba-46d5-9738-4af8f3ceffc9
73 // end_of_file