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