#tree-sitter #integer #basic #incremental #parser

tree-sitter-integerbasic

integer basic grammar for the tree-sitter parsing library

4 stable releases

2.0.0 Jul 26, 2024
1.1.1 Apr 21, 2024
1.0.3 Nov 27, 2023
1.0.2 Oct 2, 2022
1.0.1 Mar 13, 2022

#244 in Text editors

Download history 12/week @ 2024-08-11 5/week @ 2024-08-18 2/week @ 2024-09-08 13/week @ 2024-09-15 18/week @ 2024-09-22 19/week @ 2024-09-29 2/week @ 2024-10-06 1/week @ 2024-10-20

272 downloads per month
Used in 2 crates (via a2kit)

MIT license

1MB
29K SLoC

C 29K SLoC JavaScript 368 SLoC // 0.0% comments Scheme 117 SLoC Rust 30 SLoC // 0.2% comments

Parser for Integer BASIC

This is the rust binding for tree-sitter-integerbasic. To use the parser, include the following in your package's Cargo.toml:

[dependencies]
tree-sitter = "0.22.4"
tree-sitter-integerbasic = "2.0.0"

Here is a trivial main.rs example:

use tree_sitter;
use tree_sitter_integerbasic;

fn main() {
    let code = "10 GOTO 10\n";
    let mut parser = tree_sitter::Parser::new();
    parser.set_language(&tree_sitter_integerbasic::language())
      .expect("Error loading Integer BASIC grammar");
    let tree = parser.parse(code,None).unwrap();

    println!("{}",tree.root_node().to_sexp());
}

This should print the syntax tree

(source_file (line (linenum) (statement (statement_goto) (integer))))

For more on parsing with rust, see the general guidance here.


lib.rs:

This crate provides Integerbasic 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 = r#"
"#;
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_integerbasic::language()).expect("Error loading Integerbasic grammar");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

Dependencies

~2.8–4MB
~77K SLoC