diff options
Diffstat (limited to 'src/syntax')
| -rw-r--r-- | src/syntax/ast.rs | 14 | ||||
| -rw-r--r-- | src/syntax/lexer.rs | 6 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs index 78d895ff..08def533 100644 --- a/src/syntax/ast.rs +++ b/src/syntax/ast.rs @@ -345,6 +345,20 @@ impl Expr { _ => false, } } + + /// Is this a literal? + pub fn is_literal(&self) -> bool { + match self { + Self::None(_) => true, + Self::Auto(_) => true, + Self::Bool(_) => true, + Self::Int(_) => true, + Self::Float(_) => true, + Self::Numeric(_) => true, + Self::Str(_) => true, + _ => false, + } + } } impl Default for Expr { diff --git a/src/syntax/lexer.rs b/src/syntax/lexer.rs index cbddabb7..555ced84 100644 --- a/src/syntax/lexer.rs +++ b/src/syntax/lexer.rs @@ -499,7 +499,11 @@ impl Lexer<'_> { // Read the fractional part if not already done. // Make sure not to confuse a range for the decimal separator. - if c != '.' && !self.s.at("..") && self.s.eat_if('.') { + if c != '.' + && !self.s.at("..") + && !self.s.scout(1).map_or(false, is_id_start) + && self.s.eat_if('.') + { self.s.eat_while(char::is_ascii_digit); } |
