Module syntex_syntax::codemap [] [src]

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.

Reexports

pub use self::ExpnFormat::*;

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
ExpnId
ExpnInfo

Extra information for tracking spans of macro and syntax sugar expansion

FileLines
FileMap

A single source in the CodeMap.

FileMapAndBytePos
FileMapAndLine
LineInfo
Loc

A source code location used for error reporting

LocWithOpt

A source code location used as the result of lookup_char_pos_adj

MalformedCodemapPositions
MultiByteChar

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

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.

Spanned

Enums

ExpnFormat

The source of expansion.

SpanLinesError
SpanSnippetError

Constants

COMMAND_LINE_EXPN
COMMAND_LINE_SP
DUMMY_SP
NO_EXPANSION

Statics

SPAN_DEBUG

Traits

FileLoader

An abstraction over the fs operations used by the Parser.

Pos

Functions

dummy_spanned
mk_sp
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
spanned

Type Definitions

FileLinesResult
FileName