From 3cd02b1f015cc855eab058145f7590b284d78058 Mon Sep 17 00:00:00 2001 From: NanoTech Date: Wed, 7 Dec 2016 00:34:16 -0600 Subject: Parse identifiers' first character correctly --- src/lexer.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lexer.rs b/src/lexer.rs index 0ebac3e..f4e23f3 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -90,14 +90,17 @@ fn is_identifier_first_char(c: char) -> bool { } fn is_identifier_rest_char(c: char) -> bool { - c.is_alphabetic() || is_decimal(c) || c == '_' || c == '/' + is_identifier_first_char(c) || is_decimal(c) || c == '/' } fn is_decimal(c: char) -> bool { c.is_digit(10) } -named!(identifier<&str, &str>, take_while1_s!(is_identifier_rest_char)); // FIXME use is_identifier_first_char +named!(identifier<&str, &str>, recognize!(preceded!( + take_while1_s!(is_identifier_first_char), + take_while_s!(is_identifier_rest_char)) +)); named!(natural<&str, &str>, preceded!(tag!("+"), take_while1_s!(is_decimal))); named!(integral<&str, isize>, map_res!(take_while1_s!(is_decimal), |s| isize::from_str(s))); named!(integer<&str, isize>, alt!( -- cgit v1.2.3