Implement Debug on Expression
This commit is contained in:
parent
954bec9ab5
commit
ec330c2582
1 changed files with 4 additions and 3 deletions
|
@ -3,8 +3,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
use lexer;
|
use lexer::Token;
|
||||||
use types;
|
use types;
|
||||||
|
|
||||||
pub struct Program {
|
pub struct Program {
|
||||||
|
@ -20,7 +21,7 @@ impl Program {
|
||||||
pub enum Expression {
|
pub enum Expression {
|
||||||
EOF,
|
EOF,
|
||||||
Atom(Box<types::Value>),
|
Atom(Box<types::Value>),
|
||||||
List { left: lexer::Token, expr: Vec<Box<Expression>>, right: lexer::Token },
|
List { left: Token, expr: Vec<Box<Expression>>, right: Token },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Expression {
|
impl fmt::Debug for Expression {
|
||||||
|
@ -28,7 +29,7 @@ impl fmt::Debug for Expression {
|
||||||
match *self {
|
match *self {
|
||||||
Expression::EOF => write!(f, "EOF"),
|
Expression::EOF => write!(f, "EOF"),
|
||||||
Expression::Atom(ref value) => write!(f, "Atom{{ {:?} }}", value),
|
Expression::Atom(ref value) => write!(f, "Atom{{ {:?} }}", value),
|
||||||
Expression::List{ left: ref lt, expr: ref expr, right: ref rt } => {
|
Expression::List{ left: ref lt, ref expr, right: ref rt } => {
|
||||||
write!(f, "{:?} {:?} {:?}", lt, expr, rt)
|
write!(f, "{:?} {:?} {:?}", lt, expr, rt)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue