2022-07-23 17:15:08 +00:00
|
|
|
defmodule MfmParser.Reader do
|
|
|
|
def peek(input) do
|
|
|
|
next_char = input |> String.first()
|
|
|
|
|
|
|
|
case next_char do
|
|
|
|
nil -> :eof
|
2022-07-24 05:55:55 +00:00
|
|
|
_ -> next_char
|
2022-07-23 17:15:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-07-24 23:21:02 +00:00
|
|
|
def peek(input, steps) do
|
|
|
|
nth_char = input |> String.at(steps - 1)
|
|
|
|
|
|
|
|
case nth_char do
|
|
|
|
nil -> :eof
|
|
|
|
_ -> nth_char
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-07-23 17:15:08 +00:00
|
|
|
def next(input) do
|
|
|
|
{next_char, rest} = String.split_at(input, 1)
|
|
|
|
|
|
|
|
case next_char do
|
|
|
|
"" -> :eof
|
2022-07-24 05:55:55 +00:00
|
|
|
_ -> {next_char, rest}
|
2022-07-23 17:15:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|