#tree-sitter #pug #parser #incremental

tree-sitter-pug

pug grammar for the tree-sitter parsing library

1 unstable release

new 0.0.1 Dec 17, 2024

#334 in #incremental

MIT license

1MB
38K SLoC

C 37K SLoC JavaScript 624 SLoC // 0.0% comments Scheme 40 SLoC Rust 32 SLoC // 0.4% comments

Tree-sitter-pug

This is a general tree-sitter parser grammar for the pug language with some extra features built in for Angular and Vue development.

Current state

Everything currently included is relatively bug-free, but the structure/name of some rules may change before we declare this parser "complete".

There is list of todos at the top of grammar.js, but the summary is: all of the basics are supported. There are tests for every scenario supported, so you can just have a look through ./test/corpus/*.txt to see exactly which scenarios are supported and have been tested.

Feel free to open an issue/pull request if there's something missing/broken.

Developing

How to run & test:

npm install -g tree-sitter-cli
tree-sitter generate && tree-sitter test

lib.rs:

This crate provides pug 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_pug::language()).expect("Error loading pug grammar");
let tree = parser.parse(code, None).unwrap();

Dependencies

~2.8–4MB
~77K SLoC