zigler v0.3.0 Zigler.Parser.Error 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

Link to this function

backreference(path, line)

View Source
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.

Link to this function

check_ref(binary, opts \\ [])

View Source
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

  • :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

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.

Link to this function

parse_error(binary, opts \\ [])

View Source
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

  • :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