engine is running, first parsers working
[mala.git] / std / std.c
blob56c1d500154f1797b73017d5059305ed1e0c2819
1 /*
2 std.c - MaLa standard parser module
4 Copyright (C) 2005, 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.
21 #include "mala.h"
22 #include "std.h"
25 int
26 mala_substitute_parser (MalaEngine eng,
27 MalaStringListNode_ref pptr,
28 void * data)
30 if (!mala_stringlist_after_new (&eng->program, *pptr, (MalaString) data))
31 goto ealloc_node;
33 mala_stringlist_elem_delete_fwd (&eng->program, pptr);
35 return eng->state;
37 ealloc_node:
38 return eng->state = MALA_EALLOC;
41 int
42 mala_expand_parser (MalaEngine eng,
43 MalaStringListNode_ref pptr,
44 void * data)
46 MalaStringListNode itr;
47 for (itr = mala_stringlist_tail ((MalaStringList) data);
48 !mala_stringlist_is_end ((MalaStringList) data, itr);
49 mala_stringlist_rev (&itr))
51 if (!mala_stringlist_after_new (&eng->program, *pptr, itr->string))
52 goto ealloc_node;
55 mala_stringlist_elem_delete_fwd (&eng->program, pptr);
57 return eng->state;
59 ealloc_node:
60 /*TODO*/
61 return eng->state = MALA_EALLOC;
64 int
65 mala_macro_parser (MalaEngine eng,
66 MalaStringListNode_ref pptr,
67 void * data)
69 (void) eng;
70 (void) pptr;
71 (void) data;
72 return MALA_ENOACTION;
75 int
76 mala_null_parser (MalaEngine eng,
77 MalaStringListNode_ref pptr,
78 void * data)
80 (void) data;
81 mala_stringlist_elem_delete_fwd (&eng->program, pptr);
82 return eng->state;
86 // Local Variables:
87 // mode: C
88 // c-file-style: "gnu"
89 // End:
90 // arch-tag: 687e1195-8aad-4425-983d-9767a25c3793
91 // end_of_file