#source #position #compiler #sourcemap #rustc

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.

3 releases

0.1.2 Jun 30, 2019
0.1.1 Mar 3, 2018
0.1.0 May 29, 2017

#161 in Data structures

Download history 11/week @ 2019-07-23 1/week @ 2019-07-30 18/week @ 2019-08-06 15/week @ 2019-08-13 46/week @ 2019-08-20 54/week @ 2019-08-27 51/week @ 2019-09-03 38/week @ 2019-09-10 75/week @ 2019-09-17 54/week @ 2019-09-24 15/week @ 2019-10-01 26/week @ 2019-10-08 187/week @ 2019-10-15 205/week @ 2019-10-22 382/week @ 2019-10-29

230 downloads per month
Used in 7 crates (5 directly)

MIT/Apache

16KB
248 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