--- parser3/src/main/compile_tools.h 2001/02/20 19:21:13 1.2 +++ parser3/src/main/compile_tools.h 2001/02/21 11:13:16 1.6 @@ -1,5 +1,5 @@ /* - $Id: compile_tools.h,v 1.2 2001/02/20 19:21:13 paf Exp $ + $Id: compile_tools.h,v 1.6 2001/02/21 11:13:16 paf Exp $ */ #ifndef COMPILE_TOOLS @@ -7,6 +7,8 @@ #include "code.h" #include "pa_types.h" +#include "pa_pool.h" +#include "pa_array.h" enum lexical_state { LS_USER, @@ -21,15 +23,16 @@ enum lexical_state { }; struct parse_control { /* input */ - void *pool; + Pool *pool; + Array *methods; #ifndef NO_CSTRING_ORIGIN char *source; char *file; - int line; + int line, col; #endif /* state */ int pending_state/*=0*/; - void *string/*=string_create(...)*/; + String *string/*=new(pool) String(pool)*/; #define MAX_LEXICAL_STATES 100 enum lexical_state ls/*=LS_USER*/; @@ -37,56 +40,49 @@ struct parse_control { enum lexical_state stack[MAX_LEXICAL_STATES]; int brackets_nestages[MAX_LEXICAL_STATES]; - /* output: Array * */ - void *result; + /* output: filled input 'methods' and 'error' if any */ + char error[MAX_STRING]; }; -#ifdef __cplusplus -extern "C" { -#endif - /* New array // return empty array */ - void *N(void *apool); - - /* Assembler instruction // append ordinary instruction to result */ - void A(void **result, enum OPCODE acode); - - /* Assembler arGument // append instruction; append param */ - void G(void **result, void *param); +/* New array // return empty array */ +inline Array/**/ *N(Pool& pool) { + return new(pool) Array/**/(pool); +} - /* Literal // returns array with - // first: OP_STRING instruction - // second op: string itself - */ - void *L(void *astring); - /* Literal String // return string value from literal array OP+string array */ - void *LS(void *literal); - - /* aPpend code array // append code_array to result */ - void P(void **result, void *code_array); - - - void push_LS(struct parse_control *pc); - void pop_LS(struct parse_control *pc); - - void *string_create(void *pool); - -#ifndef NO_STRING_ORIGIN -# define CSTRING_APPEND_PARAMS void *astring, char *piece, size_t size, char *file, uint line -# define CSTRING_APPEND(astring, piece, size, file, line) real_cstring_append(astring, piece, size, file, line) -#else -# define CSTRING_APPEND_PARAMS void *astring, char *piece, size_t size -# define CSTRING_APPEND(astring, piece, size, file, line) real_cstring_append(astring, piece, size) -#endif - void real_cstring_append(CSTRING_APPEND_PARAMS); - char *string_cstr(void *astring); +/* Assembler instruction // append ordinary instruction to ops */ +inline void OP(Array/**/ *result, enum OPCODE code) { + Operation op; op.code=code; + *result+=op.cast; +} - void exception(void *pool, - void *atype, void *acode, - void *aproblem_source, - char *acomment); +/* Argument String // append String to ops*/ +inline void AS(Array/**/ *result, String *string) { + *result+=string; +} +/* Argument Array // append Array to ops */ +inline void AA(Array/**/ *result, Array/**/ *array) { + *result+=array; +} +/* Argument Eval_expression // append eval_expression to ops */ +inline void AE(Array/**/ *result, char *eval_expression) { + *result+=eval_expression; +} -#ifdef __cplusplus +inline void P(Array/**/ *result, Array *code_array) { + result->append_array(*code_array); } -#endif + + +/* Literal // returns array with +// first: OP_STRING instruction +// second op: string itself +*/ +Array *L(String *string); +/* Literal Array to(2) String // return string value from literal array OP+string array */ +const String *LA2S(Array *literal_string_array); + + +void push_LS(struct parse_control *pc); +void pop_LS(struct parse_control *pc); #endif