about summary refs log tree commit diff
path: root/src/parser.zig
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-05-15 18:42:37 +0200
committerBaitinq <[email protected]>2025-05-15 18:42:41 +0200
commitc8439a069354cb526e02a76f52e978738ad8871c (patch)
treee49d0eb7221431daee13965c90e724d2cba28cc0 /src/parser.zig
parentBootstrap: Tokenizer: Tokenize keywords (diff)
downloadpry-lang-c8439a069354cb526e02a76f52e978738ad8871c.tar.gz
pry-lang-c8439a069354cb526e02a76f52e978738ad8871c.tar.bz2
pry-lang-c8439a069354cb526e02a76f52e978738ad8871c.zip
Feature: Add support for null pointers
Diffstat (limited to 'src/parser.zig')
-rw-r--r--src/parser.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/parser.zig b/src/parser.zig
index 7e1b695..ce1e4cb 100644
--- a/src/parser.zig
+++ b/src/parser.zig
@@ -61,6 +61,7 @@ pub const Node = union(enum) {
         BOOLEAN: struct {
             value: bool,
         },
+        NULL: void,
         CHAR: struct {
             value: u8,
         },
@@ -525,7 +526,7 @@ pub const Parser = struct {
         } });
     }
 
-    // PrimaryExpression ::= NUMBER | BOOLEAN | CHAR | STRING | IDENTIFIER | FunctionCallStatement | FunctionDefinition | LPAREN Expression RPAREN
+    // PrimaryExpression ::= NULL | NUMBER | BOOLEAN | CHAR | STRING | IDENTIFIER | FunctionCallStatement | FunctionDefinition | LPAREN Expression RPAREN
     fn parse_primary_expression(self: *Parser) ParserError!*Node {
         errdefer if (!self.try_context) std.debug.print("Error parsing primary expression {any}\n", .{self.peek_token()});
 
@@ -542,6 +543,9 @@ pub const Parser = struct {
         const token = self.consume_token() orelse return ParserError.ParsingError;
 
         return switch (token.type) {
+            .NULL => try self.create_node(.{
+                .PRIMARY_EXPRESSION = .{ .NULL = void{} },
+            }),
             .NUMBER => |number_token| try self.create_node(.{
                 .PRIMARY_EXPRESSION = .{
                     .NUMBER = .{