Annotation of parser3/src/main/compile_tools.h, revision 1.8
1.1 paf 1: /*
1.8 ! paf 2: $Id: compile_tools.h,v 1.7 2001/02/21 15:00:02 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.8 ! paf 12: #include "pa_value.h"
1.1 paf 13:
14: enum lexical_state {
15: LS_USER,
1.7 paf 16: LS_DEF_NAME,
17: LS_DEF_PARAMS,
18: LS_DEF_LOCALS,
19: LS_DEF_COMMENT,
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 {
30: /* input */
1.3 paf 31: Pool *pool;
1.6 paf 32: Array *methods;
1.1 paf 33: #ifndef NO_CSTRING_ORIGIN
34: char *source;
35: char *file;
1.4 paf 36: int line, col;
1.1 paf 37: #endif
38: /* state */
39: int pending_state/*=0*/;
1.3 paf 40: String *string/*=new(pool) String(pool)*/;
1.1 paf 41:
42: #define MAX_LEXICAL_STATES 100
43: enum lexical_state ls/*=LS_USER*/;
44: int sp/*=0*/;
45: enum lexical_state stack[MAX_LEXICAL_STATES];
46: int brackets_nestages[MAX_LEXICAL_STATES];
47:
1.6 paf 48: /* output: filled input 'methods' and 'error' if any */
1.5 paf 49: char error[MAX_STRING];
1.1 paf 50: };
51:
1.3 paf 52: /* New array // return empty array */
1.6 paf 53: inline Array/*<op>*/ *N(Pool& pool) {
54: return new(pool) Array/*<op>*/(pool);
1.3 paf 55: }
56:
57: /* Assembler instruction // append ordinary instruction to ops */
58: inline void OP(Array/*<op>*/ *result, enum OPCODE code) {
59: Operation op; op.code=code;
60: *result+=op.cast;
61: }
62:
63: /* Argument String // append String to ops*/
64: inline void AS(Array/*<op>*/ *result, String *string) {
65: *result+=string;
66: }
67: /* Argument Array // append Array to ops */
68: inline void AA(Array/*<op>*/ *result, Array/*<op>*/ *array) {
69: *result+=array;
70: }
71: /* Argument Eval_expression // append eval_expression to ops */
72: inline void AE(Array/*<op>*/ *result, char *eval_expression) {
73: *result+=eval_expression;
74: }
75:
76: inline void P(Array/*<op>*/ *result, Array *code_array) {
77: result->append_array(*code_array);
78: }
1.1 paf 79:
80:
1.3 paf 81: /* Literal // returns array with
82: // first: OP_STRING instruction
83: // second op: string itself
84: */
85: Array *L(String *string);
86: /* Literal Array to(2) String // return string value from literal array OP+string array */
1.7 paf 87: String *LA2S(Array *literal_string_array, int offset=0);
1.8 ! paf 88: /* Literal Array String2VString fix // return literal array with string changed to VString */
! 89: Array *LAS2LAVS(Array *literal_array);
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: