From bf89132011e906384591bc85dead16d64a150a02 Mon Sep 17 00:00:00 2001 From: Tolmachev Igor Date: Sat, 9 May 2026 17:54:48 +0300 Subject: Reserve inf, +inf, -inf, nan as keywords Needed to represent literals as f64::INFINITY, f64::NEG_INFINITY and f64::NAN. --- compiler/src/ast/parser.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'compiler') diff --git a/compiler/src/ast/parser.rs b/compiler/src/ast/parser.rs index 89a1280..6b11cc6 100644 --- a/compiler/src/ast/parser.rs +++ b/compiler/src/ast/parser.rs @@ -7,7 +7,8 @@ use crate::{ }; fn parse_number(number: &str) -> Result { - let is_float = number.bytes().any(|b| matches!(b, b'.' | b'e' | b'E')); + let is_float = number.bytes().any(|b| matches!(b, b'.' | b'e' | b'E')) + || matches!(number, "inf" | "+inf" | "-inf" | "nan"); let atom = if is_float { Atom::Float(number.parse()?) @@ -52,6 +53,9 @@ fn parse_symbol(symbol: &str) -> Atom { "true" => Atom::Bool(true), "false" => Atom::Bool(false), "nil" => Atom::Nil, + "inf" | "+inf" => Atom::Float(f64::INFINITY), + "-inf" => Atom::Float(f64::NEG_INFINITY), + "nan" => Atom::Float(f64::NAN), _ => Atom::Symbol(symbol.into()), } } -- cgit v1.3