summaryrefslogtreecommitdiff
path: root/lexer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lexer.c')
-rw-r--r--lexer.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/lexer.c b/lexer.c
index e315155..2b7c8e7 100644
--- a/lexer.c
+++ b/lexer.c
@@ -198,7 +198,8 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) {
lex_type = 0xFF;
uint8_t k = 0;
- uint8_t ch = 0;
+ union reg ch;
+ ch.u64 =0;
uint8_t rs = 0;
uint8_t of = 0;
uint8_t base = 0;
@@ -395,23 +396,25 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) {
}
isesc = 0;
lexeme[j] = '\0';
- switch (lexeme[k]) {
- case '\\':
- switch (lexeme[++k]) {
- case 'n' : ch = '\n'; break;
- case 'r' : ch = '\r'; break;
- case 't' : ch = '\t'; break;
- case 'b' : ch = '\b'; break;
- case '\'': ch = '\''; break;
- case '\"': ch = '\"'; break;
- case '\\': ch = '\\'; break;
- }
- break;
- default: ch = lexeme[k];
+ for (j = 0; lexeme[k] != '\0' && j < 7; k++) {
+ switch (lexeme[k]) {
+ case '\\':
+ switch (lexeme[++k]) {
+ case 'n' : ch.u8[j++] = '\n'; break;
+ case 'r' : ch.u8[j++] = '\r'; break;
+ case 't' : ch.u8[j++] = '\t'; break;
+ case 'b' : ch.u8[j++] = '\b'; break;
+ case '\'': ch.u8[j++] = '\''; break;
+ case '\"': ch.u8[j++] = '\"'; break;
+ case '\\': ch.u8[j++] = '\\'; break;
+ }
+ break;
+ default: ch.u8[j++] = lexeme[k];
+ }
}
lex_type = TOK_CHAR;
l->count++;
- t = make_token(lex_type, 0, space, tab, ch, "", NULL);
+ t = make_token(lex_type, 0, space, tab, ch.u64, "", NULL);
break;
case PTOK_LBRACK:
case PTOK_HASH :