summaryrefslogtreecommitdiff
path: root/src/syntax
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-01-28 23:36:27 +0100
committerLaurenz <laurmaedje@gmail.com>2023-01-28 23:38:03 +0100
commit1e97d5c8cbeb96d35e5a34a8340c4ec1860fa1b6 (patch)
treeaa4a341af10dc0729132a42cdb1cacb1e1d21518 /src/syntax
parent76048a8ef45ac5892235f2e69cb7cb6c35a037e4 (diff)
Better analysis for literals
Diffstat (limited to 'src/syntax')
-rw-r--r--src/syntax/ast.rs14
-rw-r--r--src/syntax/lexer.rs6
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);
}