diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2018-12-14 00:50:34 -0800 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2018-12-14 00:57:05 -0800 |
commit | 9df075595e08b923c1eb9d73b2900ed4a0dfb464 (patch) | |
tree | 20af360d010eb3a6cf8a6bbdad095bdba53434a0 | |
parent | ce19a52a3422332d55d8c0f601f30c2e67c14f09 (diff) | |
download | nasm-9df075595e08b923c1eb9d73b2900ed4a0dfb464.tar.gz |
Restore the ability to have ? in identifiers, except ? itself
? in identifiers turns out to be used in the field even in non-TASM
mode. Resolve this by allowing it in an identifier still, but treat
'?' by itself the same as we would a keyword, meaning that it needs to
be separated from other identifier characters.
In other words:
a ? b : c ; conditional expression
a?b:c ; seg:off expression seg = a?b, off = c
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r-- | asm/eval.c | 2 | ||||
-rw-r--r-- | asm/tokens.dat | 3 | ||||
-rwxr-xr-x | asm/tokhash.pl | 4 | ||||
-rw-r--r-- | include/nasm.h | 1 | ||||
-rw-r--r-- | include/nctype.h | 3 | ||||
-rw-r--r-- | nasmlib/nctype.c | 1 |
6 files changed, 9 insertions, 5 deletions
@@ -310,7 +310,7 @@ static expr *cexpr(void) if (!e) return NULL; - if (tt == '?') { + if (tt == TOKEN_QMARK) { scan(); f = bexpr(); if (!f) diff --git a/asm/tokens.dat b/asm/tokens.dat index 528f2431..d5345e19 100644 --- a/asm/tokens.dat +++ b/asm/tokens.dat @@ -35,6 +35,9 @@ # Tokens other than instructions and registers # +% TOKEN_QMARK, 0, 0, 0 +? + % TOKEN_PREFIX, 0, 0, P_* a16 a32 diff --git a/asm/tokhash.pl b/asm/tokhash.pl index 9bc2b912..165437ac 100755 --- a/asm/tokhash.pl +++ b/asm/tokhash.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl ## -------------------------------------------------------------------------- ## -## Copyright 1996-2014 The NASM Authors - All Rights Reserved +## Copyright 1996-2018 The NASM Authors - All Rights Reserved ## See the file AUTHORS included with the NASM distribution for ## the specific copyright holders. ## @@ -130,7 +130,7 @@ open(TD, '<', $tokens_dat) or die "$0: cannot open $tokens_dat: $!\n"; while (defined($line = <TD>)) { if ($line =~ /^\%\s+(.*)$/) { $pattern = $1; - } elsif ($line =~ /^([a-z0-9_-]+)/) { + } elsif ($line =~ /^([\?\@\.a-z0-9_-]+)/) { $token = $1; if (defined($tokens{$token})) { diff --git a/include/nasm.h b/include/nasm.h index 08474135..ba015aec 100644 --- a/include/nasm.h +++ b/include/nasm.h @@ -153,6 +153,7 @@ typedef void (*ldfunc)(char *label, int32_t segment, int64_t offset, enum token_type { /* token types, other than chars */ TOKEN_INVALID = -1, /* a placeholder value */ TOKEN_EOS = 0, /* end of string */ + TOKEN_QMARK = '?', TOKEN_EQ = '=', TOKEN_GT = '>', TOKEN_LT = '<', /* aliases */ diff --git a/include/nctype.h b/include/nctype.h index ba57de23..ba594b97 100644 --- a/include/nctype.h +++ b/include/nctype.h @@ -119,10 +119,9 @@ static inline bool nasm_isquote(char x) return nasm_ctype(x, NCT_QUOTE); } -/* TASM-compatible mode requires ? to be an identifier character */ static inline void nasm_ctype_tasm_mode(void) { - nasm_ctype_tab['?'] |= NCT_ID|NCT_IDSTART; + /* No differences at the present moment */ } #endif /* NASM_NCTYPE_H */ diff --git a/nasmlib/nctype.c b/nasmlib/nctype.c index b04f9d19..f30f37e0 100644 --- a/nasmlib/nctype.c +++ b/nasmlib/nctype.c @@ -101,6 +101,7 @@ static void ctype_tab_init(void) nasm_ctype_tab['_'] |= NCT_UNDER|NCT_ID|NCT_IDSTART; nasm_ctype_tab['.'] |= NCT_ID|NCT_IDSTART; nasm_ctype_tab['@'] |= NCT_ID|NCT_IDSTART; + nasm_ctype_tab['?'] |= NCT_ID|NCT_IDSTART; nasm_ctype_tab['#'] |= NCT_ID; nasm_ctype_tab['~'] |= NCT_ID; nasm_ctype_tab['\''] |= NCT_QUOTE; |