summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zisp/io/Parser.zig17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/zisp/io/Parser.zig b/src/zisp/io/Parser.zig
index aeca539..8d16b93 100644
--- a/src/zisp/io/Parser.zig
+++ b/src/zisp/io/Parser.zig
@@ -438,6 +438,7 @@ fn parseCladDatum(p: *Parser, c: u8, next: Fn) !void {
return switch (c) {
'|' => p.jump(next, try p.getString('|')),
'"' => p.jump(next, try p.getString('"')),
+ '~' => p.jump(next, try p.getTildeString()),
'#' => p.parseHashExpr(next),
'(', '[', '{' => p.parseList(c, next),
'\'', '`', ',' => p.parseQuoteExpr(c, next),
@@ -472,6 +473,18 @@ fn getString(p: *Parser, comptime close: u8) !Value {
return p.err(.UnclosedString, .{close} ++ " string");
}
+fn getTildeString(p: *Parser) !Value {
+ const sentinel = try p.readNoEof("tilde");
+ while (try p.read()) |c| {
+ if (c == sentinel) {
+ const s = p.getCharsAsString();
+ return p.cons(TILDE, s);
+ }
+ try p.addChar(c);
+ }
+ return p.err(.UnclosedString, "tilde string");
+}
+
fn skipStringLfEscape(p: *Parser) !u8 {
const msg = "string linefeed escape";
while (try p.read()) |c| switch (c) {
@@ -735,8 +748,8 @@ fn checkBlank(p: *Parser, c: u8) !enum { yes, skip_unit, no } {
fn isBareChar(c: u8) bool {
return switch (c) {
// zig fmt: off
- 'a'...'z' , 'A'...'Z' , '0'...'9' , '!' , '$' , '%' , '*' , '+' ,
- '-' , '/' , '<' , '=' , '>' , '?' , '@' , '^' , '_' , '~' , => true,
+ 'a'...'z' , 'A'...'Z' , '0'...'9' , '!' , '$' , '%' , '*' ,
+ '+' , '-' , '/' , '<' , '=' , '>' , '?' , '@' , '^' , '_' , => true,
// zig fmt: on
else => false,
};