diff options
Diffstat (limited to 'src/parser.zig')
-rw-r--r-- | src/parser.zig | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/parser.zig b/src/parser.zig index e206403..e9a2908 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -10,7 +10,6 @@ const NodeType = enum { PROGRAM, STATEMENT, ASSIGNMENT_STATEMENT, - PRINT_STATEMENT, FUNCTION_CALL_STATEMENT, EXPRESSION, ADDITIVE_EXPRESSION, @@ -31,9 +30,6 @@ pub const Node = union(NodeType) { name: []const u8, expression: *Node, }, - PRINT_STATEMENT: struct { - expression: *Node, - }, FUNCTION_CALL_STATEMENT: struct { name: []const u8, arguments: []*Node, @@ -105,13 +101,11 @@ pub const Parser = struct { } }); } - // Statement ::= (AssignmentStatement | PrintStatement | FunctionCallStatement) SEMICOLON + // Statement ::= (AssignmentStatement | FunctionCallStatement) SEMICOLON fn parse_statement(self: *Parser) ParserError!*Node { errdefer if (!self.try_context) std.debug.print("Error parsing statement\n", .{}); - const statement = - self.accept_parse(parse_print_statement) orelse - self.accept_parse(parse_function_call_statement) orelse + const statement = self.accept_parse(parse_function_call_statement) orelse try self.parse_assignment_statement(); _ = try self.accept_token(tokenizer.TokenType.SEMICOLON); @@ -147,24 +141,6 @@ pub const Parser = struct { }); } - // PrintStatement :== PRINT LPAREN Expression RPAREN - fn parse_print_statement(self: *Parser) ParserError!*Node { - errdefer if (!self.try_context) std.debug.print("Error parsing print statement\n", .{}); - _ = try self.accept_token(tokenizer.TokenType.PRINT); - - _ = try self.accept_token(tokenizer.TokenType.LPAREN); - - const expression = try self.parse_expression(); - - _ = try self.accept_token(tokenizer.TokenType.RPAREN); - - return self.create_node(.{ - .PRINT_STATEMENT = .{ - .expression = @constCast(expression), - }, - }); - } - // FunctionCallStatement ::= IDENTIFIER LPAREN FunctionArguments? RPAREN fn parse_function_call_statement(self: *Parser) ParserError!*Node { errdefer if (!self.try_context) std.debug.print("Error parsing function call statement\n", .{}); |