edn: Allow comments.
EDN supports only one type of comment: initiated by ; and lasting until the end of the current line or the end of the input stream.
This commit is contained in:
parent
71a30fe69f
commit
247035cc9b
2 changed files with 12 additions and 2 deletions
|
@ -25,7 +25,6 @@ use types::Value;
|
|||
// to trace where the parser is failing
|
||||
|
||||
// TODO: Support tagged elements
|
||||
// TODO: Support comments
|
||||
// TODO: Support discard
|
||||
|
||||
#[export]
|
||||
|
@ -137,5 +136,6 @@ value -> Value
|
|||
list / vector / map / set
|
||||
|
||||
whitespace = (" " / "\r" / "\n" / "\t")
|
||||
comment = ";" [^\r\n]* ("\r" / "\n")?
|
||||
|
||||
__ = whitespace*
|
||||
__ = (whitespace / comment)*
|
||||
|
|
|
@ -799,6 +799,16 @@ fn test_query_find_title() {
|
|||
assert_eq!(value(test).unwrap(), reply);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_comments() {
|
||||
let result = Ok(Value::Integer(0));
|
||||
assert_eq!(value("0;"), result);
|
||||
assert_eq!(value("0;x"), result);
|
||||
assert_eq!(value("0;\n"), result);
|
||||
assert_eq!(value("0;x\n"), result);
|
||||
assert_eq!(value(";\n0"), result);
|
||||
assert_eq!(value(";\r0"), result);
|
||||
}
|
||||
/*
|
||||
// Handy templates for creating test cases follow:
|
||||
|
||||
|
|
Loading…
Reference in a new issue