Terminals have an associated location, analagous to the old location annotation, even when origin tracking is enabled on nonterminals. When a production has terminal children, sometimes we use the terminal locations in error messages, rather than querying the parsed origin info..
When constructing terminals in an AST we should use the dynamic origin location rather than the compile-time one from the qutoted AST, if possible.
Documentation
Added a few comments.
Testing
Checked the 1 ++ 2 gives the correct error location.
Changes
Terminals have an associated location, analagous to the old location annotation, even when origin tracking is enabled on nonterminals. When a production has terminal children, sometimes we use the terminal locations in error messages, rather than querying the parsed origin info..
When constructing terminals in an AST we should use the dynamic origin location rather than the compile-time one from the qutoted AST, if possible.
Documentation
Added a few comments.
Testing
Checked the
1 ++ 2
gives the correct error location.