diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-02-02 19:58:26 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-02-02 19:58:26 +0100 |
| commit | 3f4375a14218796cbd7bfff1c8cfff0f7bb1f6df (patch) | |
| tree | 1521b91b8f99af588156058b5f9aa12bb1626ac7 /src/estd/parser/common.zig | |
| parent | 8d062a90b1ffbe9e00334fa3e9e939406bd32141 (diff) | |
change .editorconfig
Diffstat (limited to 'src/estd/parser/common.zig')
| -rw-r--r-- | src/estd/parser/common.zig | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/estd/parser/common.zig b/src/estd/parser/common.zig index 986af58..2802838 100644 --- a/src/estd/parser/common.zig +++ b/src/estd/parser/common.zig @@ -4,25 +4,25 @@ const Context = @import("context.zig").Context; const ParseFn = root.ParseFn; pub fn LiteralFn(comptime I: type, comptime O: type) type { - return *const fn (comptime literal: []const I, value: O) ParseFn(I, O); + return *const fn (comptime literal: []const I, value: O) ParseFn(I, O); } pub fn Literal(comptime I: type, comptime O: type) LiteralFn(I, O) { - return struct { - pub fn literal(comptime lit: []const I, value: O) ParseFn(I, O) { - return struct { - pub fn parse(ctx: *Context(I)) !O { - const snapshot = ctx.cursor.snapshot(); - errdefer ctx.cursor.rollback(snapshot); + return struct { + pub fn literal(comptime lit: []const I, value: O) ParseFn(I, O) { + return struct { + pub fn parse(ctx: *Context(I)) !O { + const snapshot = ctx.cursor.snapshot(); + errdefer ctx.cursor.rollback(snapshot); - const slice = try ctx.cursor.consume(lit.len); - if (std.mem.eql(I, lit, slice)) { - return value; - } + const slice = try ctx.cursor.consume(lit.len); + if (std.mem.eql(I, lit, slice)) { + return value; + } - return error.UnexpectedLiteral; - } - }.parse; - } - }.literal; + return error.UnexpectedLiteral; + } + }.parse; + } + }.literal; } |