aboutsummaryrefslogtreecommitdiffstats
path: root/admin/notes/tree-sitter/html-manual/Using-Parser.html
diff options
context:
space:
mode:
authorYuan Fu2022-11-21 13:33:03 -0800
committerYuan Fu2022-11-21 13:33:03 -0800
commiteb1a35adc1c5a1a9d14ec8594580c5eb0e3d28fe (patch)
treebed9c388781db2ab5bfeb38e266d80b2c82e1078 /admin/notes/tree-sitter/html-manual/Using-Parser.html
parentabf40a41aaa71354eee50bedc04fe2123dd3836f (diff)
downloademacs-eb1a35adc1c5a1a9d14ec8594580c5eb0e3d28fe.tar.gz
emacs-eb1a35adc1c5a1a9d14ec8594580c5eb0e3d28fe.zip
; Update tree-sitter starter guide
* admin/notes/tree-sitter/starter-guide: Reflect recent changes. * admin/notes/tree-sitter/html-manual/Using-Parser.html: * admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html: * admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html: * admin/notes/tree-sitter/html-manual/Parser_002dbased-Indentation.html: * admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html: * admin/notes/tree-sitter/html-manual/Multiple-Languages.html: * admin/notes/tree-sitter/html-manual/Language-Definitions.html: Update.
Diffstat (limited to 'admin/notes/tree-sitter/html-manual/Using-Parser.html')
-rw-r--r--admin/notes/tree-sitter/html-manual/Using-Parser.html48
1 files changed, 45 insertions, 3 deletions
diff --git a/admin/notes/tree-sitter/html-manual/Using-Parser.html b/admin/notes/tree-sitter/html-manual/Using-Parser.html
index c478a39e556..a4f31f90897 100644
--- a/admin/notes/tree-sitter/html-manual/Using-Parser.html
+++ b/admin/notes/tree-sitter/html-manual/Using-Parser.html
@@ -33,7 +33,7 @@ developing GNU and promoting software freedom." -->
33<link href="Index.html" rel="index" title="Index"> 33<link href="Index.html" rel="index" title="Index">
34<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 34<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
35<link href="Parsing-Program-Source.html" rel="up" title="Parsing Program Source"> 35<link href="Parsing-Program-Source.html" rel="up" title="Parsing Program Source">
36<link href="Retrieving-Node.html" rel="next" title="Retrieving Node"> 36<link href="Retrieving-Nodes.html" rel="next" title="Retrieving Nodes">
37<link href="Language-Definitions.html" rel="prev" title="Language Definitions"> 37<link href="Language-Definitions.html" rel="prev" title="Language Definitions">
38<style type="text/css"> 38<style type="text/css">
39<!-- 39<!--
@@ -63,7 +63,7 @@ ul.no-bullet {list-style: none}
63<div class="section" id="Using-Parser"> 63<div class="section" id="Using-Parser">
64<div class="header"> 64<div class="header">
65<p> 65<p>
66Next: <a href="Retrieving-Node.html" accesskey="n" rel="next">Retrieving Node</a>, Previous: <a href="Language-Definitions.html" accesskey="p" rel="prev">Tree-sitter Language Definitions</a>, Up: <a href="Parsing-Program-Source.html" accesskey="u" rel="up">Parsing Program Source</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p> 66Next: <a href="Retrieving-Nodes.html" accesskey="n" rel="next">Retrieving Nodes</a>, Previous: <a href="Language-Definitions.html" accesskey="p" rel="prev">Tree-sitter Language Definitions</a>, Up: <a href="Parsing-Program-Source.html" accesskey="u" rel="up">Parsing Program Source</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
67</div> 67</div>
68<hr> 68<hr>
69<span id="Using-Tree_002dsitter-Parser"></span><h3 class="section">37.2 Using Tree-sitter Parser</h3> 69<span id="Using-Tree_002dsitter-Parser"></span><h3 class="section">37.2 Using Tree-sitter Parser</h3>
@@ -176,11 +176,53 @@ there is no way to update the result.
176the root node of the generated syntax tree. 176the root node of the generated syntax tree.
177</p></dd></dl> 177</p></dd></dl>
178 178
179<span id="Be-notified-by-changes-to-the-parse-tree"></span><h3 class="heading">Be notified by changes to the parse tree</h3>
180<span id="index-update-callback_002c-for-tree_002dsitter-parse_002dtree"></span>
181<span id="index-after_002dchange-notifier_002c-for-tree_002dsitter-parse_002dtree"></span>
182<span id="index-tree_002dsitter-parse_002dtree_002c-update-and-after_002dchange-callback"></span>
183<span id="index-notifiers_002c-tree_002dsitter"></span>
184
185<p>A Lisp program might want to be notified of text affected by
186incremental parsing. For example, inserting a comment-closing token
187converts text before that token into a comment. Even
188though the text is not directly edited, it is deemed to be &ldquo;changed&rdquo;
189nevertheless.
190</p>
191<p>Emacs lets a Lisp program to register callback functions
192(a.k.a. <em>notifiers</em>) for this kind of changes. A notifier
193function takes two arguments: <var>ranges</var> and <var>parser</var>.
194<var>ranges</var> is a list of cons cells of the form <code>(<var>start</var>&nbsp;.&nbsp;<var>end</var>)</code><!-- /@w -->, where <var>start</var> and <var>end</var> mark the start and the
195end positions of a range. <var>parser</var> is the parser issuing the
196notification.
197</p>
198<p>Every time a parser reparses a buffer, it compares the old and new
199parse-tree, computes the ranges in which nodes have changed, and
200passes the ranges to notifier functions.
201</p>
202<dl class="def">
203<dt id="index-treesit_002dparser_002dadd_002dnotifier"><span class="category">Function: </span><span><strong>treesit-parser-add-notifier</strong> <em>parser function</em><a href='#index-treesit_002dparser_002dadd_002dnotifier' class='copiable-anchor'> &para;</a></span></dt>
204<dd><p>This function adds <var>function</var> to <var>parser</var>&rsquo;s list of
205after-change notifier functions. <var>function</var> must be a function
206symbol, not a lambda function (see <a href="Anonymous-Functions.html">Anonymous Functions</a>).
207</p></dd></dl>
208
209<dl class="def">
210<dt id="index-treesit_002dparser_002dremove_002dnotifier"><span class="category">Function: </span><span><strong>treesit-parser-remove-notifier</strong> <em>parser function</em><a href='#index-treesit_002dparser_002dremove_002dnotifier' class='copiable-anchor'> &para;</a></span></dt>
211<dd><p>This function removes <var>function</var> from the list of <var>parser</var>&rsquo;s
212after-change notifier functions. <var>function</var> must be a function
213symbol, rather than a lambda function.
214</p></dd></dl>
215
216<dl class="def">
217<dt id="index-treesit_002dparser_002dnotifiers"><span class="category">Function: </span><span><strong>treesit-parser-notifiers</strong> <em>parser</em><a href='#index-treesit_002dparser_002dnotifiers' class='copiable-anchor'> &para;</a></span></dt>
218<dd><p>This function returns the list of <var>parser</var>&rsquo;s notifier functions.
219</p></dd></dl>
220
179</div> 221</div>
180<hr> 222<hr>
181<div class="header"> 223<div class="header">
182<p> 224<p>
183Next: <a href="Retrieving-Node.html">Retrieving Node</a>, Previous: <a href="Language-Definitions.html">Tree-sitter Language Definitions</a>, Up: <a href="Parsing-Program-Source.html">Parsing Program Source</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p> 225Next: <a href="Retrieving-Nodes.html">Retrieving Nodes</a>, Previous: <a href="Language-Definitions.html">Tree-sitter Language Definitions</a>, Up: <a href="Parsing-Program-Source.html">Parsing Program Source</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
184</div> 226</div>
185 227
186 228