Skip to main content

Objectscript grammar for tree-sitter

Project description

tree-sitter-objectscript

CI npm crates-udl crates-routine crates-playground pypi

Tree-sitter grammars for InterSystems ObjectScript.

Grammars

This repository publishes five related grammars:

  • objectscript: playground/snippet grammar.
  • objectscript_udl: class-file grammar for .cls.
  • objectscript_core: routine/statement grammar.
  • objectscript_expr: expression grammar.
  • objectscript_routine: routine-file grammar for .mac, .inc, .rtn, and .int.

Grammar extension graph: objectscript_expr -> objectscript_core -> objectscript_udl -> objectscript objectscript_expr -> objectscript_core -> objectscript_routine

Packages

  • npm: tree-sitter-objectscript
  • PyPI: tree-sitter-objectscript (ships tree_sitter_objectscript, tree_sitter_objectscript_udl, and tree_sitter_objectscript_routine)
  • Rust crates:
    • tree-sitter-objectscript (UDL grammar)
    • tree-sitter-objectscript-routine (routine grammar)
    • tree-sitter-objectscript-playground (playground grammar)

Bindings

Language bindings are available under bindings/:

  • C: bindings/c
  • Go: bindings/go
  • Node.js: bindings/node
  • Python: bindings/python
  • Rust: bindings/rust, bindings/rust-routine, and bindings/rust-playground
  • Swift: bindings/swift

Quick binding checks from repo root:

nvm use
npm ci
cargo test --lib --package tree-sitter-objectscript
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -U pip setuptools wheel pytest tree-sitter
python3 setup.py build_ext --inplace
PYTHONPATH=$PWD/bindings/python python3 -m pytest -q bindings/python/tests/test_binding.py
npm test
go test ./bindings/go/...
swift test
make test

The routine and playground Rust crates are staged from bindings/rust-routine and bindings/rust-playground via helper scripts. See CONTRIBUTING.md for the current local build workflow and the temporary studio-highlights.scm copy step those staged crates need today.

For Node bindings specifically, .nvmrc pins the expected Node version.

Quick Development

Install the tree-sitter CLI, then run commands from a grammar directory (objectscript, udl, core, expr, or objectscript_routine):

tree-sitter generate
tree-sitter test
tree-sitter build

For playground work:

tree-sitter build --wasm
tree-sitter playground

If you change an upstream grammar (expr or core), regenerate downstream grammars as needed (udl, objectscript, objectscript_routine).

Query Sync

scripts/sync_queries.py manages the canonical query trio for each grammar:

  • highlights.scm
  • indents.scm
  • injections.scm

It composes the layered query trees for core, udl, objectscript, and objectscript_routine, then mirrors those composed files into the Python binding query directories. studio-highlights.scm files are intentionally left out of that sync process and are maintained separately.

Corpus Sync

objectscript/test/corpus is treated as a synced corpus directory. On commit, the repository pre-commit hook:

  • Replaces objectscript/test/corpus contents with files from:
    • core/test/corpus
    • udl/test/corpus
    • objectscript_routine/test/corpus
  • Removes objectscript/test/corpus/invalid.txt
  • Removes objectscript/test/corpus/compiled-header.txt

Contributing

See CONTRIBUTING.md for setup, workflow, query sync, and binding test instructions.

References

Editor Integration

  • Zed On Zed, you can use tree-sitter-objectscript by downloading the InterSystems ObjectScript extension

  • Neovim We currently have a PR open with nvim-treesitter, and if that gets merged in, the setup process will be automated. However, this repo is currently archived, so for now do the following to setup the grammars in neovim:

    Step 1: Create ~/.config/nvim/lua/plugins/objectscript-treesitter.lua

    Add the following content to that file: IMPORTANT: Make sure to replace the revision section with the commit that you want.

    return {
    -- configure nvim-treesitter
    {
      "nvim-treesitter/nvim-treesitter",
      init = function()
        vim.filetype.add({
          extension = {
            cls = "objectscript_udl",
            mac = "objectscript_routine",
            inc = "objectscript_routine",
            int = "objectscript_routine",
            rtn = "objectscript_routine"
          },
        })
    
        vim.api.nvim_create_autocmd("FileType", {
          pattern = { "objectscript_udl", "objectscript_routine" },
          callback = function(args)
            vim.treesitter.start(args.buf)
          end,
        })
    
        vim.api.nvim_create_autocmd('User', { pattern = 'TSUpdate',
        callback = function()
        local parsers = require("nvim-treesitter.parsers")
    
          parsers.objectscript_udl = {
            install_info = {
              url = "https://github.com/intersystems/tree-sitter-objectscript",
              revision = "f1c568c622a0a43191563fd4c5e649a61eef11cc", 
              location = "udl",
              queries = "udl/queries",
            }
          }
    
          parsers.objectscript_routine = {
            install_info = {
              url = "https://github.com/intersystems/tree-sitter-objectscript",
              revision = "f1c568c622a0a43191563fd4c5e649a61eef11cc", 
              location = "objectscript_routine",
              queries = "objectscript_routine/queries",
            }
          }
        end})
      end,
    
        opts = function(_, opts)
          opts.ensure_installed = opts.ensure_installed or {}
          for _, lang in ipairs({ "objectscript_udl", "objectscript_routine" }) do
            if not vim.tbl_contains(opts.ensure_installed, lang) then
              table.insert(opts.ensure_installed, lang)
            end
          end
        end,
      },
    }
    

    Step 2: Remove cached data from nvim if necessary (if previously installed)

    rm -rf ~/.local/share/nvim/site/parser \
      ~/.local/share/nvim/site/parser-info \
      ~/.local/share/nvim/site/queries
    

    Step 3: Open Neovim and Install objectscript_udl and objectscript_routine

    :TSInstall objectscript_udl objectscript_routine
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_sitter_objectscript-1.7.12.tar.gz (15.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tree_sitter_objectscript-1.7.12-cp38-abi3-win_arm64.whl (4.3 MB view details)

Uploaded CPython 3.8+Windows ARM64

tree_sitter_objectscript-1.7.12-cp38-abi3-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.8+Windows x86-64

tree_sitter_objectscript-1.7.12-cp38-abi3-musllinux_1_2_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

tree_sitter_objectscript-1.7.12-cp38-abi3-musllinux_1_2_aarch64.whl (4.4 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

tree_sitter_objectscript-1.7.12-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

tree_sitter_objectscript-1.7.12-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (4.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

tree_sitter_objectscript-1.7.12-cp38-abi3-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

tree_sitter_objectscript-1.7.12-cp38-abi3-macosx_10_9_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.8+macOS 10.9+ x86-64

File details

Details for the file tree_sitter_objectscript-1.7.12.tar.gz.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.12.tar.gz
Algorithm Hash digest
SHA256 0e7982688745ea755076009d42aff3b581e6f33a0b78d8b2505abd1db61ad620
MD5 083e03b5cedfab1677d74f00623623a5
BLAKE2b-256 ff86d67971650c7832d164b102489dbf94cf3d87cad942abb485467ea99ed68a

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.12-cp38-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.12-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 aeba62447ca0a89e3811e8f70ca6c00ed9591816594d0da2489f1ced9ecc1162
MD5 679218d501c1e75bc6427bc42fb62453
BLAKE2b-256 6b99b0f0ab5439ff0f5bd854db2c35f8c72acfcde540222a24548addc3eab4ef

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.12-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.12-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c6450ca150d1fb28529d339a760e2f45dfdc4d0203520b38aa283bc1a57eec75
MD5 f597256ecba61568fbec19054d8c2551
BLAKE2b-256 e6808fcacede6ac5269be383f6aa8851da887d06d2dbaf0473c55b7da7de6227

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.12-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.12-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0aee59f302706ff084ed55da1a420faaf742c147f0598494948bef19779b2548
MD5 d2fef9347bddff8f25a49d01481922a5
BLAKE2b-256 fa0d5e034b19e560a55cee670502372a714e92330d69820e09020cd9b09300d5

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.12-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.12-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 fac2bc252dcd92f0ee3ecd94b36a46866eb1e3eaa9e36c31f2e2745b8101c4c3
MD5 33e5a0b447ae76df8cd15643f0d01a99
BLAKE2b-256 d0a88232ae575c84e203676a2ce1a633b01acbff109042f9246e792005974ebb

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.12-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.12-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fe75895c28ba7f024bdc949917f78ae2fcee37435ebb17318ff99daa96174654
MD5 95612de9ca10274e7423fbba608ff7db
BLAKE2b-256 311a4a07be305fe5ee40b0907219a1d0156cadbee2a1211938f76acae40ff135

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.12-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.12-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e987a3d4bb30958b39bd3afae383077d2012edb7db565ea4d0e6ca8f8ca00e7a
MD5 875e09a39e4deaa0798e88e6ba4f0fdb
BLAKE2b-256 9d670c41060d784e8b999ffc5ff0c31655fa9395533e212f8836e0a3a68d7091

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.12-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.12-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18948ae445d263691b90a17fb45701091f9614dafe0066b382d72c4ae3a9047d
MD5 f50015c228eb13fd223bd17fee2c0306
BLAKE2b-256 fb3c0db80594131ad97d8d74399feea06d29827aa2095749f7f94bbbcc4c0502

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.12-cp38-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.12-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 41747bae9dfbce97df8ca3337528ee3b833bdd2a16c1db62e7f525c840223b39
MD5 d84c3a3902e5c7f656c9fa384cdfb92c
BLAKE2b-256 c6a696d3e755e4cc398d19eb396aed91f491bd39da4892a7625591c68dc0e895

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page