Annotation of parser3/src/main/compile_tools.C, revision 1.5
1.1 paf 1: /*
1.5 ! paf 2: $Id: compile_tools.C,v 1.4 2001/02/21 11:13:16 paf Exp $
1.1 paf 3: */
4:
5: #include "compile_tools.h"
6: #include "pa_string.h"
7: #include "pa_array.h"
8: #include "pa_exception.h"
9:
1.3 paf 10: Array *L(String *string) {
1.1 paf 11: // empty ops array
1.4 paf 12: Array *result=N(string->pool());
1.1 paf 13:
14: // append OP_STRING
1.3 paf 15: Operation op; op.code=OP_STRING;
16: *result+=reinterpret_cast<Array::Item *>(op.cast);
1.1 paf 17:
18: // append 'string'
1.3 paf 19: *result+=string;
1.1 paf 20:
21: return result;
22: }
23:
1.5 ! paf 24: String *LA2S(Array *literal_string_array, int offset) {
! 25: return static_cast<String *>(literal_string_array->get(offset+1));
1.1 paf 26: }
27:
28:
1.5 ! paf 29: void push_LS(struct parse_control *pc, lexical_state new_state) {
1.1 paf 30: if(pc->sp<MAX_LEXICAL_STATES) {
1.5 ! paf 31: pc->stack[pc->sp++]=pc->ls; pc->ls=new_state;
1.1 paf 32: } else
33: (static_cast<Pool *>(pc->pool))->exception().raise(0, 0, 0,
34: "push_LS: stack overflow");
35: }
36: void pop_LS(struct parse_control *pc) {
37: if(--pc->sp>=0)
38: pc->ls=pc->stack[pc->sp];
39: else
40: (static_cast<Pool *>(pc->pool))->exception().raise(0, 0, 0,
41: "push_LS: stack underflow");
42: }
E-mail: