Ergo.Terminals.delimited_text
You're seeing just the function
delimited_text
, go back to Ergo.Terminals module for more information.
Link to this function
delimited_text(open_char, close_char, opts \\ [])
The delimited_text/2 parser matches a sequence of text delimited open_char
and
close_char
. Because it is expected that open_char
may appear multiple times
within the sequence it balances the tokens to ensure the right number of closing
tokens is matched.
Examples
iex> alias Ergo
iex> alias Ergo.Context
iex> import Ergo.Terminals
iex> parser = delimited_text(?{, ?})
iex> assert %Context{status: :ok, ast: "{return {foo: \"bar\", bar: {baz: \"quux\"}};}", input: ""} = Ergo.parse(parser, "{return {foo: \"bar\", bar: {baz: \"quux\"}};}")
iex> assert %Context{status: :ok, ast: "{function b(y) {return x + y;}; return b;}", input: "foo"} = Ergo.parse(parser, "{function b(y) {return x + y;}; return b;}foo")