| 1 | # CodeMap |
| 2 | |
| 3 | **[Documentation](https://docs.rs/codemap)** |
| 4 | |
| 5 | [](https://travis-ci.org/kevinmehall/codemap) |
| 6 | |
| 7 | A data structure for tracking source positions in language implementations, inspired by the |
| 8 | [SourceMap (formerly CodeMap) type in rustc's libsyntax](https://github.com/rust-lang/rust/blob/master/src/libsyntax/source_map.rs). |
| 9 | |
| 10 | The `CodeMap` tracks all source files and maps positions within them to linear indexes as if all |
| 11 | source files were concatenated. This allows a source position to be represented by a small |
| 12 | 32-bit `Pos` indexing into the `CodeMap`, under the assumption that the total amount of parsed |
| 13 | source code will not exceed 4GiB. The `CodeMap` can look up the source file, line, and column |
| 14 | of a `Pos` or `Span`, as well as provide source code snippets for error reporting. |
| 15 | |
| 16 | ## License |
| 17 | |
| 18 | Licensed under either of |
| 19 | |
| 20 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) |
| 21 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |
| 22 | |
| 23 | at your option. |
| 24 | |
| 25 | ### Contribution |
| 26 | |
| 27 | Unless you explicitly state otherwise, any contribution intentionally |
| 28 | submitted for inclusion in the work by you, as defined in the Apache-2.0 |
| 29 | license, shall be dual licensed as above, without any additional terms or |
| 30 | conditions. |