From 48ee6c9a750b358b45ff96bb220f1ddd53d343d5 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 8 Aug 2015 16:09:03 -0700 Subject: [PATCH] Add function name to parse --- src/parser.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 392184c..43d545c 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -15,7 +15,7 @@ pub enum AST { Statements(Vec), IfStatement(Box, Box, Option>), WhileStatement(Box, Box), - Function(Box, Box), + Function(String, Box, Box), ArgList(Vec), DoNothing } @@ -115,8 +115,8 @@ fn statement(tokens: &mut Tokens) -> ParseResult { fn function_block(tokens: &mut Tokens) -> ParseResult { expect!(Keyword(Kw::Fn), tokens); - let name = match tokens.next() { - Some(&Identifier(ref s)) => AST::Name(s.clone()), + let name: String = match tokens.next() { + Some(&Identifier(ref s)) => s.clone(), _ => return Err("bad parse in function_block()".to_string()) }; @@ -131,6 +131,7 @@ fn function_block(tokens: &mut Tokens) -> ParseResult { expect!(Keyword(Kw::End), tokens); Ok(AST::Function( + name, Box::new(arguments), Box::new(body) ))