simplifications
[mala.git] / std / std_init.c
blob3dbf39950ef2cd914a8cb0cfde18299e1cb4e552
1 /*
2 std_init.c - MaLa standard module initialization table
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.
20 #include <stdio.h>
21 #include <string.h>
23 #include "mala.h"
24 #include "std.h"
26 static
27 mala_actioninit std_actions[] =
30 MALA_PARSER("--", mala__parser, NULL, NULL, NULL),
31 MALA_PARSER_BRIEF("--", ""),
32 // MALA_PARSER_HELP("--", ("TODO")),
33 MALA_PARSER_SIGNATURE_TYPE("--", ("")),
34 MALA_PARSER_SIGNATURE_USAGE("--", ("")),
35 MALA_PARSER_RESULT_TYPE("--", ("")),
36 MALA_PARSER_RESULT_USAGE("--", ("")),
39 MALA_PARSER("--CHILDOF", mala__parser, NULL, NULL, NULL),
40 MALA_PARSER_BRIEF("--", ""),
41 // MALA_PARSER_HELP("--", ("TODO")),
42 MALA_PARSER_SIGNATURE_TYPE("--", ("")),
43 MALA_PARSER_SIGNATURE_USAGE("--", ("")),
44 MALA_PARSER_RESULT_TYPE("--", ("")),
45 MALA_PARSER_RESULT_USAGE("--", ("")),
47 MALA_PARSER("--FOREACH-WORD", mala_foreach_word_parser, NULL, NULL, NULL),
48 MALA_PARSER_BRIEF("--", ""),
49 // MALA_PARSER_HELP("--", ("TODO")),
50 MALA_PARSER_SIGNATURE_TYPE("--", ("")),
51 MALA_PARSER_SIGNATURE_USAGE("--", ("")),
52 MALA_PARSER_RESULT_TYPE("--", ("")),
53 MALA_PARSER_RESULT_USAGE("--", ("")),
56 MALA_SUBSTITUTE_PARSER("--MALA-VERSION","MaLa 0.2 ("__DATE__" "__TIME__")"),
57 MALA_PARSER_BRIEF("--MALA-VERSION", "Holds the version"),
58 //MALA_PARSER_HELP("--FOREACH-WORD", ("")),
60 MALA_PARSER("--FOREACH-WORD", mala_foreach_word_parser, NULL, NULL, NULL),
61 MALA_PARSER_BRIEF("--FOREACH-WORD", "applies an action to each word of a macro/expansion"),
62 // MALA_PARSER_HELP("--FOREACH-WORD", ("TODO")),
63 MALA_PARSER_SIGNATURE_TYPE("--FOREACH-WORD", ("DEFINED-ACTION", "MACRO")),
64 MALA_PARSER_SIGNATURE_USAGE("--FOREACH-WORD", ("Action to be applied",
65 "Macro consists of words on which the action"
66 " should be appied")),
67 MALA_PARSER_RESULT_TYPE("--FOREACH-WORD", ("SEQUENCE")),
68 MALA_PARSER_RESULT_USAGE("--FOREACH-WORD", ("Expansion which applies the Action to the macro")),
70 MALA_PARSER("--DEF", mala_macrodef_parser, NULL, NULL, NULL),
71 MALA_PARSER_BRIEF("--DEF", "defines a new macro"),
72 // MALA_PARSER_HELP("--DEF", ("TODO")),
73 MALA_PARSER_SIGNATURE_TYPE("--DEF", ("ACTION", "WORD-OR-BLOCK")),
74 MALA_PARSER_SIGNATURE_USAGE("--DEF", ("Word to be defined",
75 "Definition as word, or block with optional"
76 " %-expansions")),
77 MALA_PARSER_RESULT_TYPE("--DEF", ("VOID")),
79 MALA_PARSER("--END", mala_end_parser, NULL, NULL, NULL),
80 MALA_PARSER_BRIEF("--END", "closes a block"),
81 // MALA_PARSER_HELP("--END", ("TODO")),
82 MALA_PARSER_SIGNATURE_TYPE("--END", ("VOID")),
83 MALA_PARSER_RESULT_TYPE("--END", ("ERROR")),
84 MALA_PARSER_RESULT_USAGE("--END", ("an --END without a matching --BEGIN raises an error")),
86 MALA_PARSER("--EXCEPTION", mala_exception_parser, NULL, NULL, NULL),
87 MALA_PARSER_BRIEF("--EXCEPTION", "defines a new macro"),
88 // MALA_PARSER_HELP("--EXCEPTION", ("TODO")),
89 // MALA_PARSER_SIGNATURE_TYPE("--", ("")),
90 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
91 // MALA_PARSER_RESULT_TYPE("--", ("")),
92 // MALA_PARSER_RESULT_USAGE("--", ("")),
94 MALA_PARSER("--DEL", mala_macrodelete_parser, NULL, NULL, NULL),
95 MALA_PARSER_BRIEF("--DEL", "delete a macro"),
96 // MALA_PARSER_HELP("--DEL", ("TODO")),
97 // MALA_PARSER_SIGNATURE_TYPE("--", ("")),
98 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
99 // MALA_PARSER_RESULT_TYPE("--", ("")),
100 // MALA_PARSER_RESULT_USAGE("--", ("")),
102 MALA_PARSER("--BEGIN", mala_begin_parser, NULL, NULL, NULL),
103 MALA_PARSER_BRIEF("--BEGIN", "starts a block of code"),
104 // MALA_PARSER_HELP("--BEGIN", ("TODO")),
105 MALA_PARSER_SIGNATURE_TYPE("--BEGIN", ("WORDS","END")),
106 MALA_PARSER_RESULT_TYPE("--BEGIN", ("BLOCK")),
107 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
108 // MALA_PARSER_RESULT_USAGE("--", ("")),
110 MALA_PARSER("--NOT", mala_not_parser, NULL, NULL, NULL),
111 MALA_PARSER_BRIEF("--NOT", "negates logic"),
112 // MALA_PARSER_HELP("--NOT", ("TODO")),
113 // MALA_PARSER_SIGNATURE_TYPE("--", ("")),
114 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
115 // MALA_PARSER_RESULT_TYPE("--", ("")),
116 // MALA_PARSER_RESULT_USAGE("--", ("")),
118 MALA_PARSER("--LITERAL", mala_literal_parser, NULL, NULL, NULL),
119 MALA_PARSER_BRIEF("--LITERAL", "Treats the next word literally"),
120 // MALA_PARSER_HELP("--LITERAL", ("TODO")),
121 // MALA_PARSER_SIGNATURE_TYPE("--", ("")),
122 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
123 // MALA_PARSER_RESULT_TYPE("--", ("")),
124 // MALA_PARSER_RESULT_USAGE("--", ("")),
126 MALA_SUBSTITUTE_PARSER("--DEFAULT-PARSER","--LITERAL"),
127 MALA_PARSER_BRIEF("--DEFAULT-PARSER", "is used for any word which has no associated action"),
128 // MALA_PARSER_HELP("--DEFAULT-PARSER", ("TODO")),
129 // MALA_PARSER_SIGNATURE_TYPE("--", ("")),
130 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
131 // MALA_PARSER_RESULT_TYPE("--", ("")),
132 // MALA_PARSER_RESULT_USAGE("--", ("")),
134 MALA_PARSER("--NL", mala_newline_parser, NULL, NULL, NULL),
135 MALA_PARSER_BRIEF("--NL", "prints a newline"),
136 // MALA_PARSER_HELP("--NL", ("TODO")),
137 MALA_PARSER_RESULT_USAGE("--NL", ("")),
139 MALA_MACRO_PARSER("--PRINTL",("--PRINT", "--LITERAL", "%1", "--NL")),
140 MALA_PARSER_BRIEF("--PRINTL", "prints a textline to stdout"),
141 // MALA_PARSER_HELP("--PRINTL", ("TODO")),
142 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
143 // MALA_PARSER_RESULT_USAGE("--", ("")),
144 MALA_PARSER_SIGNATURE_TYPE("--PRINTL", ("WORD-OR-BLOCK")),
145 MALA_PARSER_RESULT_TYPE("--PRINTL", ("VOID")),
147 MALA_PARSER("--PRINT", mala_print_parser, NULL, NULL, NULL),
148 MALA_PARSER_BRIEF("--PRINT", "prints to stdout"),
149 // MALA_PARSER_HELP("--PRINT", ("TODO")),
150 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
151 // MALA_PARSER_RESULT_USAGE("--", ("")),
152 MALA_PARSER_SIGNATURE_TYPE("--PRINT", ("WORD-OR-BLOCK")),
153 MALA_PARSER_RESULT_TYPE("--PRINT", ("VOID")),
155 MALA_PARSER("--PRINTWRAPED",mala_printwraped_parser, NULL, NULL, NULL),
156 MALA_PARSER_BRIEF("--PRINTWRAPED", "prints a formatted block of text"),
157 MALA_PARSER_HELP("--PRINTWRAPED", ("Wraps some text to fit nicely on the screen. Tabulators become aligned.")),
158 MALA_PARSER_SIGNATURE_USAGE("--PRINTWRAPED",
159 ("Columns available on the screen",
160 "Lines available on the screen",
161 "Indent of the block in characters",
162 "Tabwidth to be used",
163 "Text to be printed")),
164 // //MALA_PARSER_RESULT_USAGE("--PRINTWRAPED", ("TODO")),
165 MALA_PARSER_SIGNATURE_TYPE("--PRINTWRAPED",
166 ("COLUMNS",
167 "LINES",
168 "INDENT",
169 "TABWIDTH",
170 "TEXT")),
172 //MALA_PARSER_RESULT_TYPE("--PRINTWRAPED", ("VOID")),
174 MALA_NULL_PARSER("--NULL"),
175 MALA_PARSER_BRIEF("--NULL","does nothing"),
176 MALA_PARSER_HELP("--NULL",("--HELP-ACTION","blah")),
177 // MALA_PARSER_SIGNATURE_TYPE("--", ("")),
178 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
179 // MALA_PARSER_RESULT_TYPE("--", ("")),
180 // MALA_PARSER_RESULT_USAGE("--", ("")),
182 MALA_TRUE_PARSER("--FLAG-NUMSPLIT-EXPANSION"),
183 // MALA_PARSER_BRIEF("--FLAG-NUMSPLIT-EXPANSION", "TODO"),
184 // MALA_PARSER_HELP("--FLAG-NUMSPLIT-EXPANSION", ("TODO")),
186 MALA_TRUE_PARSER("--FLAG-LITERAL-EXPANSION"),
187 MALA_PARSER_BRIEF("--FLAG-LITERAL-EXPANSION",
188 "words beginning with a single backquote will be "
189 "preprocessed as '--LITERAL' 'theword'"),
190 // MALA_PARSER_HELP("--FLAG-LITERAL-EXPANSION", ("TODO")),
192 MALA_TRUE_PARSER("--FLAG-EXCLAM-EXPANSION"),
193 MALA_PARSER_BRIEF("--FLAG-EXCLAM-EXPANSION",
194 "a single ! will be preprocessed as --NOT"),
195 // MALA_PARSER_HELP("--FLAG-EXCLAM-EXPANSION", ("TODO")),
197 MALA_TRUE_PARSER("--FLAG-NO-EXPANSION"),
198 // MALA_PARSER_BRIEF("--", ""),
199 //// MALA_PARSER_HELP("--", ("TODO")),
201 MALA_TRUE_PARSER("--FLAG-ASSIGN-EXPANSION"),
202 // MALA_PARSER_BRIEF("--", ""),
203 //// MALA_PARSER_HELP("--", ("TODO")),
205 MALA_TRUE_PARSER("--FLAG-ENVVAR-EXPANSION"),
206 // MALA_PARSER_BRIEF("--", ""),
207 //// MALA_PARSER_HELP("--", ("TODO")),
209 MALA_TRUE_PARSER("--FLAG-CHAR-EXPANSION"),
210 // MALA_PARSER_BRIEF("--", ""),
211 //// MALA_PARSER_HELP("--", ("TODO")),
213 MALA_TRUE_PARSER("--FLAG-UNDERSCORE-EXPANSION"),
214 // MALA_PARSER_BRIEF("--", ""),
215 //// MALA_PARSER_HELP("--", ("TODO")),
217 MALA_TRUE_PARSER("--FLAG-SETENV-EXPANSION"),
218 // MALA_PARSER_BRIEF("--", ""),
219 //// MALA_PARSER_HELP("--", ("TODO")),
221 MALA_TRUE_PARSER("--FLAG-BRACKET-EXPANSION"),
222 // MALA_PARSER_BRIEF("--", ""),
223 //// MALA_PARSER_HELP("--", ("TODO")),
225 MALA_TRUE_PARSER("--FLAG-ASSIGN-CONTRACTION"),
226 // MALA_PARSER_BRIEF("--", ""),
227 //// MALA_PARSER_HELP("--", ("TODO")),
229 MALA_SUBSTITUTE_PARSER("--BRIEF-ACTION","--PRINTL"),
230 // MALA_PARSER_BRIEF("--", ""),
231 //// MALA_PARSER_HELP("--", ("TODO")),
232 // MALA_PARSER_SIGNATURE_TYPE("--", ("")),
233 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
234 // MALA_PARSER_RESULT_TYPE("--", ("")),
235 // MALA_PARSER_RESULT_USAGE("--", ("")),
237 MALA_SUBSTITUTE_PARSER("--HELP-ACTION","--PRINTL"),
238 // MALA_PARSER_BRIEF("--", ""),
239 //// MALA_PARSER_HELP("--", ("TODO")),
240 // MALA_PARSER_SIGNATURE_TYPE("--", ("")),
241 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
242 // MALA_PARSER_RESULT_TYPE("--", ("")),
243 // MALA_PARSER_RESULT_USAGE("--", ("")),
246 // TODO to strings module
247 MALA_MACRO_PARSER("--CAT",("%1%2")),
248 MALA_PARSER_BRIEF("--CAT", "concatenates two words"),
249 // MALA_PARSER_HELP("--CAT", ("TODO")),
250 // MALA_PARSER_SIGNATURE_TYPE("--", ("")),
251 // MALA_PARSER_SIGNATURE_USAGE("--", ("")),
252 // MALA_PARSER_RESULT_TYPE("--", ("")),
253 // MALA_PARSER_RESULT_USAGE("--", ("")),
255 // TODO remove this
256 MALA_EXPAND_PARSER("TESTLIST",("TEST","LIST")),
259 MALA_ACTIONS_END
264 mala_module_std_init (MalaEngine self)
266 mala_module_std_types_init (self);
267 mala_module_std_help_init (self);
268 mala_engine_actions_register (self, std_actions);
269 return self->state;
274 // Local Variables:
275 // mode: C
276 // c-file-style: "gnu"
277 // End:
278 // arch-tag: e6d43941-2533-4f28-863e-2dd3128e58bb
279 // end_of_file