summaryrefslogtreecommitdiff
path: root/lexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lexer.c')
-rw-r--r--lexer.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/lexer.c b/lexer.c
index 7cc9b87..f8280a0 100644
--- a/lexer.c
+++ b/lexer.c
@@ -242,6 +242,7 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) {
lex_type = 0xFF;
uint8_t k = 0;
+ uint8_t k2 = 0;
union reg ch;
ch.u64 = 0;
uint8_t rs = 0;
@@ -324,12 +325,13 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) {
offset++;
}
switch (get_ptok(str[i+offset], dbg)) {
- case PTOK_B :
- case PTOK_X :
- case PTOK_Y :
- case PTOK_S :
- case PTOK_P :
- case PTOK_ALPHA :
+ case PTOK_B :
+ case PTOK_E :
+ case PTOK_X :
+ case PTOK_Y :
+ case PTOK_S :
+ case PTOK_P :
+ case PTOK_ALPHA :
case PTOK_NUMBER: ptok = PTOK_ALPHA; break;
}
if ((ptok == PTOK_S && toupper(str[i+1]) != 'P') || (ptok == PTOK_P && toupper(str[i+1]) != 'C')) {
@@ -584,6 +586,7 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) {
(t) ? (t->subspace = space) : (lt->subspace = space);
(t) ? (t->subtab = tab) : (lt->subtab = tab);
break;
+ case PTOK_E:
case PTOK_X:
case PTOK_Y:
lexeme[j] = str[i++];
@@ -593,8 +596,9 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) {
break;
}
switch (ptok) {
- case PTOK_X: l->tok->type = (lex_type == TOK_IND) ? INDX : ZMX; break;
- case PTOK_Y: l->tok->type = (lex_type == TOK_IND) ? INDY : ZMY; break;
+ case PTOK_E: l->tok->type = (lex_type == TOK_IND) ? EIND : l->tok->type; break;
+ case PTOK_X: l->tok->type = (lex_type == TOK_IND) ? INDX : ZMX; break;
+ case PTOK_Y: l->tok->type = (lex_type == TOK_IND) ? INDY : ZMY; break;
}
break;
case PTOK_S:
@@ -697,13 +701,17 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) {
isch = 0;
isop = 0;
if (j == 3 && str[i] != ':' && !is_struct) {
- for (k = 0; k < OPNUM; k++) {
- if (toupper(lexeme[0]) == mne[k][0]) {
- if (!strcasecmp(lexeme, mne[k])) {
- lex_type = TOK_OPCODE;
+ for (k = 0, k2 = 0; k < OPNUM || k2 < EXT_OPNUM; k++, k2++) {
+ int find_ext = (k2 < EXT_OPNUM);
+ int upper = toupper(lexeme[0]);
+ if (upper == mne[k][0] || (find_ext && upper == ext_mne[k2][0])) {
+ int is_base = !strcasecmp(lexeme, mne[k]);
+ int is_ext = (find_ext && !strcasecmp(lexeme, ext_mne[k2]));
+ if (is_base || is_ext) {
+ lex_type = (is_base && !is_ext) ? TOK_OPCODE : TOK_EXTOP;
isop = 1;
l->count++;
- t = make_token(lex_type, 0xFF, space, tab, k, "", NULL);
+ t = make_token(lex_type, 0xFF, space, tab, (is_base && !is_ext) ? k : k2, "", NULL);
break;
}
}
@@ -791,7 +799,7 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) {
printf("lex(): lexeme: %s, lex_type: %s\n", lexeme, (lex_type != 0xFF) ? lex_tok[lex_type] : "TOK_NONE");
}
j = 0;
- if (lex_type == TOK_OPCODE && !isop) {
+ if ((lex_type == TOK_OPCODE || lex_type == TOK_EXTOP) && !isop) {
j = 0;
} else if (lex_type == TOK_EXPR || (lex_type != TOK_MEMBER && !isdelm2(str[i], dbg))) {
i++;