Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

evalx.c

Go to the documentation of this file.
00001 #include "evaltype.h"
00002 #include "eval.h"
00003 #include "lex.h"
00004 
00005 extern int yyparse(eval_scalar *result);
00006         
00007 int eval(eval_scalar *r, const char *str, eval_func_handler func_handler, eval_symbol_handler symbol_handler, void *context)
00008 {
00009         void *oldbuffer = lex_current_buffer();
00010         void *strbuffer;
00011         eval_scalar result;
00012 /*     if (get_helpmode()) {
00013                 eval_scalar *hs = get_helpstring();
00014                 scalar_create_str_c(hs, "");
00015                 strbuffer = lex_scan_string_buffer("NaF()");
00016         } else {*/
00017                 strbuffer = lex_scan_string_buffer(str);
00018 /*     }*/
00019 
00020         DEBUG_DUMP("evaluating \"%s\":", str);
00021         DEBUG_DUMP_INDENT_IN;
00022         
00023         clear_eval_error();
00024         
00025         eval_set_context(context);
00026         eval_set_func_handler(func_handler);
00027         eval_set_symbol_handler(symbol_handler);
00028 
00029         result.type=SCALAR_NULL;
00030         yyparse(&result);
00031         
00032         lex_delete_buffer(strbuffer);
00033         if (oldbuffer) lex_switch_buffer(oldbuffer);
00034         
00035 /*     if (get_helpmode()) {
00036                 eval_scalar *hs = get_helpstring();
00037                 *r = *hs;
00038                 hs->type = SCALAR_NULL;
00039                 clear_eval_error();
00040         } else {*/
00041                 if (result.type == SCALAR_NULL) return 0;
00042                 *r = result;
00043                 if (get_eval_error(0, 0)) return 0;
00044 /*      }*/
00045         
00046         DEBUG_DUMP_INDENT_OUT;
00047         DEBUG_DUMP_SCALAR(r, "eval result:");
00048 
00049         return 1;
00050 }

Generated on Fri May 7 21:15:30 2004 by doxygen 1.3.5