From cdb47bb3b95df84f758c3125cecaa8c0601c69d6 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 26 Jul 2015 01:54:55 -0700 Subject: [PATCH] Add paren parsing --- Grammar | 1 + src/parser.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Grammar b/Grammar index f5d7237..869ae42 100644 --- a/Grammar +++ b/Grammar @@ -11,6 +11,7 @@ := if then end | if then else end | while SEP end + | ( ) | := diff --git a/src/parser.rs b/src/parser.rs index 71e62a0..8b99f2d 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -130,6 +130,12 @@ fn expression(tokens: &mut Tokens) -> ParseResult { Some(&Keyword(Kw::While)) => { while_expression(tokens) }, + Some(&LParen) => { + tokens.next(); + let expr = expression(tokens); + expect!(RParen, tokens); + expr + }, _ => simple_expression(tokens) } }