Skip to content

Commit

Permalink
ts/tree.c(ts-tree-cursor-goto-next-sibling): new procedure.
Browse files Browse the repository at this point in the history
  • Loading branch information
Z572 committed Jun 29, 2023
1 parent 496b23e commit d92581c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/tcursor.scm
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@

(let ((cursor (ts-tree-cursor-new root)))
(test-equal "ts-tree-cursor-goto-parent: no parent"
#f (ts-tree-cursor-goto-parent cursor)))))
#f (ts-tree-cursor-goto-parent cursor)))

(let ((cursor (ts-tree-cursor-new root)))
(test-equal "ts-tree-cursor-goto-next-sibling"
(ts-node-next-sibling (ts-node-child (ts-node-child root 0) 0))
(begin (ts-tree-cursor-goto-first-child cursor)
(ts-tree-cursor-goto-first-child cursor)
(ts-tree-cursor-goto-next-sibling cursor)
(ts-tree-cursor-current-node cursor))))))
13 changes: 13 additions & 0 deletions ts/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,19 @@ SCM_DEFINE(tstc_goto_first_child, "ts-tree-cursor-goto-first-child", 1, 0, 0,
return g_p;
}
#undef FUNC_NAME

SCM_DEFINE(tstc_goto_next_sibling, "ts-tree-cursor-goto-next-sibling", 1, 0, 0,
(SCM cursor),
"")
#define FUNC_NAME s_tstc_goto_next_sibling
{
ASSERT_TSTC(cursor);
Tcursor *tc = FR(cursor);
SCM success=scm_from_bool(ts_tree_cursor_goto_next_sibling(&tc->cursor));
scm_remember_upto_here_1(cursor);
return success;
}

void init_ts_tree() {
#ifndef SCM_MAGIC_SNARFER
#include "tree.x"
Expand Down
1 change: 1 addition & 0 deletions ts/tree.scm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
ts-tree-cursor-current-node
ts-tree-cursor-goto-parent
ts-tree-cursor-goto-first-child
ts-tree-cursor-goto-next-sibling
ts-tree-cursor-new
ts-tree-cursor-reset!
ts-tree-language
Expand Down

0 comments on commit d92581c

Please sign in to comment.