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

Uploaded CPython 3.8+Windows ARM64

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

Uploaded CPython 3.8+Windows x86-64

tree_sitter_objectscript-1.7.7-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.7-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.7-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.7-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.7-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.7-cp38-abi3-macosx_10_9_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.8+macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: tree_sitter_objectscript-1.7.7.tar.gz
  • Upload date:
  • Size: 15.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tree_sitter_objectscript-1.7.7.tar.gz
Algorithm Hash digest
SHA256 92402b3ec1e81fd625cf16b341fc0887942569b36c27a507b24ffb24ec7a88e1
MD5 a18b270a529935da36908cd5f0d40422
BLAKE2b-256 caab4e84fd9c455c6ee5f8b8ba062f94b6a3e1bd7f9472557a8b2b96932c7835

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.7-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 961450075c099ba82aa37e883fc566cfd326c2298101732213ae0ec64b186054
MD5 35223919a1cc0527f8f1ce702dfd8ef5
BLAKE2b-256 d4fa94a69c7e4054605366f43e739264e9dd374672fdfcaba4236cf54e8f972b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.7-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 43a171f286955cece3f82cc2cdefd8d59846c12ab303d240a0fef87b40abc25b
MD5 3d68ff388e7b583ff6cd187d4c3f3b29
BLAKE2b-256 9b1ebfd8816f679dee5fe7aaf0bfbc79361103d995a54fa406c8d421d6e244ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.7-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1bffa318c799f4d19845e6344b0de060de74b0ea966f7a847242acf40fa5eec4
MD5 2cb3f1b3aa5c4312411f2e35e5afa967
BLAKE2b-256 be9f08a13e745ef52d7947ca4ecb4e8daefea3ed82dfdf07fc4ad665354c8786

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.7-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2daaade7fac2086686e7a87cd26b70fb299fec4b3e76b6dfba02fcfa97a13096
MD5 9528163816bb9e923915f2de74326693
BLAKE2b-256 0cba380a39e30b686f5c912e2833235931b090defda235e8a1b5f4160bf95e5c

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.7-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.7-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d4872ee55928175083e929b7db89f38c68e219af5136f76ba45b994cfa97cf4c
MD5 36bc7909fd69a2582c6ffab0c10ffa7b
BLAKE2b-256 6db5355e4aae2786ce3cb754e5bd547baad62fb77a6b88bf81bd1152a992f727

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.7-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 901c518d9f97c24352f35e40898c0aa3e7d08b8aa2035747599c5327a60ebe5b
MD5 f583c5c18272cedd310df1b3da974088
BLAKE2b-256 4e66864982e4194899083147513d1794e8f0c3d671d61d3a7d04990ab7f458a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.7-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4bab42a96ebb893d1271d0abee0c89d63e327f5b9e19992a5ec6214e257d7da9
MD5 9dd9b68f17b005e87728e1e83ed8f2b9
BLAKE2b-256 fb698370c7c8e450778e9135eeb6840de66095aff33813694d117ac3e8f8dd58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.7-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1f246e653b78dc840f30b9437d475844b22b7009aea07822306b4f1c9af84c9c
MD5 72384457f191642c5f65e42ac0c8b8a5
BLAKE2b-256 4092e8c6f06da61195d1cb4765b3d111f8d87ad126198b432984ef54a2e98bb6

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