File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -433,6 +433,16 @@ pub fn try_read_pattern(input: &str) -> IResult<&str, Value> {
433
433
let regex = regex:: Regex :: new ( regex_string. as_str ( ) ) . to_value ( ) ;
434
434
Ok ( ( rest_input, regex) )
435
435
}
436
+ // Reads the #
437
+ pub fn try_read_var ( input : & str ) -> IResult < & str , Value > {
438
+ named ! ( var_parser<& str , & str >, preceded!( consume_clojure_whitespaces_parser, tag!( "#'" ) ) ) ;
439
+
440
+ let ( rest_input, _) = var_parser ( input) ?;
441
+ let ( rest_input, val) = try_read ( rest_input) ?;
442
+ // #'x just expands to (var x), just like 'x is just a shorthand for (quote x)
443
+ // So here we return (var val)
444
+ Ok ( ( rest_input, list_val ! ( sym!( "var" ) val) ) )
445
+ }
436
446
437
447
// @TODO Perhaps generalize this, or even generalize it as a reader macro
438
448
/// Tries to parse &str into Value::PersistentListMap, or some other Value::..Map
@@ -586,6 +596,7 @@ pub fn try_read(input: &str) -> IResult<&str, Value> {
586
596
try_read_list,
587
597
try_read_vector,
588
598
try_read_pattern,
599
+ try_read_var,
589
600
) ) ,
590
601
) ( input)
591
602
}
You can’t perform that action at this time.
0 commit comments