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