Tree-sitter grammar for comment tags like TODO, FIXME(user).

Overview

tree-sitter-comment

Tree-sitter grammar for comment tags like TODO:, FIXME(user):, etc. Useful to be embedded inside comments.

Syntax

Since comment tags aren't a programming language or have a standard, I have chosen to follow popular conventions for the syntax.

  • Comment tags can contain:
    • Upper case ascii letters
    • Numbers (can't start with one)
    • -, _ (they can't start or end whit these characters)
  • Optionally can have an user linked to the tag inside parentheses ()
  • The name must be followed by : and a whitespace

If you think there are other popular conventions this syntax doesn't cover, feel free to open a issue.

Examples

TODO: something needs to be done
TODO(stsewd): something needs to be done by @stsewd

XXX: fix something else.
XXX:    extra white spaces.

(NOTE: this works too).

NOTE-BUG (stsewd): tags can be separated by `_`
NOTE_BUG: or by `_`.

TODO

  • Detect links?
  • Detect tags that start with # (like when linking to a PR)?

Why C?

Tree-sitter is a LR parser for context-free grammars, that means it works great for grammars that don't require backtracking, or to keep a state for whitespaces (like indentation). For these reasons, parsing languages that need to keep a state or falling back to a general token, it requires some manual parsing in C.

Other grammars

Issues
  • [Rust]: Highlight

    [Rust]: Highlight "safety comments"

    Hello there! It was mentioned in the README that this project is open to suggestions regarding popular comment conventions in other languages. I would like to propose adding highlighting support for "safety comments", a convention that is particularly prevalent among Rust programmers. Safety comments communicate why certain usage of unsafe code indeed does not violate invariants relied upon by the compiler and depended libraries. An example of such usage is given below:

    let mut text: String = get_string_from_somwhere();
    if text.is_ascii() {
        // SAFETY: We have verified that all characters are within the ASCII range.
        // Thus, the following byte-wise operations preserve UTF-8-validity.
        let bytes = unsafe { text.as_bytes_mut() };
        // Do aforementioned byte-wise operations here...
    }
    

    As illustrated above, the keyword I am proposing to add is SAFETY. It would be really neat for safety comments to pop out considering how critical they are to enforcing correctness in code. Thanks!

    opened by Some-Dood 4
  • adding a license

    adding a license

    👋 hello!

    Would you consider adding a license? MIT is most common for tree-sitter grammars but for the purposes of packaging, just about any license will do.

    opened by the-mikedavis 1
  • Fix text tokens

    Fix text tokens

    The following text was being parsed as one single "text" token instead of two

    TODO something
    

    tree-sitter doesn't allow testing anonymous nodes, so bear with me.

    opened by stsewd 0
  • [Question] Is it possible to optionally include the leading space

    [Question] Is it possible to optionally include the leading space

    I'm trying to achieve the equivalent of the highlighting provided by something like https://github.com/folke/todo-comments.nvim or the following emacs screenshot.

    One thing I haven't been able to figure out how to do it is to match the preceding whitespace for a tag if there is any.

    image

    This doesn't seem to be part of the actual comment i.e. this parser I don't think covers it, and I'm also unable to use #offset! to extend the range of the injection so I guess my question is, is this currently possible with a query (as far as you can see) or would it require this parser to be able to include it?

    opened by akinsho 2
  • Tips for downgrading this to an older version of tree-sitter

    Tips for downgrading this to an older version of tree-sitter

    Hi! I'm interested in forking this library and rebuilding it for use in an Atom grammar. I tried doing this with the library as is, but because it the language version is 13

    https://github.com/stsewd/tree-sitter-comment/blob/674c5cbb948b596c3ed664b510dde76e1f21aee3/src/parser.c#L8

    it is incompatible with the current versions of Atom (and Atom might not catch up any time soon).

    I'm completely ignorant about tree-sitter parser side of things. Do you think it's a simple matter of just regenerating the C code with an older version of tree-sitter-cli, but with the same grammar you have here?

    question 
    opened by jonboiser 3
Owner
Santos Gallegos
Python, Neovim, free & open source software 🐍. >>> import this
Santos Gallegos
Coverage-guided grammar aware fuzzer that uses grammar automatons

Gramatron Gramatron is a coverage-guided fuzzer that uses grammar automatons to perform grammar-aware fuzzing. Technical details about our framework a

HexHive 37 May 8, 2022
Flutter TODO application for cs50 final project with hive database.

TODO application TODO apllication for CS50 final project with flutter framework. Video Demo: https://youtu.be/91qB2TgGXTc Description: This is my Fina

Seyyed Mohammad Hossein Nabavi 0 Jul 25, 2022
Reverse engineered source code of the engineowning cheat for cod9 (tags, ignore. Fortnite cheat, engineowning, engineowning cracked, cheat cracked, cod cracked cheat, cod cheat source)

engineowning-cod9 Reverse engineered source code of the engineowning cheat for cod9 Cracked by CODEX notinjector = C:\Windows\Release\ .exe drSYS = C:

null 6 Jul 9, 2022
A method from GH on how to stream a dll without touching disk, TAGS: fortnite cheat fortnite injector dll injector

dll-encryptor People who make pay hacks typically have down syndrome and are incapable of using their brains in any fashion, and yet these bath salt s

Micca 2 Nov 24, 2021
Tuple but with tags.

tagged_tuple Tuple but with tags. Example code: #include <iostream> #include "tagged_tuple.hpp" int main() { // defines binding between types (na

null 2 Nov 17, 2021
Custom BLE firmware for Hanshow E-Paper Shelf Labels / Price Tags

ATC_TLSR_Paper Custom BLE firmware for Hanshow E-Paper Shelf Labels / Price Tags using the TLSR8359 ARM SOC You can support my work via PayPal: https:

null 63 Aug 2, 2022
Probabilistic Risk Analysis Tool (fault tree analysis, event tree analysis, etc.)

SCRAM SCRAM is a Command-line Risk Analysis Multi-tool. This project aims to build a command line tool for probabilistic risk analysis. SCRAM is capab

Olzhas Rakhimov 113 Jul 1, 2022
Parsing Expression Grammar Template Library

Welcome to the PEGTL The Parsing Expression Grammar Template Library (PEGTL) is a zero-dependency C++ header-only parser combinator library for creati

The Art of C++ 1.6k Aug 8, 2022
BNFLite is a C++ template library for lightweight flexible grammar parsers

BNFLite is a C++ template library for lightweight flexible grammar parsers. BNFLite offers creative approach when the developer can specify a language for further parsing directly in the C++ code. Moreover, such "specifications" are executable now!

Alexander S 59 Jul 27, 2022
std::tuple like methods for user defined types without any macro or boilerplate code

Boost.PFR This is a C++14 library for very basic reflection that gives you access to structure elements by index and provides other std::tuple like me

Boost.org 1k Aug 7, 2022
Vimb - the vim like browser is a webkit based web browser that behaves like the vimperator plugin for the firefox and usage paradigms from the great editor vim.

Vimb - the vim like browser is a webkit based web browser that behaves like the vimperator plugin for the firefox and usage paradigms from the great editor vim. The goal of vimb is to build a completely keyboard-driven, efficient and pleasurable browsing-experience.

Daniel Carl 1.2k Aug 4, 2022
A ZX Spectrum-like library built for "dos-like" by Mattias Gustavsson.

ZX-Like A ZX Spectrum-like library built for "dos-like" by Mattias Gustavsson. It allows for the creation of ZX Spectrum like screens for demos, games

Oli Wilkinson 3 Oct 20, 2021
Radical kernel source tree

Radical kernel source tree

sheispeko 41 Jul 19, 2022
Inoki's NB1 kernel source tree based on Nokia official tarball

Inoki's NB1 kernel source tree based on Nokia official tarball

Inoki 2 Dec 27, 2021
Caffeecoin Core integration/staging tree

Caffeecoin Core integration/staging tree https://caffeecoin.com What is Caffeecoin? Caffeecoin is an experimental digital currency that enables instan

null 3 Aug 3, 2022
TWRP device tree for the LG Q7

Device Tree for LG Q7 (mcv5a) The LG Q7 (codenamed "mcv5a") is a low-range smartphone from LG. It was released in May 2018. Basic Spec Sheet OS Androi

Roger Ortiz 5 Jan 11, 2022
Linux kernel source tree

Linux kernel ============ There are several guides for kernel developers and users. These guides can be rendered in a number of formats, like HTML an

GNU/Weeb 3 Jul 5, 2022
Go through the readme... fork ....add....send a pull request .... get yourself in the contribution list...Plant the tree

Hacktoberfest 2021 Follow the README below to get started! Table of contents Getting Started The Process The Process star this repo Fork this reposito

Aditya Deshmukh 6 Jan 5, 2022
My own version of a PCB Christmas Tree, using an ATtiny85 / ATtiny13A.

PCB_ChristmasTree My own version of a PCB Christmas tree, using an ATtiny85 / ATtiny13/13A. Some of the ideas are my own, others are borrowed from var

Marius 2 Dec 15, 2021