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