summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNanoTech2016-12-07 00:34:16 -0600
committerNanoTech2017-03-10 23:48:28 -0600
commit3cd02b1f015cc855eab058145f7590b284d78058 (patch)
treeaf9d5ebbf3feb2ee0200dff61b3ee0fa1395a4eb
parentbae6662c9b04a158f4e267d329bd402c1667fca3 (diff)
Parse identifiers' first character correctly
Diffstat (limited to '')
-rw-r--r--src/lexer.rs7
1 files changed, 5 insertions, 2 deletions
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!(