Beispiel #1
0
static int asmrp_set_id (asmrp_t *p, char *s, int v) {

  int i;

  i = asmrp_find_id (p, s);

  if (i<0) {
    i = p->sym_tab_num;
    p->sym_tab_num++;
    p->sym_tab[i].id = strdup (s);

#ifdef LOG
    printf ("new symbol '%s'\n", s);
#endif

  }    

  p->sym_tab[i].v = v;
 
#ifdef LOG
  printf ("symbol '%s' assigned %d\n", s, v);
#endif

  return i;
}
Beispiel #2
0
static int asmrp_operand (asmrp_t *p) {

  int i, ret;
  
#ifdef LOG
  printf ("operand\n");
#endif

  ret = 0;

  switch (p->sym) {

  case ASMRP_SYM_DOLLAR:

    asmrp_get_sym (p);
    
    if (p->sym != ASMRP_SYM_ID) {
      printf ("error: identifier expected.\n");
      abort();
    }

    i = asmrp_find_id (p, p->str);
    if (i<0) {
      printf ("error: unknown identifier %s\n", p->str);
    }
    ret = p->sym_tab[i].v;

    asmrp_get_sym (p);
    break;

  case ASMRP_SYM_NUM:
    ret = p->num;

    asmrp_get_sym (p);
    break;

  case ASMRP_SYM_LPAREN:
    asmrp_get_sym (p);

    ret = asmrp_condition (p);

    if (p->sym != ASMRP_SYM_RPAREN) {
      printf ("error: ) expected.\n");
      abort();
    }

    asmrp_get_sym (p);
    break;

  default:
    printf ("syntax error, $ number or ( expected\n");
    abort();
  }

#ifdef LOG
  printf ("operand done, =%d\n", ret);
#endif
  
  return ret;
}
Beispiel #3
0
static int asmrp_set_id (asmrp_t *p, char *s, int v) {

  int i;

  i = asmrp_find_id (p, s);

  if (i<0) {
    if (p->sym_tab_num == ASMRP_MAX_SYMTAB - 1) {
      mp_msg(MSGT_STREAM, MSGL_ERR, "sym_tab overflow, ignoring identifier %s\n", s);
      return 0;
    }
    i = p->sym_tab_num;
    p->sym_tab_num++;
    p->sym_tab[i].id = strdup (s);

#ifdef LOG
    printf ("new symbol '%s'\n", s);
#endif

  }

  p->sym_tab[i].v = v;

#ifdef LOG
  printf ("symbol '%s' assigned %d\n", s, v);
#endif

  return i;
}