From 0755d42112b5053656cd2c449a1933c6df3198b5 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 11 Sep 2017 20:37:19 -0700 Subject: [PATCH] More parsing work --- src/schala_lang/parsing.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index 63a0e8d..ba57d9c 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -286,7 +286,9 @@ statement := expression | declaration declaration := type_declaration | func_declaration type_declaration := TYPE identifier -func_declaration := FN +func_declaration := FN identifier LParen param_list RParen + +param_list := (identifier type_anno+ Comma)* expression := primary primary := literal @@ -403,7 +405,16 @@ impl Parser { } fn func_declaration(&mut self) -> ParseResult { - unimplemented!() + expect!(self, Keyword(Func), "Expected 'fn'"); + let name = self.identifier()?; + expect!(self, LParen, "Expected '('"); + let params = self.param_list(); + expect!(self, RParen, "Expected ')'"); + Ok(Declaration::FuncDecl) + } + + fn param_list(&mut self) -> ParseResult>> { + Ok(vec!()) } fn expression(&mut self) -> ParseResult { @@ -451,7 +462,6 @@ impl Parser { fn float_literal(&mut self) -> ParseResult { use self::Expression::*; let mut digits = self.digits()?; - let p = self.peek(); if let TokenType::Period = self.peek() { self.next(); digits.push_str(".");