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.10.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.10-cp38-abi3-win_arm64.whl (4.3 MB view details)

Uploaded CPython 3.8+Windows ARM64

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

Uploaded CPython 3.8+Windows x86-64

tree_sitter_objectscript-1.7.10-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.10-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.10-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.10-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.10-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.10-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.10.tar.gz.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.10.tar.gz
Algorithm Hash digest
SHA256 c0fc196e6cf7be24e1da439ef36ccd62e3128237e6d1a298924772dd71c207a4
MD5 6facc89b878ef2bf72904de15a8ab855
BLAKE2b-256 fe1a7eea4153253c65f4eefad5d14a73dd234a554e64b3c9d3e7f7102537aee6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.10-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 db909f7bbaf2bade7c7456df4c797369fa7d03a8a32486208dd8bf80f0ab5135
MD5 f1cc9521ab526695c5d69f967001bb7e
BLAKE2b-256 98154e85a2b0e7eb3de83977f7d4b6d14529c5dabe23294e2f7da4056e33e69c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.10-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e4c288b9346fa3461c114c8f968ef2efad1d1b2d4808fecbcc273c1c41633dcd
MD5 3bfb7046c21c528f7fbe9ca882727b0b
BLAKE2b-256 15e9824a1c5cf20b9ef58a5171331742cce35127b2894a97bae163a800e84762

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.10-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a6ecd9fe796633bc21b2c17a556441ede29afbd799162a6c09061966166e893d
MD5 c657452b17a8d2e9fe4b54dca30fb43f
BLAKE2b-256 2643a53b5466513a85e882eaaa4c0b6f620429dc82d91bf7bedf84067117df12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.10-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 52165f543a05b1f3be5e93e48613a21c14b949a591a760a9750588a497225ff7
MD5 6271ee8a9419751643e7caa16d7546b8
BLAKE2b-256 80196bc02cdf88d9a9d31189678f293cf3ae8953985488daf2d019d267ff4f7a

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.10-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.10-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aaf81b84f459fb2ffc5d067195bc9148124a983dfa498e4f20aa93420c5eab12
MD5 7a3dd382c3719aa22fde2af3aa44ed26
BLAKE2b-256 1b70990befb0d283efab5cf873991c2723cea620f709b15c945d73fc4f85580c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.10-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 19a7fff2979a25e92945080e961708e9261bd290444e216ed64f45e3e47585b5
MD5 4a88c46e3d75589fa8bbca62822692fc
BLAKE2b-256 86608591db6a1524c4884e7e132eedca4eb428dce90cbb0d2c2c72bd15f1ea29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.10-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1876ae6969240ed310981de1569a33a76d81c7be6059f39fd6edca3ff07be3d4
MD5 35d9804a1707407eb1b6645e2406deb9
BLAKE2b-256 b3961c222358e9d4ecaff248f3ce50f71388b1cb03ad3797b693c7ef5f02a2f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.10-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3519161b283bb76e9338e6f4f425b01f93b2072489a281576398c69459ccd361
MD5 9b1334804d4ad0fc103d56572ec7f698
BLAKE2b-256 b8bf9c864f14ee819b1ba518c4a75ce608b14ac4b1fc1b733d4f8674d15abac5

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