#language #call #call-stack #tree-sitter #ast #graph #parser

asterisk

Universal language-agnostic AST walking and accurate call stack generation with tree-sitter

1 unstable release

0.1.0 Apr 19, 2024

#381 in Programming languages

Download history 112/week @ 2024-04-15 9/week @ 2024-04-22

121 downloads per month

MIT license

225KB
678 lines

asterisk 🌟

Asterisk is a library for parsing and indexing code in various languages. 📚

LICENSE

Table of Contents

Features

  • Extract code structure and call information 📊
  • Generate call graphs 🌐
  • Support for multiple languages 🌍
    • Rust 🦀
    • Python 🐍
  • Configurable language-specific settings 🛠️

Installation

Add asterisk as a dependency in your Cargo.toml file:

[dependencies]
asterisk = "0.1.0"

Usage

use asterisk::config::Config;
use asterisk::indexer::index_directory;

fn main() {
    let toml_str = fs::read_to_string("asterisk.toml").expect("Unable to read file");
    let config = Config::from_toml(&toml_str).unwrap();

    let dir_path = "path/to/directory";
    let (blocks, call_stack, call_graph) = index_directory(&config, dir_path);

    // Process the extracted information
    // ...
}

Configuration

Asterisk uses a TOML configuration file to specify language-specific settings. Here's an example configuration:

[languages]
  [languages.python]
    [languages.python.matchers]
      import_statement = "import_from_statement"
      # ...

  [languages.rust]
    [languages.rust.matchers]
      import_statement = "use_declaration"  
      # ...

Development

To build the project from source:

$ git clone https://github.com/stitionai/asterisk.git
$ cd asterisk/
$ cargo build --release

Contribution

Ways to contribute:

  • Suggest a feature
  • Report a bug
  • Fix something and open a pull request
  • Help document the code
  • Spread the word

License

Licensed under the MIT License, see LICENSE for more information.

Liked the project?

Support the project by starring the repository. ⭐

Dependencies

~5–7.5MB
~141K SLoC