#error-reporting #source #position #compiler #file-line #source-map #line-column

codemap

A data structure for efficiently storing source code position and span information (e.g. in a compiler AST), and mapping it back to file/line/column locations for error reporting and suggestions.

4 releases

Uses old Rust 2015

0.1.3 Apr 12, 2020
0.1.2 Jun 30, 2019
0.1.1 Mar 3, 2018
0.1.0 May 29, 2017

#465 in Data structures

Download history 16618/week @ 2024-07-24 13827/week @ 2024-07-31 17653/week @ 2024-08-07 16986/week @ 2024-08-14 16462/week @ 2024-08-21 16049/week @ 2024-08-28 18999/week @ 2024-09-04 16253/week @ 2024-09-11 18546/week @ 2024-09-18 17731/week @ 2024-09-25 19952/week @ 2024-10-02 17847/week @ 2024-10-09 19795/week @ 2024-10-16 18662/week @ 2024-10-23 19385/week @ 2024-10-30 14663/week @ 2024-11-06

75,978 downloads per month
Used in 115 crates (19 directly)

MIT/Apache

18KB
332 lines

CodeMap

Documentation

Build Status

A data structure for tracking source positions in language implementations, inspired by the SourceMap (formerly CodeMap) type in rustc's libsyntax.

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.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps