Annotation of parser3/src/main/compile_tools.C, revision 1.7

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

E-mail: