From ddf78e19b5c3c44c05e0ff0d43656eaea0184c3d Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 4 Dec 2007 04:59:07 +0000 Subject: [PATCH] Fix #127: Allow use of 0X in addition to 0x for hex constants. svn path=/trunk/yasm/; revision=2017 --- modules/parsers/nasm/nasm-token.re | 4 ++-- modules/parsers/nasm/tests/Makefile.inc | 2 ++ modules/parsers/nasm/tests/hexconst.asm | 2 ++ modules/parsers/nasm/tests/hexconst.hex | 8 ++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 modules/parsers/nasm/tests/hexconst.asm create mode 100644 modules/parsers/nasm/tests/hexconst.hex diff --git a/modules/parsers/nasm/nasm-token.re b/modules/parsers/nasm/nasm-token.re index cbf9fb0f..8d385e50 100644 --- a/modules/parsers/nasm/nasm-token.re +++ b/modules/parsers/nasm/nasm-token.re @@ -144,10 +144,10 @@ scan: } /* $0AA and 0xAA forms of hexidecimal number */ - (("$" digit) | "0x") hexdigit+ { + (("$" digit) | '0x') hexdigit+ { savech = s->tok[TOKLEN]; s->tok[TOKLEN] = '\0'; - if (s->tok[1] == 'x') + if (s->tok[1] == 'x' || s->tok[1] == 'X') /* skip 0 and x */ lvalp->intn = yasm_intnum_create_hex(TOK+2); else diff --git a/modules/parsers/nasm/tests/Makefile.inc b/modules/parsers/nasm/tests/Makefile.inc index 552320cc..8ec457b4 100644 --- a/modules/parsers/nasm/tests/Makefile.inc +++ b/modules/parsers/nasm/tests/Makefile.inc @@ -15,6 +15,8 @@ EXTRA_DIST += modules/parsers/nasm/tests/equcolon.asm EXTRA_DIST += modules/parsers/nasm/tests/equcolon.hex EXTRA_DIST += modules/parsers/nasm/tests/equlocal.asm EXTRA_DIST += modules/parsers/nasm/tests/equlocal.hex +EXTRA_DIST += modules/parsers/nasm/tests/hexconst.asm +EXTRA_DIST += modules/parsers/nasm/tests/hexconst.hex EXTRA_DIST += modules/parsers/nasm/tests/long.asm EXTRA_DIST += modules/parsers/nasm/tests/long.hex EXTRA_DIST += modules/parsers/nasm/tests/newsect.asm diff --git a/modules/parsers/nasm/tests/hexconst.asm b/modules/parsers/nasm/tests/hexconst.asm new file mode 100644 index 00000000..a0039b02 --- /dev/null +++ b/modules/parsers/nasm/tests/hexconst.asm @@ -0,0 +1,2 @@ +dd 0x500 +dd 0X500 diff --git a/modules/parsers/nasm/tests/hexconst.hex b/modules/parsers/nasm/tests/hexconst.hex new file mode 100644 index 00000000..90a00fe9 --- /dev/null +++ b/modules/parsers/nasm/tests/hexconst.hex @@ -0,0 +1,8 @@ +00 +05 +00 +00 +00 +05 +00 +00 -- 2.40.0