## line-number-db.api
# Compiled by:
#
src/lib/c-kit/src/parser/c-parser.sublib### "The enchanting charms of this sublime science
### reveal only to those who have the courage
### to go deeply into it."
###
### -- Carl Friedrich Gauss
# This api is implemented in:
#
#
src/lib/c-kit/src/parser/stuff/line-number-db.pkg#
api Line_Number_Db {
#
Charpos = Int;
# Char position in a file
Source_Code_Region = (Charpos, Charpos);
# region between two character positions, where it is assumed that
# the first charpos is less than the second
Location
= LOC
{ src_file: String,
begin_line: Int,
begin_col: Int,
end_line: Int,
end_col: Int }
| UNKNOWN;
# encodes the information used to record locations in input sources.
# a location designates a region within a (single) source file
Sourcemap;
#
# A data package maintaining a mapping between character positions
# in an input source and locations.
# This handles multiple source files, which can happen if the input
# has been passed through the C preprocessor.
newmap: { src_file: String } -> Sourcemap;
# Creates a new sourcemap with an initial source file name srcFile
newline: Sourcemap -> Charpos -> Void;
# records a line break in the input source
resynch: Sourcemap -> { pos: Charpos, src_file: Null_Or( String ), line: Int } -> Void;
# switch source file names in response to a directive created by
# an include
parse_directive: Sourcemap -> (Charpos, String) -> Void;
# parse a C preprocessor directive to reset src file name and line number
location: Sourcemap -> Source_Code_Region -> Location;
# maps a region to a location
curr_pos: Sourcemap -> Charpos;
/* returns the current character position in the source represented
* by the sourcemap */
loc_to_string: Location -> String;
#
# format a location as a string
};