The location of byte byte of the value of literal (a string literal node from
compiler_get_nodes); byte == value.count is the end of the value. ok is false when the
literal's source cannot be read again, or does not decode to the node's value (a string the
compiler built rather than read): the location is then where the literal starts.
#import "Extensions/String_Literal";
Where a byte of a string literal's value sits in the source.
Compile-time code that checks a string it was given (a query, a pattern, a format) can report a problem at the exact character instead of at the whole literal:
check_sql :: (code: Code) {
literal := cast(*Code_Literal) compiler_get_nodes(code);
error_at := find_problem(literal._string);
location := String_Literal.location_of_byte(literal, error_at);
compiler_report("syntax error", location);
}Not run: the example is marked ignore.
Not run: it is a compile-time macro that reports to the compiler.
Both quoted literals (with every escape) and here-strings (#string, #string,cr,
#string,\%) are mapped. The source is read through the compiler's file system, so the
editor maps against the unsaved buffer.