Annotation of parser3/src/main/compile_tools.C, revision 1.1
1.1 ! paf 1: /*
! 2: $Id: core.C,v 1.20 2001/02/20 12:18:28 paf Exp $
! 3: */
! 4:
! 5: #include "compile_tools.h"
! 6: #include "pa_string.h"
! 7: #include "pa_array.h"
! 8: #include "pa_exception.h"
! 9:
! 10: void *N(void *apool) {
! 11: Pool& pool=*static_cast<Pool *>(apool);
! 12: return new(pool) Array(pool);
! 13: }
! 14:
! 15: void A(void **result, enum OPCODE acode) {
! 16: int code=acode;
! 17: (*static_cast<Array *>(*result))+=reinterpret_cast<Array::Item *>(code);
! 18: }
! 19:
! 20: void AP(void **result, enum OPCODE acode, void *param) {
! 21: int code=acode;
! 22: (*static_cast<Array *>(*result))+=reinterpret_cast<Array::Item *>(code);
! 23: (*static_cast<Array *>(*result))+=param;
! 24: }
! 25:
! 26: void *L(void *astring) {
! 27: String *string=static_cast<String *>(astring);
! 28:
! 29: // empty ops array
! 30: void *result=N(&string->pool());
! 31:
! 32: // append OP_STRING
! 33: int code=OP_STRING;
! 34: *(static_cast<Array *>(result))+=reinterpret_cast<Array::Item *>(code);
! 35:
! 36: // append 'string'
! 37: *(static_cast<Array *>(result))+=string;
! 38:
! 39: return result;
! 40: }
! 41:
! 42: void *LS(void *literal) {
! 43: return const_cast<void *>(static_cast<Array *>(literal)->get(1));
! 44: }
! 45:
! 46: void P(void **result, void *code_array) {
! 47: *(static_cast<Array *>(*result))+=code_array;
! 48: }
! 49:
! 50:
! 51:
! 52: void push_LS(struct parse_control *pc) {
! 53: if(pc->sp<MAX_LEXICAL_STATES) {
! 54: pc->stack[pc->sp++]=pc->ls; pc->ls=LS_VAR_NAME_SIMPLE;
! 55: } else
! 56: (static_cast<Pool *>(pc->pool))->exception().raise(0, 0, 0,
! 57: "push_LS: stack overflow");
! 58: }
! 59: void pop_LS(struct parse_control *pc) {
! 60: if(--pc->sp>=0)
! 61: pc->ls=pc->stack[pc->sp];
! 62: else
! 63: (static_cast<Pool *>(pc->pool))->exception().raise(0, 0, 0,
! 64: "push_LS: stack underflow");
! 65: }
! 66:
! 67: void *string_create(void *apool) {
! 68: Pool& pool=*static_cast<Pool *>(apool);
! 69: return new(pool) String(pool);
! 70: }
! 71:
! 72: void real_cstring_append(CSTRING_APPEND_PARAMS) {
! 73: static_cast<String *>(astring)->APPEND(piece, size, file, line);
! 74: }
! 75:
! 76: char *string_cstr(void *astring) {
! 77: return static_cast<String *>(astring)->cstr();
! 78: }
! 79:
! 80: /* exception */
! 81:
! 82: void exception(void *pool,
! 83: void *atype, void *acode,
! 84: void *aproblem_source,
! 85: char *acomment) {
! 86: static_cast<Pool *>(pool)->exception().raise(
! 87: static_cast<class String *>(atype),
! 88: static_cast<class String *>(acode),
! 89: static_cast<class String *>(aproblem_source),
! 90: acomment);
! 91: }
E-mail: