Clarify distinction btwn tree padding, tree offset, node position

- Node position is public. It represents the node's first character
  index in the document.
- Tree offset is private. It represents the distance between the tree's
  first character index and it's parent's first character index.
- Tree padding is private. It represents the amount of whitespace
  (or other separator characters) immediately preceding the tree.
This commit is contained in:
Max Brunsfeld 2014-08-28 13:22:06 -07:00
parent 226ffd6b5b
commit 3430a5edcc
6 changed files with 126 additions and 78 deletions

View file

@ -22,9 +22,9 @@ static int advance(TSLexer *lexer) {
static TSTree *accept(TSLexer *lexer, TSSymbol symbol, int is_hidden) {
size_t current_position = ts_lexer_position(lexer);
size_t size = current_position - lexer->token_start_position;
size_t offset = lexer->token_start_position - lexer->token_end_position;
size_t padding = lexer->token_start_position - lexer->token_end_position;
lexer->token_end_position = current_position;
return ts_tree_make_leaf(symbol, size, offset, is_hidden);
return ts_tree_make_leaf(symbol, size, padding, is_hidden);
}
TSLexer ts_lexer_make() {