about summary refs log tree commit diff
path: root/src/parser.zig
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-03-24 23:33:26 +0100
committerBaitinq <[email protected]>2025-03-24 23:33:26 +0100
commit2d8538557dfdd8b86879e4a7ae35749f659bcb34 (patch)
tree71bbed42f1366fed99fe1a3c12efb867320231e5 /src/parser.zig
parentExamples: Add example of interacting with 3rd party library (diff)
downloadpry-lang-2d8538557dfdd8b86879e4a7ae35749f659bcb34.tar.gz
pry-lang-2d8538557dfdd8b86879e4a7ae35749f659bcb34.tar.bz2
pry-lang-2d8538557dfdd8b86879e4a7ae35749f659bcb34.zip
Feature: Add "proper" pointer types
Diffstat (limited to '')
-rw-r--r--src/parser.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/parser.zig b/src/parser.zig
index d7c54f8..a66817c 100644
--- a/src/parser.zig
+++ b/src/parser.zig
@@ -73,6 +73,9 @@ pub const Node = union(enum) {
             parameters: []*Node,
             return_type: *Node,
         },
+        POINTER_TYPE: struct {
+            type: *Node,
+        },
     },
     RETURN_STATEMENT: struct {
         expression: *Node,
@@ -534,6 +537,15 @@ pub const Parser = struct {
         errdefer if (!self.try_context) std.debug.print("Error parsing type annotation {any}\n", .{self.peek_token()});
 
         return self.accept_parse(parse_function_type) orelse switch (self.consume_token().?.type) {
+            .MUL => {
+                return self.create_node(.{
+                    .TYPE = .{
+                        .POINTER_TYPE = .{
+                            .type = try self.parse_type(),
+                        },
+                    },
+                });
+            },
             .IDENTIFIER => |ident| {
                 //TODO: we should only accept specific type identifiers
                 return try self.create_node(.{