From f6282b30d363cdc02304a31526f18e3d00233d5d Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Wed, 28 Feb 2007 05:32:27 +0100 Subject: [PATCH] eval_parser evaluates the following programm fully (until --STOP) but returns MALA_START state --- std/std_statements.c | 17 +++++++++++++++++ std/std_statements.h | 1 + tests/30stdmodule.tests | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/std/std_statements.c b/std/std_statements.c index f6dab92..b0e130f 100644 --- a/std/std_statements.c +++ b/std/std_statements.c @@ -67,6 +67,10 @@ mala_actioninit std_statements[] = MALA_PARSER_MACRO("--IF", ("--IF-ELSE", "%1", "%2", "--BEGIN", "--PASS", "--END")), MALA_PARSER_SIMPLE("--STOP", mala_stop_parser), + + MALA_PARSER_SIMPLE("--EVAL", mala_eval_parser), + + /* MALA_PARSER("--", mala__parser, NULL, NULL, NULL), MALA_PARSER_BRIEF("--", ""), @@ -336,6 +340,19 @@ mala_sleep_parser (MalaProgram prg) return MALA_STATEMENT; } +mala_state +mala_eval_parser (MalaProgram prg) +{ + TRACE (mala_module_std); + if (mala_program_eval_arg (prg, 1, MALA_SUCCESS, NULL) > MALA_EFAULT) + return mala_program_commonexception (prg, MALA_STRING_ERROR); + + mala_program_action_done (prg, 0); + return MALA_START; +} + + + #if 0 int mala_defined_parser (MalaEngine eng, diff --git a/std/std_statements.h b/std/std_statements.h index 91741f6..1f15d88 100644 --- a/std/std_statements.h +++ b/std/std_statements.h @@ -32,6 +32,7 @@ MALA_PARSER_DEFINE(nono); MALA_PARSER_DEFINE(ifelse); MALA_PARSER_DEFINE(sleep); MALA_PARSER_DEFINE(stop); +MALA_PARSER_DEFINE(eval); //MALA_PARSER_DEFINE(defined); //MALA_PARSER_DEFINE(trace); //MALA_PARSER_DEFINE(gctrace); diff --git a/tests/30stdmodule.tests b/tests/30stdmodule.tests index 5eea19b..a7b0171 100644 --- a/tests/30stdmodule.tests +++ b/tests/30stdmodule.tests @@ -464,6 +464,14 @@ state: STATEMENT END +TEST "eval" --PRINT --EVAL --DEF foo evaluated --STOP finally foo <