From 8c4204c542d32c864ef263d2f2272082e5d307b3 Mon Sep 17 00:00:00 2001 From: Rangi Date: Tue, 30 Mar 2021 10:17:09 -0400 Subject: [PATCH] Make 'w' and '...' tokens, and make '@' a separate token Now '@' is valid as a relocexpr_no_str, in 'BANK(@)', and in 'DEF(@)', but not in general T_ID or T_LABEL contexts This will make it easier to implement INCBIN with 'ld' --- src/asm/lexer.c | 6 +++++- src/asm/parser.y | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/asm/lexer.c b/src/asm/lexer.c index 55585183..876dd967 100644 --- a/src/asm/lexer.c +++ b/src/asm/lexer.c @@ -176,6 +176,7 @@ static struct KeywordMapping { {"E", T_TOKEN_E}, {"H", T_TOKEN_H}, {"L", T_TOKEN_L}, + {"W", T_TOKEN_W}, {"DEF", T_OP_DEF}, @@ -293,6 +294,9 @@ static struct KeywordMapping { {"OPT", T_POP_OPT}, {".", T_PERIOD}, + {"...", T_ELLIPSIS}, + + {"@", T_TOKEN_AT}, }; static bool isWhitespace(int c) @@ -591,7 +595,7 @@ struct KeywordDictNode { uint16_t children[0x60 - ' ']; struct KeywordMapping const *keyword; /* Since the keyword structure is invariant, the min number of nodes is known at compile time */ -} keywordDict[354] = {0}; /* Make sure to keep this correct when adding keywords! */ +} keywordDict[357] = {0}; /* Make sure to keep this correct when adding keywords! */ /* Convert a char into its index into the dict */ static inline uint8_t dictIndex(char c) diff --git a/src/asm/parser.y b/src/asm/parser.y index 7951b6cd..4c883aba 100644 --- a/src/asm/parser.y +++ b/src/asm/parser.y @@ -450,6 +450,7 @@ enum { %token T_STRING "string" %token T_PERIOD "." +%token T_ELLIPSIS "..." %token T_COMMA "," %token T_COLON ":" %token T_LBRACK "[" T_RBRACK "]" @@ -510,6 +511,7 @@ enum { %token T_ID "identifier" %token T_LOCAL_ID "local identifier" %token T_ANON "anonymous label" +%token T_TOKEN_AT "@" %type def_id %type redef_id %type scoped_id @@ -590,6 +592,7 @@ enum { %token T_TOKEN_B "b" T_TOKEN_C "c" %token T_TOKEN_D "d" T_TOKEN_E "e" %token T_TOKEN_H "h" T_TOKEN_L "l" +%token T_TOKEN_W "w" %token T_MODE_AF "af" T_MODE_BC "bc" T_MODE_DE "de" T_MODE_SP "sp" T_MODE_PC "pc" %token T_MODE_IME "ime" %token T_MODE_HL "hl" T_MODE_HL_DEC "hld/hl-" T_MODE_HL_INC "hli/hl+" @@ -717,7 +720,7 @@ redef_id : T_POP_REDEF { ; scoped_id : T_ID | T_LOCAL_ID; -scoped_anon_id : scoped_id | T_ANON; +scoped_anon_id : scoped_id | T_ANON | T_TOKEN_AT; label : %empty | T_COLON {