branch: elpa/clojure-ts-mode commit 2ecde0c4255b3093d0f2fc6967835e2e34cf029f Author: Bozhidar Batsov <bozhi...@batsov.dev> Commit: Bozhidar Batsov <bozhi...@batsov.dev>
[Docs] Small tweaks to the design document --- doc/design.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/design.md b/doc/design.md index 7555a385d0..fb5d50b56a 100644 --- a/doc/design.md +++ b/doc/design.md @@ -22,22 +22,22 @@ In short: ## Important Definitions -- Parser: A dynamic library compiled from C source code that is generated by the Tree-sitter tool. A parser reads source code for a particular language and produces a syntax tree. -- Grammar: The rules that define how a parser will create the syntax tree for a language. The grammar is written in JavaScript. Tree-sitter tooling consumes the grammar as input and outputs C source (which can be compiled into a parser) -- Syntax Tree: a tree data structure comprised of syntax nodes that represents some source code text. - - Concrete Syntax Tree: Syntax trees that contain nodes for every token in the source code, including things likes brackets and parentheses. Tree-sitter creates Concrete Syntax Trees. - - Abstract Syntax Tree: A syntax tree with less important details removed. An AST may contain a node for a list, but not individual parentheses. Tree-sitter does not create Abstract Syntax Trees. -- Syntax Node: A node in a syntax tree. It represents some subset of a source code text. Each node has a type, defined by the grammar used to produce it. Some common node types represent language constructs like strings, integers, operators. - - Named Syntax Node: A node that can be identified by a name given to it in the Tree-sitter Grammar. In clojure-ts-mode, `list_lit` is a named node for lists. - - Anonymous Syntax Node: A node that cannot be identified by a name. In the Grammar these are identified by simple strings, not by complex Grammar rules. In clojure-ts-mode, `"("` and `")"` are anonymous nodes. -- Font Locking: What Emacs calls "Syntax Highlighting". +- **Parser**: A dynamic library compiled from C source code that is generated by the Tree-sitter tool. A parser reads source code for a particular language and produces a syntax tree. +- **Grammar**: The rules that define how a parser will create the syntax tree for a language. The grammar is written in JavaScript. Tree-sitter tooling consumes the grammar as input and outputs C source (which can be compiled into a parser) +- **Syntax Tree**: a tree data structure comprised of syntax nodes that represents some source code text. + - **Concrete Syntax Tree**: Syntax trees that contain nodes for every token in the source code, including things likes brackets and parentheses. Tree-sitter creates Concrete Syntax Trees. + - **Abstract Syntax Tree**: A syntax tree with less important details removed. An AST may contain a node for a list, but not individual parentheses. Tree-sitter does not create Abstract Syntax Trees. +- **Syntax Node**: A node in a syntax tree. It represents some subset of a source code text. Each node has a type, defined by the grammar used to produce it. Some common node types represent language constructs like strings, integers, operators. + - **Named Syntax Node**: A node that can be identified by a name given to it in the Tree-sitter Grammar. In clojure-ts-mode, `list_lit` is a named node for lists. + - **Anonymous Syntax Node**: A node that cannot be identified by a name. In the Grammar these are identified by simple strings, not by complex Grammar rules. In clojure-ts-mode, `"("` and `")"` are anonymous nodes. +- **Font Locking**: The Emacs terminology for "syntax highlighting". ## tree-sitter-clojure `clojure-ts-mode` uses the experimental version tree-sitter-clojure grammar, which can be found at <https://github.com/sogaiu/tree-sitter-clojure/tree/unstable-20250526>. The -`clojure-ts-mode` grammar provides very basic, low level nodes that try to match +grammar provides very basic, low level nodes that try to match Clojure's very light syntax. There are nodes to represent: @@ -86,8 +86,8 @@ will produce a parse tree like so ``` Although it's somewhat closer to how Clojure treats metadata itself, in the -context of a text editor it creates some problems, which were discussed [here](https://github.com/sogaiu/tree-sitter-clojure/issues/65). To -name a few: +context of a text editor it creates some problems, which were discussed +[here](https://github.com/sogaiu/tree-sitter-clojure/issues/65). To name a few: - `forward-sexp` command would skip both, metadata and the node it's attached to. Called from an opening paren it would signal an error "No more sexp to