A human-friendly DSL for ATProto Lexicons
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

README.md

tree-sitter-mlf#

MLF (Matt's Lexicon Format) grammar for tree-sitter.

Installation#

npm#

npm install tree-sitter-mlf

Cargo#

[dependencies]
tree-sitter-mlf = "0.1"

Usage#

Rust#

use tree_sitter::Parser;

let code = r#"
record post {
    text: string constrained {
        maxLength: 300,
    },
};
"#;

let mut parser = Parser::new();
parser.set_language(&tree_sitter_mlf::language()).unwrap();
let tree = parser.parse(code, None).unwrap();

JavaScript#

const Parser = require('tree-sitter');
const MLF = require('tree-sitter-mlf');

const parser = new Parser();
parser.setLanguage(MLF);

const code = `
record post {
    text: string,
};
`;

const tree = parser.parse(code);

Development#

Generate the parser#

# Install tree-sitter CLI
npm install

# Generate parser
npx tree-sitter generate

# Test the grammar
npx tree-sitter test

Build Rust bindings#

cd bindings/rust
cargo build
cargo test

Features#

  • Full MLF syntax support
  • Records, aliases, tokens, queries, procedures, subscriptions
  • Type system with primitives, references, arrays, unions, objects
  • Constrained types with validation rules
  • Syntax highlighting queries included

Editor Support#

This grammar can be used with:

  • Neovim - Via nvim-treesitter
  • Emacs - Via tree-sitter-mode
  • Helix - Built-in tree-sitter support
  • VS Code - Via tree-sitter extensions