aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Kangas2024-07-21 17:46:12 +0200
committerStefan Kangas2024-07-21 17:47:41 +0200
commit68615a386699f8e6108cb294a2cbc5664948af39 (patch)
tree921ac44799d31eeb1d4577a7363e5417cb353515 /src
parent00adee897ac95912cb9ad6bd8a8d161db71945ac (diff)
downloademacs-68615a386699f8e6108cb294a2cbc5664948af39.tar.gz
emacs-68615a386699f8e6108cb294a2cbc5664948af39.zip
Fix punctuation and doc style in treesit.c
* src/treesit.c (Ftreesit_parser_included_ranges) (Ftreesit_query_capture, treesit_traverse_sibling_helper) (treesit_traverse_match_predicate): Fix punctiation and documentation style in comments and docstrings.
Diffstat (limited to 'src')
-rw-r--r--src/treesit.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/treesit.c b/src/treesit.c
index a0e41add475..7c8c655f561 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -404,7 +404,7 @@ init_treesit_functions (void)
404 buffer's parser list. The discussion can be found in bug#59693. */ 404 buffer's parser list. The discussion can be found in bug#59693. */
405 405
406 406
407/*** Initialization */ 407/*** Initialization */
408 408
409static Lisp_Object Vtreesit_str_libtree_sitter; 409static Lisp_Object Vtreesit_str_libtree_sitter;
410static Lisp_Object Vtreesit_str_tree_sitter; 410static Lisp_Object Vtreesit_str_tree_sitter;
@@ -431,7 +431,7 @@ static Lisp_Object Vtreesit_str_pred;
431 functions. Remember to update docstrings when changing this value. 431 functions. Remember to update docstrings when changing this value.
432 432
433 If we think of programs and AST, it is very rare for any program to 433 If we think of programs and AST, it is very rare for any program to
434 have a very deep AST. For example, you would need 1000+ levels of 434 have a very deep AST. For example, you would need 1000+ levels of
435 nested if-statements, or a struct somehow nested for 1000+ levels. 435 nested if-statements, or a struct somehow nested for 1000+ levels.
436 It's hard for me to imagine any hand-written or machine generated 436 It's hard for me to imagine any hand-written or machine generated
437 program to be like that. So I think 1000 is already generous. If 437 program to be like that. So I think 1000 is already generous. If
@@ -485,10 +485,9 @@ treesit_initialize (void)
485} 485}
486 486
487 487
488/*** Loading language library */ 488/*** Loading language library */
489 489
490/* Translates a symbol treesit-<lang> to a C name 490/* Translate a symbol treesit-<lang> to a C name treesit_<lang>. */
491 treesit_<lang>. */
492static void 491static void
493treesit_symbol_to_c_name (char *symbol_name) 492treesit_symbol_to_c_name (char *symbol_name)
494{ 493{
@@ -758,7 +757,7 @@ Return nil if a grammar library for LANGUAGE is not available. */)
758} 757}
759 758
760 759
761/*** Parsing functions */ 760/*** Parsing functions */
762 761
763static void 762static void
764treesit_check_parser (Lisp_Object obj) 763treesit_check_parser (Lisp_Object obj)
@@ -873,7 +872,7 @@ treesit_record_change (ptrdiff_t start_byte, ptrdiff_t old_end_byte,
873 } 872 }
874} 873}
875 874
876/* Comment (ref:visible-beg-null) The purpose of visible_beg/end is to 875/* Comment (ref:visible-beg-null) The purpose of visible_beg/end is to
877 keep track of "which part of the buffer does the tree-sitter tree 876 keep track of "which part of the buffer does the tree-sitter tree
878 see", in order to update the tree correctly. Visible_beg/end have 877 see", in order to update the tree correctly. Visible_beg/end have
879 two purposes: they "clip" buffer changes within them, and they 878 two purposes: they "clip" buffer changes within them, and they
@@ -1150,7 +1149,7 @@ treesit_read_buffer (void *parser, uint32_t byte_index,
1150} 1149}
1151 1150
1152 1151
1153/*** Functions for parser and node object */ 1152/*** Functions for parser and node object */
1154 1153
1155/* Wrap the parser in a Lisp_Object to be used in the Lisp 1154/* Wrap the parser in a Lisp_Object to be used in the Lisp
1156 machine. */ 1155 machine. */
@@ -1566,7 +1565,7 @@ treesit_parser_live_p (Lisp_Object parser)
1566} 1565}
1567 1566
1568 1567
1569/*** Parser API */ 1568/*** Parser API */
1570 1569
1571DEFUN ("treesit-parser-root-node", 1570DEFUN ("treesit-parser-root-node",
1572 Ftreesit_parser_root_node, Streesit_parser_root_node, 1571 Ftreesit_parser_root_node, Streesit_parser_root_node,
@@ -1739,7 +1738,7 @@ See also `treesit-parser-set-included-ranges'. */)
1739 1738
1740 /* When the parser doesn't have a range set and we call 1739 /* When the parser doesn't have a range set and we call
1741 ts_parser_included_ranges on it, it doesn't return an empty list, 1740 ts_parser_included_ranges on it, it doesn't return an empty list,
1742 but rather return DEFAULT_RANGE. (A single range where start_byte 1741 but rather return DEFAULT_RANGE. (A single range where start_byte
1743 = 0, end_byte = UINT32_MAX). So we need to track whether the 1742 = 0, end_byte = UINT32_MAX). So we need to track whether the
1744 parser is ranged ourselves. */ 1743 parser is ranged ourselves. */
1745 if (NILP (XTS_PARSER (parser)->last_set_ranges)) 1744 if (NILP (XTS_PARSER (parser)->last_set_ranges))
@@ -1842,8 +1841,8 @@ treesit_check_node (Lisp_Object obj)
1842 xsignal1 (Qtreesit_node_buffer_killed, obj); 1841 xsignal1 (Qtreesit_node_buffer_killed, obj);
1843} 1842}
1844 1843
1845/* Checks that OBJ is a positive integer and it is within the visible 1844/* Check that OBJ is a positive integer and it is within the visible
1846 portion of BUF. */ 1845 portion of BUF. */
1847static void 1846static void
1848treesit_check_position (Lisp_Object obj, struct buffer *buf) 1847treesit_check_position (Lisp_Object obj, struct buffer *buf)
1849{ 1848{
@@ -2360,7 +2359,7 @@ produced by tree-sitter. */)
2360} 2359}
2361 2360
2362 2361
2363/*** Query functions */ 2362/*** Query functions */
2364 2363
2365/* Convert a Lisp string to its printed representation in the tree-sitter 2364/* Convert a Lisp string to its printed representation in the tree-sitter
2366 query syntax. */ 2365 query syntax. */
@@ -2998,7 +2997,7 @@ the query. */)
2998 test for predicates. If predicates pass, then all good, if 2997 test for predicates. If predicates pass, then all good, if
2999 predicates don't pass, revert the result back to the result 2998 predicates don't pass, revert the result back to the result
3000 before this loop (PREV_RESULT). (Predicates control the entire 2999 before this loop (PREV_RESULT). (Predicates control the entire
3001 match.) This way we don't need to create a list of captures in 3000 match.) This way we don't need to create a list of captures in
3002 every for loop and nconc it to RESULT every time. That is indeed 3001 every for loop and nconc it to RESULT every time. That is indeed
3003 the initial implementation in which Yoav found nconc being the 3002 the initial implementation in which Yoav found nconc being the
3004 bottleneck (98.4% of the running time spent on nconc). */ 3003 bottleneck (98.4% of the running time spent on nconc). */
@@ -3076,7 +3075,7 @@ the query. */)
3076} 3075}
3077 3076
3078 3077
3079/*** Navigation */ 3078/*** Navigation */
3080 3079
3081static inline void 3080static inline void
3082treesit_assume_true (bool val) 3081treesit_assume_true (bool val)
@@ -3193,7 +3192,7 @@ treesit_traverse_sibling_helper (TSTreeCursor *cursor,
3193 if (ts_node_eq (first_child, start)) 3192 if (ts_node_eq (first_child, start))
3194 return false; 3193 return false;
3195 3194
3196 /* PROBE is always DELTA siblings ahead of CURSOR. */ 3195 /* PROBE is always DELTA siblings ahead of CURSOR. */
3197 TSTreeCursor probe = ts_tree_cursor_copy (cursor); 3196 TSTreeCursor probe = ts_tree_cursor_copy (cursor);
3198 /* This is position of PROBE minus position of CURSOR. */ 3197 /* This is position of PROBE minus position of CURSOR. */
3199 ptrdiff_t delta = 0; 3198 ptrdiff_t delta = 0;
@@ -3477,7 +3476,7 @@ treesit_traverse_match_predicate (TSTreeCursor *cursor, Lisp_Object pred,
3477 return true; 3476 return true;
3478 } 3477 }
3479 } 3478 }
3480 /* Returning false is better than UB. */ 3479 /* Returning false is better than UB. */
3481 return false; 3480 return false;
3482} 3481}
3483 3482
@@ -3990,7 +3989,7 @@ DEFUN ("treesit-available-p", Ftreesit_available_p,
3990} 3989}
3991 3990
3992 3991
3993/*** Initialization */ 3992/*** Initialization */
3994 3993
3995/* Initialize the tree-sitter routines. */ 3994/* Initialize the tree-sitter routines. */
3996void 3995void