From 5b47a70be6f8577a503950b5ea346826c07affc5 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Sat, 11 Jun 2005 14:04:15 +0000 Subject: [PATCH] exception_parser git-archimport-id: chth@gmx.net--2004/mala-glibc--devel--0.2--patch-69 --- ChangeLog | 12 ++++++++++++ std/std.c | 34 ++++++++++++++++++++++++++++++++++ std/std.h | 5 +++++ 3 files changed, 51 insertions(+) diff --git a/ChangeLog b/ChangeLog index fc77765..6543822 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,18 @@ # arch-tag: automatic-ChangeLog--chth@gmx.net--2004/mala-glibc--devel--0.2 # +2005-06-11 14:04:15 GMT Christian Thaeter patch-69 + + Summary: + exception_parser + Revision: + mala-glibc--devel--0.2--patch-69 + + + modified files: + ChangeLog std/std.c std/std.h + + 2005-06-11 14:04:01 GMT Christian Thaeter patch-68 Summary: diff --git a/std/std.c b/std/std.c index 54c754a..46c776e 100644 --- a/std/std.c +++ b/std/std.c @@ -45,6 +45,10 @@ static mala_actioninit std_actions[] = */ + MALA_PARSER("--EXCEPTION", mala_exception_parser, NULL, NULL, NULL), + MALA_PARSER_BRIEF("--EXCEPTION", "defines a new macro"), + MALA_PARSER_HELP("--EXCEPTION", ("--HELP-ACTION", "TODO")), + MALA_PARSER("--DEL", mala_macrodelete_parser, NULL, NULL, NULL), MALA_PARSER_BRIEF("--DEL", "delete a macro"), MALA_PARSER_HELP("--DEL", ("--HELP-ACTION", "TODO")), @@ -383,6 +387,36 @@ mala_macrodelete_parser (MalaEngine eng, return MALA_SUCCESS; } +int +mala_exception_parser (MalaEngine eng, + MalaStringListNode_ref pptr, + void * data) +{ + (void) data; + + mala_engine_try_eval_arg_n (eng, pptr, 1); + + if (mala_stringlist_is_tail (&eng->program, *pptr)) + return mala_engine_exception (eng, pptr, *pptr, + eng->common_string[MALA_STRING_ERROR_MISSING_ARGUMENT]); + + if (eng->state > MALA_EFAULT) + return eng->state; + + MalaString ex = mala_string_new_print (&eng->words, "--ERROR-%s", + mala_string_cstr (mala_stringlist_next (*pptr)->string)); + + mala_stringlist_elem_delete_fwd (&eng->program, pptr); + int state = mala_engine_exception (eng, pptr, *pptr, ex); + mala_stringlist_elem_delete (&eng->program, mala_stringlist_next (*pptr)); + + mala_string_free (ex); + + return state; + + //return MALA_SUCCESS; +} + /* // Local Variables: diff --git a/std/std.h b/std/std.h index f3e4930..bc124e6 100644 --- a/std/std.h +++ b/std/std.h @@ -115,6 +115,11 @@ mala_macrodelete_parser (MalaEngine eng, MalaStringListNode_ref pptr, void * data); +int +mala_exception_parser (MalaEngine eng, + MalaStringListNode_ref pptr, + void * data); + #endif /* MALA_STD_H */ -- 2.11.4.GIT