Annotation of parser3/src/main/compile_tools.h, revision 1.17
1.1 paf 1: /*
1.17 ! paf 2: $Id: compile_tools.h,v 1.16 2001/02/25 08:12:22 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.10 paf 10: #include "pa_vstring.h"
1.14 paf 11: #include "pa_request.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.15 paf 19: LS_SPEC_CODE,
1.1 paf 20: LS_VAR_NAME_SIMPLE,
21: LS_VAR_NAME_CURLY,
22: LS_VAR_ROUND,
23: LS_VAR_CURLY,
24: LS_METHOD_NAME,
25: LS_METHOD_ROUND,
26: LS_METHOD_CURLY,
27: LS_METHOD_AFTER
28: };
29: struct parse_control {
1.13 paf 30: // input
1.3 paf 31: Pool *pool;
1.14 paf 32: Request *request;
33: VClass *vclass;
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.16 paf 83: // String Literal // returns array with
1.3 paf 84: // first: OP_STRING instruction
85: // second op: string itself
1.16 paf 86: Array *SL(VString *vstring);
87: // Literal Array to(2) String // return string value from literal array OP+string array
88: String *SLA2S(Array *literal_string_array, int offset=0);
89:
90: // Class Literal // returns array with
91: // first: OP_CLASS instruction
92: // second op: vclass itself
93: Array *CL(VClass *vclass);
1.13 paf 94:
1.1 paf 95:
1.7 paf 96: void push_LS(struct parse_control *pc, lexical_state new_state);
1.3 paf 97: void pop_LS(struct parse_control *pc);
1.1 paf 98:
99: #endif
E-mail: