diff options
| author | Yuan Fu | 2022-11-21 13:33:03 -0800 |
|---|---|---|
| committer | Yuan Fu | 2022-11-21 13:33:03 -0800 |
| commit | eb1a35adc1c5a1a9d14ec8594580c5eb0e3d28fe (patch) | |
| tree | bed9c388781db2ab5bfeb38e266d80b2c82e1078 /admin/notes/tree-sitter/html-manual/Using-Parser.html | |
| parent | abf40a41aaa71354eee50bedc04fe2123dd3836f (diff) | |
| download | emacs-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.html | 48 |
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> |
| 66 | Next: <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> [<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> | 66 | Next: <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> [<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. | |||
| 176 | the root node of the generated syntax tree. | 176 | the 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 | ||
| 186 | incremental parsing. For example, inserting a comment-closing token | ||
| 187 | converts text before that token into a comment. Even | ||
| 188 | though the text is not directly edited, it is deemed to be “changed” | ||
| 189 | nevertheless. | ||
| 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 | ||
| 193 | function 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> . <var>end</var>)</code><!-- /@w -->, where <var>start</var> and <var>end</var> mark the start and the | ||
| 195 | end positions of a range. <var>parser</var> is the parser issuing the | ||
| 196 | notification. | ||
| 197 | </p> | ||
| 198 | <p>Every time a parser reparses a buffer, it compares the old and new | ||
| 199 | parse-tree, computes the ranges in which nodes have changed, and | ||
| 200 | passes 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'> ¶</a></span></dt> | ||
| 204 | <dd><p>This function adds <var>function</var> to <var>parser</var>’s list of | ||
| 205 | after-change notifier functions. <var>function</var> must be a function | ||
| 206 | symbol, 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'> ¶</a></span></dt> | ||
| 211 | <dd><p>This function removes <var>function</var> from the list of <var>parser</var>’s | ||
| 212 | after-change notifier functions. <var>function</var> must be a function | ||
| 213 | symbol, 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'> ¶</a></span></dt> | ||
| 218 | <dd><p>This function returns the list of <var>parser</var>’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> |
| 183 | Next: <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> [<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> | 225 | Next: <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> [<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 | ||