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

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

E-mail: