|
From: | BTuin |
Subject: | New tree-sitter mode: bison-ts-mode |
Date: | Thu, 21 Sep 2023 22:15:45 +0200 |
User-agent: | Mozilla Thunderbird |
Hello, I'd like to propose a new tree-sitter mode for Emacs, bison-ts-mode.This is a major mode for GNU Bison grammar files, and it supports the embedded languages C, C++ and Java. Bison also supports D, but this language is not yet supported in Emacs so this mode does not support it either.
Since Bison is a superset of Yacc, it should work with Yacc without modification.
The grammar is available here: <https://gitlab.com/btuin2/tree-sitter-bison>This mode auto-detects the embedded language in the file if the directive "%language" is set.
In addition of the mode, three patches are joined (should I open a bug report for those?).
The first one is to add some missing rules in c-ts-mode. Currently there is no rule if an identifier in a declaration is on a new line.
In these two cases, "variable_name" is not indented: static myttype * variable_name; static myttype variable_name; The new behavior is the same as c-mode.The second one fix an edge case with multiple languages indentation. Here is a simple example:
// language_A { // language_B } // language_AHere, brackets are managed by language_A, but everything inside is managed by language_B. Meaning that if the pointer is at the beginning of the third line (with the closing bracket), it will use language_B's indent rules. But if the point is located on the bracket, it will use language_A's rules.
The third patch simply extracts java-ts-mode's feature list in a variable, to allow to reuse it.
Huge thanks to Yuan Fu for his help and his amazing work with tree-sitter. I'll need to sign the copyright assignment.
0001-Add-missing-indent-rules-in-c-ts-mode.patch
Description: Text Data
0002-Fix-tree-sitter-indentation-conflict-with-multiple-l.patch
Description: Text Data
0003-Extract-feature-list-of-java-ts-mode-in-a-variable.patch
Description: Text Data
bison-ts-mode.el
Description: Text Data
[Prev in Thread] | Current Thread | [Next in Thread] |