break compile time dependencies inside the search parser

This commit is contained in:
byte[] 2019-12-30 16:14:57 -05:00
parent 0f3cb295a3
commit f278362fda
4 changed files with 14 additions and 8 deletions

View file

@ -1,6 +1,8 @@
defmodule Search.FloatParser do
import NimbleParsec
import Search.Helpers
defp to_number(input), do: Search.Helpers.to_number(input)
defp range(input), do: Search.Helpers.range(input)
space =
choice([string(" "), string("\t"), string("\n"), string("\r"), string("\v"), string("\f")])
@ -33,4 +35,4 @@ defmodule Search.FloatParser do
|> label("a real number, like `2.7182818' or `-10'")
defparsec :parse, float_parser
end
end

View file

@ -1,6 +1,8 @@
defmodule Search.IntParser do
import NimbleParsec
import Search.Helpers
defp to_int(input), do: Search.Helpers.to_int(input)
defp range(input), do: Search.Helpers.range(input)
space =
choice([string(" "), string("\t"), string("\n"), string("\r"), string("\v"), string("\f")])
@ -26,4 +28,4 @@ defmodule Search.IntParser do
|> label("an integer, like `3' or `-10'")
defparsec :parse, int_parser
end
end

View file

@ -1,6 +1,7 @@
defmodule Search.Lexer do
import NimbleParsec
import Search.Helpers
defp to_number(input), do: Search.Helpers.to_number(input)
float =
optional(ascii_char('-+'))
@ -97,4 +98,4 @@ defmodule Search.Lexer do
|> eos()
defparsec :lex, search
end
end

View file

@ -1,6 +1,7 @@
defmodule Search.LiteralParser do
import NimbleParsec
import Search.Helpers
defp to_number(input), do: Search.Helpers.to_number(input)
float =
ascii_string([?0..?9], min: 1)
@ -55,4 +56,4 @@ defmodule Search.LiteralParser do
])
defparsec :parse, literal
end
end