otp
otp copied to clipboard
Add end_location annotations for parse trees
Based on https://github.com/erlang/otp/pull/3020.
This allows the quoted source code in error messages to underline the range of the error, and can also be used by tools that display source code, as in an IDE.
Example:
foo.erl:18:16: illegal guard expression
% 18| foo(A, B) when is_lit(A), is_list(B) ->
% | ^^^^^^
instead of just
foo.erl:18:16: illegal guard expression
% 18| foo(A, B) when is_lit(A), is_list(B) ->
% | ^
This has only been implemented on the parser level. Adding further support for the scanner to annotate all tokens with end position right away would save the time now spent calculating end positions of tokens by taking the length of the text.