Zig.Parser.Error (zigler v0.9.1) View Source
parses errors emitted by the zig compiler
Link to this section Summary
Functions
given a code file path and a line number, calculates the file and line number
of the source document from which it came. Strongly depends on having
fencing comments of the form // ref: <file> line: <line>
in order to backtrack
this information.
Parses the given binary
as check_ref.
given a zig compiler error message, a directory for the code file, and the temporary
directory where code assembly is taking place, return an appropriate CompileError
struct which can be raised to emit a sensible compiler error message.
Parses the given binary
as parse_error.
Link to this section Functions
Specs
backreference(Path.t(), non_neg_integer()) :: {Path.t(), non_neg_integer()}
given a code file path and a line number, calculates the file and line number
of the source document from which it came. Strongly depends on having
fencing comments of the form // ref: <file> line: <line>
in order to backtrack
this information.
Specs
check_ref(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 check_ref.
Returns {:ok, [token], rest, context, position, byte_offset}
or
{:error, reason, rest, context, line, byte_offset}
where position
describes the location of the check_ref (start position) as {line, column_on_line}
.
Options
:byte_offset
- the byte offset for the whole binary, defaults to 0:line
- the line and the byte offset into that line, defaults to{1, byte_offset}
:context
- the initial context value. It will be converted to a map
given a zig compiler error message, a directory for the code file, and the temporary
directory where code assembly is taking place, return an appropriate CompileError
struct which can be raised to emit a sensible compiler error message.
The temporary directory is stripped (when reasonable) in favor of a "true" source file and any filename substitutions are performed as well.
Specs
parse_error(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 parse_error.
Returns {:ok, [token], rest, context, position, byte_offset}
or
{:error, reason, rest, context, line, byte_offset}
where position
describes the location of the parse_error (start position) as {line, column_on_line}
.
Options
:byte_offset
- the byte offset for the whole binary, defaults to 0:line
- the line and the byte offset into that line, defaults to{1, byte_offset}
:context
- the initial context value. It will be converted to a map