Ejemplo n.º 1
0
/*
 * main
 */
void expr_parser(bc_t *bc_src) {
  // init
  bc_in = bc_src;
  bc_out = malloc(sizeof(bc_t));
  bc_create(bc_out);

  byte code = CODE_PEEK();

  //
  // empty!
  //
  if (code == kwTYPE_LINE || code == kwTYPE_EOC) {
    bc_destroy(bc_out);
    free(bc_out);
    return;
  }
  //
  // LET|CONST special code
  //
  if (code == kwTYPE_CMPOPR) {
    IP++;
    if (CODE(IP) != '=') {
      cev_opr_err();
      bc_destroy(bc_out);
      free(bc_out);
      return;
    } else {
      IP++;
      cev_add2(kwTYPE_CMPOPR, '=');
    }
  }
  // start
  code = CODE_PEEK();
  while (code != kwTYPE_EOC && code != kwTYPE_LINE && !comp_error) {
    if (kw_check_evexit(code)) {  // separator
      cev_add1(code);
      IP++;                     // add sep.
      if (code == kwUSE) {
        cev_add_addr(0);
        // USE needs 2 ips
        cev_add_addr(0);
        IP += (ADDRSZ + ADDRSZ);
      } else if (code == kwAS) {
        if (CODE_PEEK() == kwTYPE_SEP) {  // OPEN ... AS #1
          cev_add1(kwTYPE_SEP);
          IP++;
          cev_add1(CODE(IP));
          IP++;
        }
      } else {
        if (code == kwTYPE_SEP) { // Normal separator (,;)
          cev_add1(CODE(IP));
          IP++;
        }
      }
      code = CODE_PEEK();       // next
      continue;
    }
    cev_log();                  // do it
    code = CODE_PEEK();         // next
  }

  // finish
  if (bc_out->count) {
    bc_in->count = 0;
    bc_append(bc_in, bc_out);
  }

  bc_destroy(bc_out);
  free(bc_out);
}
Ejemplo n.º 2
0
Archivo: pbrange.c Proyecto: jw3/jbmcgi
void pointblankrange_destroy(lpPointBlankRange pointblankrange)
{
  atmos_destroy(pointblankrange->atmos);
  bc_destroy(pointblankrange->bc);
  free(pointblankrange);
}