mfm-parser/lib/reader.ex

29 lines
474 B
Elixir
Raw Normal View History

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
_ -> next_char
2022-07-23 17:15:08 +00:00
end
end
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
_ -> {next_char, rest}
2022-07-23 17:15:08 +00:00
end
end
end