Mercurial > python-compiler.rs
diff src/ast_dump.rs @ 19:0cb53a31ac12
Implement ast.BoolOp, and improve its display.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 03 Jun 2016 00:55:24 +0100 |
parents | f1c77634a2eb |
children | 7af637f444d1 |
line wrap: on
line diff
--- a/src/ast_dump.rs +++ b/src/ast_dump.rs @@ -5,8 +5,8 @@ use std::iter; impl boolop { fn to_string(&self) -> &'static str { match *self { - boolop::And => "and", - boolop::Or => "or" + boolop::And => " and ", + boolop::Or => " or " } } } @@ -116,7 +116,13 @@ fn generators_to_string(generators: Vec< impl expr { fn to_string(&self) -> String { match self.clone() { - expr::BoolOp(op, values) => format!("{}({})", op.to_string(), args_to_string(values)), + expr::BoolOp(op, values) => { + let mut data = vec!(); + for value in values { + data.push(value.to_string()); + } + data.join(op.to_string()) + }, expr::BinOp(a, op, b) => format!("{} {} {}", a.to_string(), op.to_string(), b.to_string()), expr::UnaryOp(op, operand) => format!("{}{}", op.to_string(), operand.to_string()),