#parser #incremental #norg

tree-sitter-norg

Norg grammar for the tree-sitter parsing library

3 unstable releases

0.1.1 Mar 11, 2023
0.1.0 Mar 11, 2023
0.0.1 Mar 11, 2023

#388 in Text editors


Used in 2 crates

MIT license

14MB
466K SLoC

C 465K SLoC JavaScript 861 SLoC // 0.0% comments C++ 111 SLoC Rust 41 SLoC // 0.3% comments

Treesitter parser for Norg

This repository is an attempt at building on the initial tree-sitter-norg parser in order to both decrease the size and increase the speed of the parser.

Upgrades from the old parser include:

  • Grammar-based -- the old parser almost entirely relied on a C++ scanner.cc, which hindered error handling and parsing efficiency.
  • Lightweight - the parser weights 4x less than the first generation parser, greatly thanks to a smarter design and a heavier reliance on the grammar.

Thanks to its smaller size, the parser should be embeddable almost anywhere.


lib.rs:

This crate provides norg language support for the tree-sitter parsing library.

Typically, you will use the language function to add this language to a tree-sitter Parser, and then use the parser to parse some code:

let code = "";
let mut parser = tree_sitter::Parser::new();
parser.set_language(tree_sitter_norg::language()).expect("Error loading norg grammar");
let tree = parser.parse(code, None).unwrap();

Dependencies

~2.8–4MB
~76K SLoC