#tree-sitter #assembly #parser #incremental #parse-tree #syntax-tree #merlin6502

tree-sitter-merlin6502

merlin6502 grammar for the tree-sitter parsing library

5 stable releases

3.0.1 Aug 17, 2024
3.0.0 Jul 20, 2024
2.3.0 Jul 17, 2024
2.2.0 Apr 21, 2024
1.0.0 Oct 30, 2022

#220 in Text editors

Download history 111/week @ 2024-07-11 170/week @ 2024-07-18 15/week @ 2024-07-25 1/week @ 2024-08-01 151/week @ 2024-08-15 10/week @ 2024-08-22 1/week @ 2024-09-05 14/week @ 2024-09-12 19/week @ 2024-09-19 26/week @ 2024-09-26 14/week @ 2024-10-03

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

MIT license

1MB
40K SLoC

C 39K SLoC JavaScript 653 SLoC // 0.1% comments Scheme 184 SLoC Rust 33 SLoC // 0.4% comments

Parser for Merlin 6502 Assembly

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

[dependencies]
tree-sitter = "0.22.4"
tree-sitter-merlin6502 = "3.0.1"

Here is a trivial main.rs example:

use tree_sitter;
use tree_sitter_merlin6502;

fn main() {
    let code = " LDA #$00\n";
    let mut parser = tree_sitter::Parser::new();
    parser.set_language(&tree_sitter_merlin6502::language())
      .expect("Error loading Merlin 6502 grammar");
    let tree = parser.parse(code,None).unwrap();

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

This should print the syntax tree

(source_file (operation (op_lda) (arg_lda (imm (imm_prefix) (num)))))

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


lib.rs:

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

Dependencies

~2.7–4MB
~73K SLoC