about summary refs log tree commit diff
path: root/src/parser.zig
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-03-23 23:57:05 +0100
committerBaitinq <[email protected]>2025-03-24 00:17:07 +0100
commit31fa32743a5ed25724868cfa476e3af028adb118 (patch)
tree97afd19643223af3784baef5c2b57e48467dcce9 /src/parser.zig
parentParser: Fix ambiguity with symbol declaration (diff)
downloadpry-lang-31fa32743a5ed25724868cfa476e3af028adb118.tar.gz
pry-lang-31fa32743a5ed25724868cfa476e3af028adb118.tar.bz2
pry-lang-31fa32743a5ed25724868cfa476e3af028adb118.zip
Feature: Add support for strings
Diffstat (limited to '')
-rw-r--r--src/parser.zig10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/parser.zig b/src/parser.zig
index 64e670e..9d40c65 100644
--- a/src/parser.zig
+++ b/src/parser.zig
@@ -52,6 +52,9 @@ pub const Node = union(enum) {
         BOOLEAN: struct {
             value: bool,
         },
+        STRING: struct {
+            value: []const u8,
+        },
         IDENTIFIER: struct {
             name: []const u8,
             type: ?*Node,
@@ -403,7 +406,7 @@ pub const Parser = struct {
         } });
     }
 
-    // PrimaryExpression ::= NUMBER | BOOLEAN | IDENTIFIER | FunctionCallStatement | FunctionDefinition | LPAREN Expression RPAREN
+    // PrimaryExpression ::= NUMBER | BOOLEAN | 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()});
 
@@ -432,6 +435,11 @@ pub const Parser = struct {
                     .value = boolean_token,
                 } },
             }),
+            .STRING => |string_token| try self.create_node(.{
+                .PRIMARY_EXPRESSION = .{ .STRING = .{
+                    .value = try self.arena.dupe(u8, string_token),
+                } },
+            }),
             .IDENTIFIER => |identifier_token| try self.create_node(.{
                 .PRIMARY_EXPRESSION = .{
                     .IDENTIFIER = .{