Tree-sitter-mojo

tree-sitter-mojo

My take on Mojo grammar for tree-sitter.

  1. Supports all Mojo syntax described in the nightly language reference and targets the upcoming 1.0.0 release
  2. In general, names of the rules are used as they are described in the language reference
  3. Trying to optimize state count:
    • Python grammar
      • src/parser.c

        #define STATE_COUNT 2788
        #define LARGE_STATE_COUNT 185
        
    • After refactoring and adding Mojo features
      • src/parser.c

        #define STATE_COUNT 3230
        #define LARGE_STATE_COUNT 267
        
  4. neovim-treesitter repo now supports Self-Contained Queries. Added this to keep queries in sync with the grammar
  5. In editors like Ki syntax-node-based code navigation and editing is one of the core features. To improve the usability of this mode, additional adjustments to the grammar may be made
1 Like