[][src]Module syntex_syntax2::codemap

The CodeMap tracks all the source code used within a single crate, mapping from integer byte positions to the original source code location. Each bit of source parsed during crate parsing (typically files, in-memory strings, or various bits of macro expansion) cover a continuous range of bytes in the CodeMap and are represented by FileMaps. Byte positions are stored in spans and used pervasively in the compiler. They are absolute positions within the CodeMap, which upon request can be converted to line and column information, source code snippets, etc.

Re-exports

pub use self::ExpnFormat::*;

Modules

hygiene

Machinery for hygienic macros, inspired by the MTWT[1] paper.

symbol

An "interner" is a data structure that associates values with usize tags and allows bidirectional lookup; i.e. given a value, one can easily find the type, and vice versa.

Structs

BytePos

A byte offset. Keep this small (currently 32-bits), as AST contains a lot of them.

CharPos

A character offset. Because of multibyte utf8 characters, a byte offset is not equivalent to a character offset. The CodeMap will convert BytePos values to CharPos values as necessary.

CodeMap
DistinctSources
ExpnInfo

Extra information for tracking spans of macro and syntax sugar expansion

FileLines
FileMap

A single source in the CodeMap.

FileMapAndBytePos
FileMapAndLine
FilePathMapping
LineInfo
Loc

A source code location used for error reporting

LocWithOpt

A source code location used as the result of lookup_char_pos_adj

MacroBacktrace
MalformedCodemapPositions
MultiByteChar

Identifies an offset of a multi-byte character in a FileMap

MultiSpan

A collection of spans. Spans have two orthogonal attributes:

NameAndSpan
RealFileLoader

A FileLoader that uses std::fs to load real files.

Span

Spans represent a region of code, used for error reporting. Positions in spans are absolute positions from the beginning of the codemap, not positions relative to FileMaps. Methods on the CodeMap can be used to relate spans back to the original source. You must be careful if the span crosses more than one file - you will not be able to use many of the functions on spans in codemap and you cannot assume that the length of the span = hi - lo; there may be space in the BytePos range between files.

SpanLabel
Spanned

Enums

ExpnFormat

The source of expansion.

SpanLinesError
SpanSnippetError

Constants

DUMMY_SP
NO_EXPANSION
SPAN_DEBUG

Traits

FileLoader

An abstraction over the fs operations used by the Parser.

Pos

Functions

dummy_spanned
original_sp

Return the span itself if it doesn't come from a macro expansion, otherwise return the call site span up to the enclosing_sp by following the expn_info chain.

respan

Type Definitions

FileLinesResult
FileName