We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 922b6b1 commit 7d8c3d7Copy full SHA for 7d8c3d7
lib/nimble_parsec/compiler.ex
@@ -37,6 +37,17 @@ defmodule NimbleParsec.Compiler do
37
args = quote(do: [binary, opts \\ []])
38
guards = quote(do: is_binary(binary))
39
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
50
51
body =
52
quote do
53
context = Map.new(Keyword.get(opts, :context, []))
@@ -48,13 +59,7 @@ defmodule NimbleParsec.Compiler do
59
line -> {line, byte_offset}
60
end
61
- case unquote(:"#{name}__0")(binary, [], [], context, line, byte_offset) do
- {:ok, acc, rest, context, line, offset} ->
- {:ok, :lists.reverse(acc), rest, context, line, offset}
54
-
55
- {:error, _, _, _, _, _} = error ->
56
- error
57
- end
62
+ unquote(case)
58
63
64
65
{doc, spec, {name, args, guards, body}}
0 commit comments