|
8 | 8 | //! not; since this is about being a 'free-er' Clojure, especially since it can't compete with it in raw
|
9 | 9 | //! power, neither speed or ecosystem, it might be worth it to leave in reader macros.
|
10 | 10 |
|
11 |
| -use itertools::join; |
| 11 | +use nom::combinator::verify; |
12 | 12 | use nom::{
|
13 | 13 | branch::alt, bytes::complete::tag, combinator::opt, map, sequence::preceded, take_until,
|
14 | 14 | terminated, Err::Incomplete, IResult,
|
@@ -326,17 +326,6 @@ pub fn try_read_bool(input: &str) -> IResult<&str, Value> {
|
326 | 326 | Ok((rest_input, Value::Boolean(bool.parse().unwrap())))
|
327 | 327 | }
|
328 | 328 |
|
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 |
| - |
340 | 329 | /// Tries to parse &str into Value::double
|
341 | 330 | ///
|
342 | 331 | pub fn try_read_f64(input: &str) -> IResult<&str, Value> {
|
@@ -375,11 +364,8 @@ pub fn try_read_symbol(input: &str) -> IResult<&str, Value> {
|
375 | 364 | /// Example Successes:
|
376 | 365 | /// nil => Value::Nil
|
377 | 366 | 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)) |
383 | 369 | }
|
384 | 370 |
|
385 | 371 | // @TODO allow escaped strings
|
@@ -501,7 +487,6 @@ pub fn try_read(input: &str) -> IResult<&str, Value> {
|
501 | 487 | try_read_f64,
|
502 | 488 | try_read_i32,
|
503 | 489 | try_read_bool,
|
504 |
| - try_read_nil, |
505 | 490 | try_read_symbol,
|
506 | 491 | try_read_keyword,
|
507 | 492 | try_read_list,
|
|
0 commit comments