lambda icon indicating copy to clipboard operation
lambda copied to clipboard

AST Node Coordinates

Open 71104 opened this issue 9 years ago • 0 comments

Store coordinates in each AST node. Coordinates are indications on how to find the corresponding source code in the original source stream.

Each AST node is associated to a span of text in the source stream. Therefore, each AST node shall be associated the following coordinates:

  • start offset (index of the first character of the corresponding piece of code in the source stream);
  • end offset (past-the-end index, i.e. index of the first character not belonging to the corresponding piece of code in the source stream);
  • start line number (line number of the character at the start offset);
  • start line offset (offset of the first character of the corresponding piece of code within the start line);
  • end line number (line number of the last character of the corresponding piece of code, note that this is not the same character at the end offset);
  • end line offset (offset of the last character of the corresponding piece of code within the end line).

This feature will be exposed by the AST API and will allow for:

  • more detailed error messages that include line numbers and offsets,
  • source maps,
  • step-by-step debugging,
  • possibly more.

71104 avatar Aug 28 '15 11:08 71104