Skip to content

Instantly share code, notes, and snippets.

@fengb

fengb/reader.zig Secret

Last active April 19, 2019 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fengb/c926190b44813c831b92776387218d30 to your computer and use it in GitHub Desktop.
Save fengb/c926190b44813c831b92776387218d30 to your computer and use it in GitHub Desktop.
mal/zig/reader.zig:20:20: error: values of type 'comptime_int' must be comptime known
const len = switch (self.input[self.curr]) {
'~' => if (self.input[self.curr + 1] == '@') 2 else 1,
^
const len: usize = switch (self.input[self.curr]) {
'[', ']', '{', '}', '(', ')', '\'', '`', '^', '@' => 1,
'~' => if (self.input[self.curr + 1] == '@') 2 else 1,
'"' => blk: {
for (self.input[(self.curr + 1)..]) |char, i| if (char == '"') {
break :blk i + 1;
};
return ReaderError.UnmatchedQuote;
},
else => blk: {
for (self.input[(self.curr + 1)..]) |char, i| switch (char) {
' ', ',', '[', ']', '{', '}', '(', ')', '\'', '"', '`', ';' => {
break :blk i + 1;
},
else => {},
};
break :blk self.input.len - self.curr;
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment