Ergo.Combinators.lookahead
You're seeing just the function
lookahead
, go back to Ergo.Combinators module for more information.
Link to this function
lookahead(parser)
The lookahead
parser accepts a parser and matches it but does not update the context when it succeeds.
Example
iex> alias Ergo.{Context, Terminals, Combinators}
iex> context = Context.new("Hello World")
iex> parser = Combinators.lookahead(Terminals.literal("Hello"))
iex> parser.(context)
%Context{status: :ok, ast: nil, input: "Hello World", char: 0, index: 0, line: 1, col: 1}
iex> alias Ergo.{Context, Terminals, Combinators}
iex> context = Context.new("Hello World")
iex> parser = Combinators.lookahead(Terminals.literal("Helga"))
iex> parser.(context)
%Context{status: {:error, :lookahead_fail}, ast: [?l, ?e, ?H], char: ?l, index: 3, col: 4, input: "lo World"}