Add string to AST

This commit is contained in:
greg 2015-07-22 02:51:49 -07:00
parent fc3dcf792d
commit dbdae42c1b

View File

@ -28,6 +28,7 @@ enum Token {
#[derive(Debug)] #[derive(Debug)]
enum ASTNode { enum ASTNode {
Name(String), Name(String),
LangString(String),
Number(f64), Number(f64),
BinOp(Box<ASTNode>, Box<ASTNode>, Box<ASTNode>), BinOp(Box<ASTNode>, Box<ASTNode>, Box<ASTNode>),
Binding(String, Box<ASTNode>) Binding(String, Box<ASTNode>)
@ -181,7 +182,7 @@ fn let_expression<'a>(input: &mut Iter<Token>) -> ParseResult {
} }
if let Some(&StrLiteral(ref value)) = next { if let Some(&StrLiteral(ref value)) = next {
let ast = ASTNode::Binding(name.clone(), Box::new(ASTNode::Name(value.clone()))); let ast = ASTNode::Binding(name.clone(), Box::new(ASTNode::LangString(value.clone())));
return ParseResult::Ok(ast); return ParseResult::Ok(ast);
} }