From 02c2055601508b7e53cad635dfa9f5f5ae354d54 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 24 Aug 2019 16:56:58 -0300 Subject: [PATCH] parser: make println consume parens --- examples/hello.v | 13 +++++++------ src/parser.zig | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/hello.v b/examples/hello.v index 9219a29..8afff20 100644 --- a/examples/hello.v +++ b/examples/hello.v @@ -1,12 +1,13 @@ -//const ( -// Cock = 1 -// Ball = 2 -// Deals = 3 -// Businesses = 4 -//) +const ( + Cock = 1 + Ball = 2 + 3 + Deals = 3 + Businesses = 4 +) fn main(a int) int { 1 + 2 + 3 + 4 1 + 1 * 1 3 / (51 + 2) + println(2 * 1956) } diff --git a/src/parser.zig b/src/parser.zig index ddc3011..75a8e30 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -405,7 +405,11 @@ pub const Parser = struct { fn parsePrintln(self: *@This()) !*Stmt { _ = try self.consumeSingle(.Println); + + _ = try self.consumeSingle(.LeftParen); var expr = try self.parseExpr(); + _ = try self.consumeSingle(.RightParen); + return try Stmt.mkPrintln(self.allocator, expr.Expr); }