Parselix
Provides the macro for creating parser and some helper functions.
Summary
Types
ok :: {:ok, any, String.t, %Parselix.Position{horizontal: term, index: term, vertical: term}}
A successful result of product parser. {:ok, RESULT, REMAINDER, NEW_POSITION}
error :: {:error, String.t, %Parselix.Position{horizontal: term, index: term, vertical: term}}
A failed result of product parser. {:error, ERROR_MESSAGE, POSITION}
ok_1 :: {:ok, any, integer}
A successful result of source parser. {:ok, RESULT, LENGTH_OF_CONSUMED_STRING}
product_parser :: (String.t, %Parselix.Position{horizontal: term, index: term, vertical: term} -> ok | error)
A parser generated by parser/2.
source_parser :: (product_parser, any, String.t, %Parselix.Position{horizontal: term, index: term, vertical: term} -> ok | ok_1 | ok_2 | error | error_1)
A parser passed to parser/2.
Parameters
- Its own parser.
- The option which is passed to your parser.
- Target string.
- Current position.
Functions
Macros
Specs:
- parser(term, String.t, source_parser) :: product_parser
Macro for creating a parser.
Result format which you can return in the function.
Example
parser "any" do
fn
_, _, "", position -> {:error, "EOF appeared.", position}
_, _, x, _ -> {:ok, String.first(x), 1}
end
end