aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorTolmachev Igor <me@igorek.dev>2026-05-09 17:54:48 +0300
committerTolmachev Igor <me@igorek.dev>2026-05-09 17:54:48 +0300
commitbf89132011e906384591bc85dead16d64a150a02 (patch)
treee844f574162443b8fdfb933e18c2d2bfdc2c5e36 /compiler
parent60ad7b994c2126346c19769a1a5f5c8f679a05ee (diff)
downloadcrisp-bf89132011e906384591bc85dead16d64a150a02.tar.gz
crisp-bf89132011e906384591bc85dead16d64a150a02.zip
Reserve inf, +inf, -inf, nan as keywords
Needed to represent literals as f64::INFINITY, f64::NEG_INFINITY and f64::NAN.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/src/ast/parser.rs6
1 files changed, 5 insertions, 1 deletions
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::{
7}; 7};
8 8
9fn parse_number(number: &str) -> Result<Atom, Error> { 9fn parse_number(number: &str) -> Result<Atom, Error> {
10 let is_float = number.bytes().any(|b| matches!(b, b'.' | b'e' | b'E')); 10 let is_float = number.bytes().any(|b| matches!(b, b'.' | b'e' | b'E'))
11 || matches!(number, "inf" | "+inf" | "-inf" | "nan");
11 12
12 let atom = if is_float { 13 let atom = if is_float {
13 Atom::Float(number.parse()?) 14 Atom::Float(number.parse()?)
@@ -52,6 +53,9 @@ fn parse_symbol(symbol: &str) -> Atom {
52 "true" => Atom::Bool(true), 53 "true" => Atom::Bool(true),
53 "false" => Atom::Bool(false), 54 "false" => Atom::Bool(false),
54 "nil" => Atom::Nil, 55 "nil" => Atom::Nil,
56 "inf" | "+inf" => Atom::Float(f64::INFINITY),
57 "-inf" => Atom::Float(f64::NEG_INFINITY),
58 "nan" => Atom::Float(f64::NAN),
55 _ => Atom::Symbol(symbol.into()), 59 _ => Atom::Symbol(symbol.into()),
56 } 60 }
57} 61}