#pascal #parser #incremental #delphi

tree-sitter-pascal

Pascal grammar for the tree-sitter parsing library

1 unstable release

new 0.10.0 Feb 19, 2025

#127 in Parser tooling

MIT license

3.5MB
131K SLoC

C 130K SLoC JavaScript 1K SLoC // 0.1% comments Scheme 257 SLoC // 0.2% comments Rust 27 SLoC // 0.3% comments

tree-sitter-pascal

Grammar for Pascal and its dialects Delphi and Freepascal.

Supported language features

  • Classes, records, interfaces, class helpers
  • Nested declarations
  • Variant records
  • Generics (Delphi- & FPC flavored)
  • Anonymous procedures & functions
  • Inline assember (but no highlighting)
  • Extended RTTI attributes
  • FPC PasCocoa extensions

Tree-sitter features:

  • Syntax highlighting
  • Scopes

Screenshots

(using nvim-treesitter)


lib.rs:

This crate provides Pascal 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_pascal::LANGUAGE;
parser
    .set_language(&language.into())
    .expect("Error loading Pascal parser");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

Dependencies