Skip to content

Commit

Permalink
Shortcut integer parsing (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilagamma authored Mar 4, 2023
1 parent 16a4193 commit ba47414
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/bento/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ defmodule Bento.Parser do
defp integer_start(other), do: syntax_error(other)

defp integer_continue("e" <> rest, acc) do
{acc |> Enum.reverse() |> IO.iodata_to_binary() |> String.to_integer(), rest}
{acc |> Enum.reverse() |> List.to_integer(), rest}
end

defp integer_continue(<<digit>> <> rest, acc) when digit in '0123456789' do
Expand All @@ -109,7 +109,7 @@ defmodule Bento.Parser do
end

defp string_length(":" <> rest, acc) do
string_contents(acc |> Enum.reverse() |> IO.iodata_to_binary() |> String.to_integer(), rest)
string_contents(acc |> Enum.reverse() |> List.to_integer(), rest)
end

defp string_length(other, _acc), do: syntax_error(other)
Expand Down

0 comments on commit ba47414

Please sign in to comment.