Skip to content

Commit d64f895

Browse files
committed
Added quote as ' to the reader
1 parent a0b4072 commit d64f895

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/reader.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,24 @@ pub fn try_read_list(input: &str) -> IResult<&str, Value> {
418418
}
419419
}
420420

421+
pub fn try_read_quoted(input: &str) -> IResult<&str, Value> {
422+
named!(quote<&str, &str>, preceded!(consume_clojure_whitespaces_parser, tag!("'")));
423+
424+
let (form,_) = quote(input)?;
425+
426+
let (rest_input,quoted_form_value) = try_read(form)?;
427+
428+
// (quote value)
429+
Ok((rest_input,
430+
vec![Symbol::intern("quote").to_rc_value(),
431+
quoted_form_value .to_rc_value()].into_list().to_value()))
432+
}
433+
421434
pub fn try_read(input: &str) -> IResult<&str, Value> {
422435
preceded(
423436
consume_clojure_whitespaces_parser,
424437
alt((
438+
try_read_quoted,
425439
try_read_map,
426440
try_read_string,
427441
try_read_f64,

0 commit comments

Comments
 (0)