Skip to content

Commit f5ed15d

Browse files
committed
Fix nil
1 parent faad310 commit f5ed15d

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

src/reader.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! not; since this is about being a 'free-er' Clojure, especially since it can't compete with it in raw
99
//! power, neither speed or ecosystem, it might be worth it to leave in reader macros.
1010
11-
use itertools::join;
11+
use nom::combinator::verify;
1212
use nom::{
1313
branch::alt, bytes::complete::tag, combinator::opt, map, sequence::preceded, take_until,
1414
terminated, Err::Incomplete, IResult,
@@ -326,17 +326,6 @@ pub fn try_read_bool(input: &str) -> IResult<&str, Value> {
326326
Ok((rest_input, Value::Boolean(bool.parse().unwrap())))
327327
}
328328

329-
// Tries to parse &str into Value::Nil
330-
/// Expects:
331-
/// nil
332-
/// Example success:
333-
/// nil => Value::Nil
334-
pub fn try_read_nil(input: &str) -> IResult<&str, Value> {
335-
named!(nil_parser<&str,&str>, tag!("nil"));
336-
let (rest_input, nil) = nil_parser(input)?;
337-
Ok((rest_input, Value::Nil))
338-
}
339-
340329
/// Tries to parse &str into Value::double
341330
///
342331
pub fn try_read_f64(input: &str) -> IResult<&str, Value> {
@@ -375,11 +364,8 @@ pub fn try_read_symbol(input: &str) -> IResult<&str, Value> {
375364
/// Example Successes:
376365
/// nil => Value::Nil
377366
pub fn try_read_nil(input: &str) -> IResult<&str, Value> {
378-
named!(nil<&str, &str>, preceded!(consume_clojure_whitespaces_parser, tag!("nil")));
379-
380-
let (rest_input, _) = nil(input)?;
381-
382-
Ok((rest_input, Value::Nil))
367+
let (rest_input, _) = verify(identifier_parser,|ident: &str| ident == "nil")(input)?;
368+
Ok((rest_input,Value::Nil))
383369
}
384370

385371
// @TODO allow escaped strings
@@ -501,7 +487,6 @@ pub fn try_read(input: &str) -> IResult<&str, Value> {
501487
try_read_f64,
502488
try_read_i32,
503489
try_read_bool,
504-
try_read_nil,
505490
try_read_symbol,
506491
try_read_keyword,
507492
try_read_list,

0 commit comments

Comments
 (0)