Dusk: Support parentheses expressions #1090

Closed
opened 2023-10-27 21:10:35 +00:00 by clickingbuttons · 2 comments
clickingbuttons commented 2023-10-27 21:10:35 +00:00 (Migrated from github.com)

Pretty simple to add to parser.

 fn expectParenExpr(p: *Parser) !NodeIndex {
-    _ = try p.expectToken(.paren_left);
+    const main_token = try p.expectToken(.paren_left);
     const expr = try p.expression() orelse {
         try p.errors.add(
             p.peekToken(.loc, 0),
@@ -1491,7 +1491,11 @@ fn expectParenExpr(p: *Parser) !NodeIndex {
         return error.Parsing;
     };
     _ = try p.expectToken(.paren_right);
-    return expr;
+    return try p.addNode(.{
+        .tag = .paren_expr,
+        .main_token = main_token,
+        .lhs = expr,
+    });
 }
Pretty simple to add to parser. ```diff fn expectParenExpr(p: *Parser) !NodeIndex { - _ = try p.expectToken(.paren_left); + const main_token = try p.expectToken(.paren_left); const expr = try p.expression() orelse { try p.errors.add( p.peekToken(.loc, 0), @@ -1491,7 +1491,11 @@ fn expectParenExpr(p: *Parser) !NodeIndex { return error.Parsing; }; _ = try p.expectToken(.paren_right); - return expr; + return try p.addNode(.{ + .tag = .paren_expr, + .main_token = main_token, + .lhs = expr, + }); } ```
alichraghi commented 2023-10-27 22:58:49 +00:00 (Migrated from github.com)

what's the point?

what's the point?
emidoots commented 2023-10-28 00:16:40 +00:00 (Migrated from github.com)
Duplicate of https://github.com/hexops/mach/issues/1091
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#1090
No description provided.