Hi
I am dabbling a bit with parser combinators. And one of the parsers i need is one for escaped characters. When trying to write doctests for it i failed miserably. Took me quite some time to realize the problem is the way doctests handle backslashes.
The following doctest succeeds for me:
defmodule Doctest do
@moduledoc """
iex> "\$"
"$"
iex> "\\$"
"$"
iex> "\\\$"
"$"
iex> "\\\$"
"\$"
iex> "\\\$"
"\\$"
iex> "\\\$"
"\\\$"
iex> "\\\\$"
"\\\\$"
"""
end
And i have trouble explaining to myself why it does. Why do three backslashes vanish and four suddenly matter completely.
Anyone with insights?