Annotation of parser3/src/main/compile_tools.h, revision 1.7

1.1       paf         1: /*
1.7     ! paf         2:   $Id: compile_tools.h,v 1.6 2001/02/21 11:13:16 paf Exp $
1.1       paf         3: */
                      4: 
                      5: #ifndef COMPILE_TOOLS
                      6: #define COMPILE_TOOLS
                      7: 
                      8: #include "code.h"
                      9: #include "pa_types.h"
1.6       paf        10: #include "pa_pool.h"
                     11: #include "pa_array.h"
1.1       paf        12: 
                     13: enum lexical_state {
                     14:        LS_USER,
1.7     ! paf        15:        LS_DEF_NAME,
        !            16:        LS_DEF_PARAMS,
        !            17:        LS_DEF_LOCALS,
        !            18:        LS_DEF_COMMENT,
1.1       paf        19:        LS_VAR_NAME_SIMPLE,
                     20:        LS_VAR_NAME_CURLY,
                     21:        LS_VAR_ROUND,
                     22:        LS_VAR_CURLY,
                     23:        LS_METHOD_NAME,
                     24:        LS_METHOD_ROUND,
                     25:        LS_METHOD_CURLY,
                     26:        LS_METHOD_AFTER
                     27: };
                     28: struct parse_control {
                     29:        /* input */
1.3       paf        30:        Pool *pool;
1.6       paf        31:        Array *methods;
1.1       paf        32: #ifndef NO_CSTRING_ORIGIN
                     33:        char *source;
                     34:        char *file;
1.4       paf        35:        int line, col;
1.1       paf        36: #endif
                     37:        /* state */
                     38:        int pending_state/*=0*/;
1.3       paf        39:        String *string/*=new(pool) String(pool)*/;
1.1       paf        40:        
                     41: #define MAX_LEXICAL_STATES 100
                     42:        enum lexical_state ls/*=LS_USER*/;
                     43:        int sp/*=0*/;
                     44:        enum lexical_state stack[MAX_LEXICAL_STATES];
                     45:        int brackets_nestages[MAX_LEXICAL_STATES];
                     46:        
1.6       paf        47:        /* output: filled input 'methods' and 'error' if any */
1.5       paf        48:        char error[MAX_STRING];
1.1       paf        49: };
                     50: 
1.3       paf        51: /* New array // return empty array */
1.6       paf        52: inline Array/*<op>*/ *N(Pool& pool) {
                     53:        return new(pool) Array/*<op>*/(pool);
1.3       paf        54: }
                     55: 
                     56: /* Assembler instruction // append ordinary instruction to ops */
                     57: inline void OP(Array/*<op>*/ *result, enum OPCODE code) {
                     58:        Operation op; op.code=code;
                     59:        *result+=op.cast;
                     60: }
                     61: 
                     62: /* Argument String // append String to ops*/
                     63: inline void AS(Array/*<op>*/ *result, String *string) {
                     64:        *result+=string;
                     65: }
                     66: /* Argument Array // append Array to ops */
                     67: inline void AA(Array/*<op>*/ *result, Array/*<op>*/ *array) {
                     68:        *result+=array;
                     69: }
                     70: /* Argument Eval_expression // append eval_expression to ops */
                     71: inline void AE(Array/*<op>*/ *result, char *eval_expression) {
                     72:        *result+=eval_expression;
                     73: }
                     74: 
                     75: inline void P(Array/*<op>*/ *result, Array *code_array) {
                     76:        result->append_array(*code_array);
                     77: }
1.1       paf        78: 
                     79: 
1.3       paf        80: /* Literal // returns array with 
                     81: // first: OP_STRING instruction
                     82: // second op: string itself
                     83: */
                     84: Array *L(String *string);
                     85: /* Literal Array to(2) String // return string value from literal array OP+string array */
1.7     ! paf        86: String *LA2S(Array *literal_string_array, int offset=0);
1.1       paf        87: 
                     88: 
1.7     ! paf        89: void push_LS(struct parse_control *pc, lexical_state new_state);
1.3       paf        90: void pop_LS(struct parse_control *pc);
1.1       paf        91: 
                     92: #endif

E-mail: