From 5c622b6ecbb47cfcef7322047217665bda5675b7 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 13 Oct 2010 11:02:56 -0700 Subject: [PATCH] rustc: Lex identifiers that have numbers in them too --- src/comp/front/lexer.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/comp/front/lexer.rs b/src/comp/front/lexer.rs index f38f5024fe0..9ff12f1c086 100644 --- a/src/comp/front/lexer.rs +++ b/src/comp/front/lexer.rs @@ -204,6 +204,10 @@ fn is_dec_digit(char c) -> bool { ret in_range(c, '0', '9'); } +fn is_alnum(char c) -> bool { + ret is_alpha(c) || is_dec_digit(c); +} + fn is_hex_digit(char c) -> bool { ret in_range(c, '0', '9') || in_range(c, 'a', 'f') || @@ -304,8 +308,8 @@ io fn next_token(reader rdr) -> token.token { auto c = rdr.curr(); - if (is_alpha(c)) { - while (is_alpha(c) || c == '_') { + if (is_alpha(c) || c == '_') { + while (is_alnum(c) || c == '_') { accum_str += (c as u8); rdr.bump(); c = rdr.curr();