Annotation of parser3/src/main/compile_tools.C, revision 1.11
1.1 paf 1: /*
1.11 ! paf 2: $Id: compile_tools.C,v 1.10 2001/02/22 14:45:27 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"
1.9 paf 9: #include "pa_vstring.h"
1.1 paf 10:
1.9 paf 11: Array *L(VString *vstring) {
1.1 paf 12: // empty ops array
1.9 paf 13: Array *result=N(vstring->pool());
1.1 paf 14:
15: // append OP_STRING
1.9 paf 16: Operation op; op.code=OP_STRING;
1.6 paf 17: *result+=op.cast;
1.1 paf 18:
1.9 paf 19: // append 'vstring'
20: *result+=vstring;
1.1 paf 21:
22: return result;
23: }
24:
1.5 paf 25: String *LA2S(Array *literal_string_array, int offset) {
1.11 ! paf 26: Operation op;
! 27: op.cast=literal_string_array->get(offset+0);
! 28: if(op.code!=OP_STRING)
! 29: return 0;
! 30:
1.10 paf 31: return static_cast<VString *>(literal_string_array->get(offset+1))->get_string();
1.1 paf 32: }
33:
34:
1.5 paf 35: void push_LS(struct parse_control *pc, lexical_state new_state) {
1.1 paf 36: if(pc->sp<MAX_LEXICAL_STATES) {
1.5 paf 37: pc->stack[pc->sp++]=pc->ls; pc->ls=new_state;
1.1 paf 38: } else
1.7 paf 39: pc->pool->THROW(0, 0, 0, "push_LS: stack overflow");
1.1 paf 40: }
41: void pop_LS(struct parse_control *pc) {
42: if(--pc->sp>=0)
43: pc->ls=pc->stack[pc->sp];
44: else
1.7 paf 45: pc->pool->THROW(0, 0, 0, "push_LS: stack underflow");
1.1 paf 46: }
E-mail: