Expression parsing

This commit is contained in:
greg 2016-01-15 01:04:54 -08:00
parent e1aa7ecb17
commit e3c8753a4d

View File

@ -201,12 +201,29 @@ impl Parser {
let expr = match self.peek() { let expr = match self.peek() {
Some(NumLiteral(n)) => { self.next(); Expression::Number(n) }, Some(NumLiteral(n)) => { self.next(); Expression::Number(n) },
Some(StrLiteral(s)) => { self.next(); Expression::StringLiteral(s) }, Some(StrLiteral(s)) => { self.next(); Expression::StringLiteral(s) },
Some(Identifier(var)) => { self.next(); Expression::Variable(var) }, Some(Identifier(var)) => {
_ => unimplemented!() 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) Ok(expr)
} }
fn call_expr(&mut self) -> ParseResult<Expression> {
unimplemented!()
}
fn paren_expr(&mut self) -> ParseResult<Expression> {
unimplemented!()
}
} }
pub fn parse(tokens: &[Token], _parsed_tree: &[ASTNode]) -> ParseResult<AST> { pub fn parse(tokens: &[Token], _parsed_tree: &[ASTNode]) -> ParseResult<AST> {