fix: bug in parsing not returning errors
This commit is contained in:
parent
6edee4b073
commit
0ae33a44ff
1 changed files with 14 additions and 10 deletions
|
@ -19,12 +19,14 @@ defmodule Gcode.Parser do
|
||||||
ok(program) <- hydrate(tokens) do
|
ok(program) <- hydrate(tokens) do
|
||||||
ok(program)
|
ok(program)
|
||||||
else
|
else
|
||||||
{:error, reason} ->
|
error(reason) ->
|
||||||
{:parse_error, reason}
|
error({:parse_error, reason})
|
||||||
|
|
||||||
{:error, {message, unexpected, _, {line, _}, col}} ->
|
error({message, unexpected, _, {line, _}, col}) ->
|
||||||
|
error(
|
||||||
{:parse_error,
|
{:parse_error,
|
||||||
"Unexpected #{inspect(unexpected)} at line: #{line}:#{col + 1}. #{message}."}
|
"Unexpected #{inspect(unexpected)} at line: #{line}:#{col + 1}. #{message}."}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,12 +40,14 @@ defmodule Gcode.Parser do
|
||||||
ok(program) <- hydrate(tokens) do
|
ok(program) <- hydrate(tokens) do
|
||||||
ok(program)
|
ok(program)
|
||||||
else
|
else
|
||||||
{:error, reason} ->
|
error(reason) ->
|
||||||
{:parse_error, reason}
|
error({:parse_error, reason})
|
||||||
|
|
||||||
{:error, {message, unexpected, _, {line, _}, col}} ->
|
error({message, unexpected, _, {line, _}, col}) ->
|
||||||
|
error(
|
||||||
{:parse_error,
|
{:parse_error,
|
||||||
"Unexpected #{inspect(unexpected)} at line: #{line}:#{col + 1}. #{message}."}
|
"Unexpected #{inspect(unexpected)} at line: #{line}:#{col + 1}. #{message}."}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue