#![arguments(filename: &str, newlines: &Vec<usize>)]
use rb;
use rb::Value;
use atom::atom;
use quotes::QUOTES;
whitespace
= [ \t\n]*
escape
= "\\" .
string -> Option<Value>
= s:$("\"" (escape / [^"])* "\"") { Some(rb::str_new(&s.to_string())) }
delimited_identifier -> &'input str
= "|" i:$([^|]+) "|" {i}
simple_atom -> Value
= p:#position a:(delimited_identifier / $([^\(\) \t\n\[\]\{\}\|"]+)) { atom(&a, &filename, p, newlines) }
quoted_atom -> Value
= q:quote a:simple_atom { rb::vec2rbarr(vec![q, a]) }
atom -> Option<Value>
= a:(quoted_atom / simple_atom) { Some(a) }
sexp -> Option<Value>
= n:(quoted_sexp / simple_sexp) { Some(n) }
comment -> Option<Value>
= (block_comment / line_comment / datum_comment) { None }
expression -> Option<Value>
= string / comment / sexp / atom
quote -> Value
= q:$("'" / ",@" / "," / "`") { rb::str_new("ES.get(&q).unwrap().to_string()) }
quoted_sexp -> Value
= q:quote s:simple_sexp { rb::vec2rbarr(vec![q, s]) }
simple_sexp -> Value
= "(" s:expressions ")" {s}
block_comment
= "#|" (!"|#" .)* "|#"
line_comment
= ";" [^\n]*
datum_comment
= "#;" " "? (atom / sexp)
expressions -> Value
= whitespace s:(expression ** whitespace) whitespace { rb::vec2rbarr(s.into_iter().filter_map(|i| i).collect()) }
pub program -> Value
= expressions