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

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

E-mail: