diff options
| author | Yuan Fu | 2022-10-05 14:11:33 -0700 |
|---|---|---|
| committer | Yuan Fu | 2022-10-05 14:11:33 -0700 |
| commit | cb183f6467401fb5ed2b7fc98ca75be9d943cbe3 (patch) | |
| tree | ef42ea6ae71e0829d900ffb46d8306fbba962a8e /admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html | |
| parent | 1ea503ed4b3a14b3dc0a597cfbfe57d73b871422 (diff) | |
| download | emacs-cb183f6467401fb5ed2b7fc98ca75be9d943cbe3.tar.gz emacs-cb183f6467401fb5ed2b7fc98ca75be9d943cbe3.zip | |
Add tree-sitter admin notes
starter-guide: Guide on writing major mode features.
build-module: Script for building official language definitions.
html-manual: HTML version of the manual for easy access.
* admin/notes/tree-sitter/build-module/README: New file.
* admin/notes/tree-sitter/build-module/batch.sh: New file.
* admin/notes/tree-sitter/build-module/build.sh: New file.
* admin/notes/tree-sitter/starter-guide: New file.
* admin/notes/tree-sitter/html-manual/Accessing-Node.html: New file.
* admin/notes/tree-sitter/html-manual/Language-Definitions.html: New file.
* admin/notes/tree-sitter/html-manual/Multiple-Languages.html: New file.
* admin/notes/tree-sitter/html-manual/Parser_002dbased-Font-Lock.html:
New file.
* admin/notes/tree-sitter/html-manual/Parser_002dbased-Indentation.html:
New file.
* admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html: New
file.
* admin/notes/tree-sitter/html-manual/Pattern-Matching.html: New file.
* admin/notes/tree-sitter/html-manual/Retrieving-Node.html: New file.
* admin/notes/tree-sitter/html-manual/Tree_002dsitter-C-API.html: New
file.
* admin/notes/tree-sitter/html-manual/Using-Parser.html: New file.
* admin/notes/tree-sitter/html-manual/build-manual.sh: New file.
* admin/notes/tree-sitter/html-manual/manual.css: New file.
Diffstat (limited to 'admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html')
| -rw-r--r-- | admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html b/admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html new file mode 100644 index 00000000000..7b6e51468a6 --- /dev/null +++ b/admin/notes/tree-sitter/html-manual/Parsing-Program-Source.html | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
| 2 | <html> | ||
| 3 | <!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ --> | ||
| 4 | <head> | ||
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
| 6 | <!-- This is the GNU Emacs Lisp Reference Manual | ||
| 7 | corresponding to Emacs version 29.0.50. | ||
| 8 | |||
| 9 | Copyright © 1990-1996, 1998-2022 Free Software Foundation, | ||
| 10 | Inc. | ||
| 11 | |||
| 12 | Permission is granted to copy, distribute and/or modify this document | ||
| 13 | under the terms of the GNU Free Documentation License, Version 1.3 or | ||
| 14 | any later version published by the Free Software Foundation; with the | ||
| 15 | Invariant Sections being "GNU General Public License," with the | ||
| 16 | Front-Cover Texts being "A GNU Manual," and with the Back-Cover | ||
| 17 | Texts as in (a) below. A copy of the license is included in the | ||
| 18 | section entitled "GNU Free Documentation License." | ||
| 19 | |||
| 20 | (a) The FSF's Back-Cover Text is: "You have the freedom to copy and | ||
| 21 | modify this GNU manual. Buying copies from the FSF supports it in | ||
| 22 | developing GNU and promoting software freedom." --> | ||
| 23 | <title>Parsing Program Source (GNU Emacs Lisp Reference Manual)</title> | ||
| 24 | |||
| 25 | <meta name="description" content="Parsing Program Source (GNU Emacs Lisp Reference Manual)"> | ||
| 26 | <meta name="keywords" content="Parsing Program Source (GNU Emacs Lisp Reference Manual)"> | ||
| 27 | <meta name="resource-type" content="document"> | ||
| 28 | <meta name="distribution" content="global"> | ||
| 29 | <meta name="Generator" content="makeinfo"> | ||
| 30 | <meta name="viewport" content="width=device-width,initial-scale=1"> | ||
| 31 | |||
| 32 | <link href="index.html" rel="start" title="Top"> | ||
| 33 | <link href="Index.html" rel="index" title="Index"> | ||
| 34 | <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> | ||
| 35 | <link href="index.html" rel="up" title="Top"> | ||
| 36 | <link href="Abbrevs.html" rel="next" title="Abbrevs"> | ||
| 37 | <link href="Syntax-Tables.html" rel="prev" title="Syntax Tables"> | ||
| 38 | <style type="text/css"> | ||
| 39 | <!-- | ||
| 40 | a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em} | ||
| 41 | a.summary-letter {text-decoration: none} | ||
| 42 | blockquote.indentedblock {margin-right: 0em} | ||
| 43 | div.display {margin-left: 3.2em} | ||
| 44 | div.example {margin-left: 3.2em} | ||
| 45 | kbd {font-style: oblique} | ||
| 46 | pre.display {font-family: inherit} | ||
| 47 | pre.format {font-family: inherit} | ||
| 48 | pre.menu-comment {font-family: serif} | ||
| 49 | pre.menu-preformatted {font-family: serif} | ||
| 50 | span.nolinebreak {white-space: nowrap} | ||
| 51 | span.roman {font-family: initial; font-weight: normal} | ||
| 52 | span.sansserif {font-family: sans-serif; font-weight: normal} | ||
| 53 | span:hover a.copiable-anchor {visibility: visible} | ||
| 54 | ul.no-bullet {list-style: none} | ||
| 55 | --> | ||
| 56 | </style> | ||
| 57 | <link rel="stylesheet" type="text/css" href="./manual.css"> | ||
| 58 | |||
| 59 | |||
| 60 | </head> | ||
| 61 | |||
| 62 | <body lang="en"> | ||
| 63 | <div class="chapter" id="Parsing-Program-Source"> | ||
| 64 | <div class="header"> | ||
| 65 | <p> | ||
| 66 | Next: <a href="Abbrevs.html" accesskey="n" rel="next">Abbrevs and Abbrev Expansion</a>, Previous: <a href="Syntax-Tables.html" accesskey="p" rel="prev">Syntax Tables</a>, Up: <a href="index.html" accesskey="u" rel="up">Emacs Lisp</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> | ||
| 68 | <hr> | ||
| 69 | <span id="Parsing-Program-Source-1"></span><h2 class="chapter">37 Parsing Program Source</h2> | ||
| 70 | |||
| 71 | <p>Emacs provides various ways to parse program source text and produce a | ||
| 72 | <em>syntax tree</em>. In a syntax tree, text is no longer a | ||
| 73 | one-dimensional stream but a structured tree of nodes, where each node | ||
| 74 | representing a piece of text. Thus a syntax tree can enable | ||
| 75 | interesting features like precise fontification, indentation, | ||
| 76 | navigation, structured editing, etc. | ||
| 77 | </p> | ||
| 78 | <p>Emacs has a simple facility for parsing balanced expressions | ||
| 79 | (see <a href="Parsing-Expressions.html">Parsing Expressions</a>). There is also SMIE library for generic | ||
| 80 | navigation and indentation (see <a href="SMIE.html">Simple Minded Indentation Engine</a>). | ||
| 81 | </p> | ||
| 82 | <p>Emacs also provides integration with tree-sitter library | ||
| 83 | (<a href="https://tree-sitter.github.io/tree-sitter">https://tree-sitter.github.io/tree-sitter</a>) if compiled with | ||
| 84 | it. The tree-sitter library implements an incremental parser and has | ||
| 85 | support from a wide range of programming languages. | ||
| 86 | </p> | ||
| 87 | <dl class="def"> | ||
| 88 | <dt id="index-treesit_002davailable_002dp"><span class="category">Function: </span><span><strong>treesit-available-p</strong><a href='#index-treesit_002davailable_002dp' class='copiable-anchor'> ¶</a></span></dt> | ||
| 89 | <dd><p>This function returns non-nil if tree-sitter features are available | ||
| 90 | for this Emacs instance. | ||
| 91 | </p></dd></dl> | ||
| 92 | |||
| 93 | <p>For tree-sitter integration with existing Emacs features, | ||
| 94 | see <a href="Parser_002dbased-Font-Lock.html">Parser-based Font Lock</a>, <a href="Parser_002dbased-Indentation.html">Parser-based Indentation</a>, and | ||
| 95 | <a href="List-Motion.html">Moving over Balanced Expressions</a>. | ||
| 96 | </p> | ||
| 97 | <p>To access the syntax tree of the text in a buffer, we need to first | ||
| 98 | load a language definition and create a parser with it. Next, we can | ||
| 99 | query the parser for specific nodes in the syntax tree. Then, we can | ||
| 100 | access various information about the node, and we can pattern-match a | ||
| 101 | node with a powerful syntax. Finally, we explain how to work with | ||
| 102 | source files that mixes multiple languages. The following sections | ||
| 103 | explain how to do each of the tasks in detail. | ||
| 104 | </p> | ||
| 105 | |||
| 106 | <ul class="section-toc"> | ||
| 107 | <li><a href="Language-Definitions.html" accesskey="1">Tree-sitter Language Definitions</a></li> | ||
| 108 | <li><a href="Using-Parser.html" accesskey="2">Using Tree-sitter Parser</a></li> | ||
| 109 | <li><a href="Retrieving-Node.html" accesskey="3">Retrieving Node</a></li> | ||
| 110 | <li><a href="Accessing-Node.html" accesskey="4">Accessing Node Information</a></li> | ||
| 111 | <li><a href="Pattern-Matching.html" accesskey="5">Pattern Matching Tree-sitter Nodes</a></li> | ||
| 112 | <li><a href="Multiple-Languages.html" accesskey="6">Parsing Text in Multiple Languages</a></li> | ||
| 113 | <li><a href="Tree_002dsitter-C-API.html" accesskey="7">Tree-sitter C API Correspondence</a></li> | ||
| 114 | </ul> | ||
| 115 | </div> | ||
| 116 | <hr> | ||
| 117 | <div class="header"> | ||
| 118 | <p> | ||
| 119 | Next: <a href="Abbrevs.html">Abbrevs and Abbrev Expansion</a>, Previous: <a href="Syntax-Tables.html">Syntax Tables</a>, Up: <a href="index.html">Emacs Lisp</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> | ||
| 120 | </div> | ||
| 121 | |||
| 122 | |||
| 123 | |||
| 124 | </body> | ||
| 125 | </html> | ||