#tree-sitter #openscad #incremental #parser

tree-sitter-openscad-ng

openscad grammar for the tree-sitter parsing library

1 unstable release

new 0.6.0 Feb 17, 2025

#140 in Text editors

24 downloads per month

MIT license

315KB
12K SLoC

C 12K SLoC JavaScript 343 SLoC // 0.2% comments Scheme 168 SLoC // 0.1% comments Rust 32 SLoC // 0.1% comments

tree-sitter-openscad

OpenSCAD grammar for the tree-sitter parsing library

Developer quickstart

Most development of tree-sitter parsers is done using nodejs and npm. You can find the instructions on how to set that up here: https://tree-sitter.github.io/tree-sitter/creating-parsers

The TLDR would be:

  1. Ensure you have npm and just installed.
  2. Install npm (there are many ways, pick your poison)
  3. From the source directory, run npm install to get all the dependencies
  4. export PATH=$PATH:./node_modules/.bin to get the tree-sitter CLI command
  5. tree-sitter generate to build your changes
  6. tree-sitter test to make sure you didn't unintentionally break any of the existing test cases
  7. Add a new test case covering your change (instructions here: https://tree-sitter.github.io/tree-sitter/creating-parsers#command-test)

lib.rs:

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

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

let code = r#"
"#;
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_openscad::LANGUAGE;
parser
    .set_language(&language.into())
    .expect("Error loading Openscad parser");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

Dependencies

~4–310KB