A Location identifies where a parser is operating or where it encountered an error. It retains the complete input, an offset into that input, and line and column information derived lazily from the input and offset. section 9.5.1
The offset provides the precise position used by parser operations. The derived line counts newline characters before that position, while the column is measured from the most recent newline or from the beginning of the input.
Location supports several parts of parser error reporting:
- Associates a failure with the input position where it occurred. section 9.5.1
- Allows alternative failures at the same position to be grouped and their messages combined. section 9.8
- Supports readable output containing line and column information, the failing input line, and a caret marking the position. section 9.8
A labeled parser failure
When a parser is wrapped with label, its failure carries a message such as “non-negative integer” together with the Location supplied by the parser implementation. The message identifies what was expected; the Location identifies where it was expected. section 9.5.1
