Module starlark::codemap

source ·
Expand description

A data structure for tracking source positions in language implementations The CodeMap tracks all source files and maps positions within them to linear indexes as if all source files were concatenated. This allows a source position to be represented by a small 32-bit Pos indexing into the CodeMap, under the assumption that the total amount of parsed source code will not exceed 4GiB. The CodeMap can look up the source file, line, and column of a Pos or Span, as well as provide source code snippets for error reporting.

Structs

  • A file, and a line and column range within it.
  • A file, and a line and column range within it.
  • A small, Copy, value representing a position in a CodeMap’s file.
  • File name and line and column pairs for a span.
  • The locations of values within a span. All are 0-based, but print out with 1-based.
  • Associate a Span with a value of arbitrary type (e.g. an AST node).