aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/sexpr.rs25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/sexpr.rs b/src/sexpr.rs
index bc13bd4..6cef563 100644
--- a/src/sexpr.rs
+++ b/src/sexpr.rs
@@ -34,8 +34,6 @@ pub enum SExpr {
SIdentifier(String),
SString(String),
SList(Vec<SExpr>),
- SVector(Vec<SExpr>),
- //SQuote(Vec<SExpr>),
}
//////////// Lexing, Parsing, and Printing
@@ -45,7 +43,7 @@ fn is_whitespace(c: char) -> bool{
}
fn is_seperator(c: char) -> bool {
- "()#".find(c) != None
+ "()".find(c) != None
}
fn is_valid_identifier(s: &str) -> bool {
@@ -193,7 +191,7 @@ pub fn sexpr_parse(tokens: &Vec<&str>, depth: u32) -> Result<(Vec<SExpr>, usize)
while i < tokens.len() {
parsed += 1;
match tokens[i] {
- "(" | "#(" => {
+ "(" => {
// "Read ahead" to check for empty tuple
if i+1 < tokens.len() && tokens[i+1] == ")" {
ret.push(SExpr::SNull);
@@ -203,11 +201,7 @@ pub fn sexpr_parse(tokens: &Vec<&str>, depth: u32) -> Result<(Vec<SExpr>, usize)
let (expr_list, skip) = sexpr_parse(&tokens[i+1..].to_vec(), depth+1)?;
i += skip;
parsed += skip;
- match tokens[i-skip] {
- "(" => ret.push(SExpr::SList(expr_list)),
- "#(" => ret.push(SExpr::SVector(expr_list)),
- _ => unreachable!(),
- };
+ ret.push(SExpr::SList(expr_list));
}
},
")" => {
@@ -251,19 +245,6 @@ pub fn sexpr_repr(ast: &SExpr) -> Result<String, String> {
let elements: Vec<String> = list.iter().map(|ref el| sexpr_repr(&el).unwrap()).collect();
Ok(format!("({})", elements.join(" ")))
},
- &SExpr::SVector(ref list) => {
- let elements: Vec<String> = list.iter().map(|ref el| sexpr_repr(&el).unwrap()).collect();
- Ok(format!("#({})", elements.join(" ")))
- },
- /*
- &SExpr::SQuote(ref list) => {
- let mut ret: String =
- list.iter().fold("(quote ".to_string(),
- |acc, ref el| acc + " " + &sexpr_repr(&el).unwrap());
- ret.push_str(" )");
- Ok(ret)
- },
- */
}
}