static void asmrp_init (asmrp_t *p, const char *str) { p->buf = strdup (str); p->pos = 0; asmrp_getch (p); }
static void asmrp_string (asmrp_t *p) { int l; l = 0; while ( (p->ch!='"') && (p->ch>=32) ) { p->str[l] = p->ch; l++; asmrp_getch (p); } p->str[l]=0; if (p->ch=='"') asmrp_getch (p); p->sym = ASMRP_SYM_STRING; }
static void asmrp_string (asmrp_t *p) { int l; l = 0; while ( (p->ch!='"') && (p->ch>=32) ) { if(l < ASMRP_MAX_ID - 1) p->str[l++] = p->ch; else mp_msg(MSGT_STREAM, MSGL_ERR, "error: string too long, ignoring char %c.\n", p->ch); asmrp_getch (p); } p->str[l]=0; if (p->ch=='"') asmrp_getch (p); p->sym = ASMRP_SYM_STRING; }
static void asmrp_number (asmrp_t *p) { int num; num = 0; while ( (p->ch>='0') && (p->ch<='9') ) { num = num*10 + (p->ch - '0'); asmrp_getch (p); } p->sym = ASMRP_SYM_NUM; p->num = num; }
static void asmrp_identifier (asmrp_t *p) { int l; l = 0; while ( ((p->ch>='A') && (p->ch<='z')) || ((p->ch>='0') && (p->ch<='9'))) { p->str[l] = p->ch; l++; asmrp_getch (p); } p->str[l]=0; p->sym = ASMRP_SYM_ID; }
static void asmrp_identifier (asmrp_t *p) { int l; l = 0; while ( ((p->ch>='A') && (p->ch<='z')) || ((p->ch>='0') && (p->ch<='9'))) { if(l < ASMRP_MAX_ID - 1) p->str[l++] = p->ch; else mp_msg(MSGT_STREAM, MSGL_ERR, "error: identifier too long, ignoring char %c.\n", p->ch); asmrp_getch (p); } p->str[l]=0; p->sym = ASMRP_SYM_ID; }
static void asmrp_get_sym (asmrp_t *p) { while (p->ch <= 32) { if (p->ch == 0) { p->sym = ASMRP_SYM_EOF; return; } asmrp_getch (p); } if (p->ch == '\\') asmrp_getch (p); switch (p->ch) { case '#': p->sym = ASMRP_SYM_HASH; asmrp_getch (p); break; case ';': p->sym = ASMRP_SYM_SEMICOLON; asmrp_getch (p); break; case ',': p->sym = ASMRP_SYM_COMMA; asmrp_getch (p); break; case '=': p->sym = ASMRP_SYM_EQUALS; asmrp_getch (p); if (p->ch=='=') asmrp_getch (p); break; case '&': p->sym = ASMRP_SYM_AND; asmrp_getch (p); if (p->ch=='&') asmrp_getch (p); break; case '|': p->sym = ASMRP_SYM_OR; asmrp_getch (p); if (p->ch=='|') asmrp_getch (p); break; case '<': p->sym = ASMRP_SYM_LESS; asmrp_getch (p); if (p->ch=='=') { p->sym = ASMRP_SYM_LEQ; asmrp_getch (p); } break; case '>': p->sym = ASMRP_SYM_GREATER; asmrp_getch (p); if (p->ch=='=') { p->sym = ASMRP_SYM_GEQ; asmrp_getch (p); } break; case '$': p->sym = ASMRP_SYM_DOLLAR; asmrp_getch (p); break; case '(': p->sym = ASMRP_SYM_LPAREN; asmrp_getch (p); break; case ')': p->sym = ASMRP_SYM_RPAREN; asmrp_getch (p); break; case '"': asmrp_getch (p); asmrp_string (p); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': asmrp_number (p); break; default: asmrp_identifier (p); } #ifdef LOG asmrp_print_sym (p); #endif }