From e3c8753a4db671c1acbf27689a048b64e1d3ba16 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 15 Jan 2016 01:04:54 -0800 Subject: [PATCH] Expression parsing --- src/parser.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 80d27f8..1167620 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -201,12 +201,29 @@ impl Parser { let expr = match self.peek() { Some(NumLiteral(n)) => { self.next(); Expression::Number(n) }, Some(StrLiteral(s)) => { self.next(); Expression::StringLiteral(s) }, - Some(Identifier(var)) => { self.next(); Expression::Variable(var) }, - _ => unimplemented!() + Some(Identifier(var)) => { + self.next(); + match self.peek() { + Some(LParen) => try!(self.call_expr()), + _ => Expression::Variable(var) + } + }, + Some(LParen) => { try!(self.paren_expr()) } + Some(x) => return ParseError::result_from_str("Expected primary expression"), + None => return ParseError::result_from_str("Expected primary expression received EoI") }; Ok(expr) } + + fn call_expr(&mut self) -> ParseResult { + unimplemented!() + } + + fn paren_expr(&mut self) -> ParseResult { + + unimplemented!() + } } pub fn parse(tokens: &[Token], _parsed_tree: &[ASTNode]) -> ParseResult {