Start and Finish Ranges

Return to Contents

When parsing input, the start position and finish position that describe a parsed or lexed chunk are the index of the first item and the last item of that chunk. This was done to match the idea with how array slicing is done in Ada, but it has a few other implications.

Empty chunks are described by a finish position that is less than the start position. For consistency, this is always done as the finish position being only one less than the start.

This convention also differs from the convention used by Frost, Hafiz, and Callaghan (2008). They used start positions corresponding to the first item in a chunk, but finish positions corresponding to the first item after the chunk had ended. Care should be taken to keep this in mind to avoid off-by-one errors.