Function generate

Source
pub fn generate(
    source: &str,
    language: &Language,
    tokens: Option<HashMap<&'static str, &'static str>>,
) -> TokenStream
Expand description

Generates the Rust code for a given Tree-sitter grammar

§Arguments

  • source - node-types.json
  • language - tree-sitter language fn
  • tokens - optional map of tokens to enum names (since tokens can’t be valid rust identifiers)

§Returns

A TokenStream containing the generated code

§Example

use auto_lsp_codegen::generate;

let _result = generate(
       &tree_sitter_python::NODE_TYPES,
       &tree_sitter_python::LANGUAGE.into(),
       None,
   );