mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 03:46:44 +01:00
break compile time dependencies inside the search parser
This commit is contained in:
parent
0f3cb295a3
commit
f278362fda
4 changed files with 14 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue