Pantagruel v0.0.4 Pantagruel.Parse View Source
The parser takes a binary representing a Pantagruel program and constructs an AST. It expects the binary to have been preprocessed by the Scan module.
Link to this section Summary
Types
A Pantagruel AST consists of a list of section nodes, each of which
represent one section of the program delimited by the ;;
separator
Link to this section Types
combinator_resp() :: {:ok, t(), binary(), map(), {pos_integer(), pos_integer()}, pos_integer()}
A Pantagruel AST consists of a list of section nodes, each of which
represent one section of the program delimited by the ;;
separator.
A section has two components: the head and the body. The head contains declarations, either function declarations or domain alias declarations. The body contains expressions which should evaluate to true propositions about the program being described.
A section must have at least one statement in its head. The body is optional.
Link to this section Functions
expression(binary(), keyword()) :: {:ok, [term()], rest, context, line, byte_offset} | {:error, reason, rest, context, line, byte_offset} when line: {pos_integer(), byte_offset}, byte_offset: pos_integer(), rest: binary(), reason: String.t(), context: map()
Parses the given binary
as expression.
Returns {:ok, [token], rest, context, line, byte_offset}
or
{:error, reason, rest, context, line, byte_offset}
.
Options
:line
- the initial line, defaults to 1:byte_offset
- the initial byte offset, defaults to 0:context
- the initial context value. It will be converted to a map
program(binary(), keyword()) :: {:ok, [term()], rest, context, line, byte_offset} | {:error, reason, rest, context, line, byte_offset} when line: {pos_integer(), byte_offset}, byte_offset: pos_integer(), rest: binary(), reason: String.t(), context: map()
Parses the given binary
as program.
Returns {:ok, [token], rest, context, line, byte_offset}
or
{:error, reason, rest, context, line, byte_offset}
.
Options
:line
- the initial line, defaults to 1:byte_offset
- the initial byte offset, defaults to 0:context
- the initial context value. It will be converted to a map