summaryrefslogtreecommitdiff
path: root/src/zisp/io/Parser.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/zisp/io/Parser.zig')
-rw-r--r--src/zisp/io/Parser.zig21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/zisp/io/Parser.zig b/src/zisp/io/Parser.zig
index 4fdde8b..0b1a6c7 100644
--- a/src/zisp/io/Parser.zig
+++ b/src/zisp/io/Parser.zig
@@ -192,12 +192,21 @@ fn addUnicode(p: *Parser, uc: u21) !void {
fn getCharsAsString(p: *Parser) !Value {
defer p.chars.clearRetainingCapacity();
const s = p.chars.items;
- return if (value.sstr.isValidSstr(s))
- value.sstr.pack(s)
- else if (value.istr.isValidIstr(s) and p.istr_set != null)
- value.istr.getOrNewInSet(p.istr_set.?, s)
- else
- value.array.newString(p.alloc, s);
+ if (value.sstr.isValidSstr(s)) {
+ return value.sstr.pack(s);
+ } else if (value.istr.isValidIstr(s)) {
+ return p.getIstr(s);
+ } else {
+ return value.array.newString(p.alloc, s);
+ }
+}
+
+fn getIstr(p: *Parser, s: []const u8) !Value {
+ if (p.istr_set) |set| {
+ return value.istr.getOrNewInSet(set, s);
+ } else {
+ return value.istr.pack(try value.istr.new(p.alloc, s));
+ }
}
fn getCharsAsRune(p: *Parser) Value {