Skip to content

Commit 7d8c3d7

Browse files
committed
Mark case as generated
1 parent 922b6b1 commit 7d8c3d7

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/nimble_parsec/compiler.ex

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ defmodule NimbleParsec.Compiler do
3737
args = quote(do: [binary, opts \\ []])
3838
guards = quote(do: is_binary(binary))
3939

40+
case =
41+
quote generated: true do
42+
case unquote(:"#{name}__0")(binary, [], [], context, line, byte_offset) do
43+
{:ok, acc, rest, context, line, offset} ->
44+
{:ok, :lists.reverse(acc), rest, context, line, offset}
45+
46+
{:error, _, _, _, _, _} = error ->
47+
error
48+
end
49+
end
50+
4051
body =
4152
quote do
4253
context = Map.new(Keyword.get(opts, :context, []))
@@ -48,13 +59,7 @@ defmodule NimbleParsec.Compiler do
4859
line -> {line, byte_offset}
4960
end
5061

51-
case unquote(:"#{name}__0")(binary, [], [], context, line, byte_offset) do
52-
{:ok, acc, rest, context, line, offset} ->
53-
{:ok, :lists.reverse(acc), rest, context, line, offset}
54-
55-
{:error, _, _, _, _, _} = error ->
56-
error
57-
end
62+
unquote(case)
5863
end
5964

6065
{doc, spec, {name, args, guards, body}}

0 commit comments

Comments
 (0)