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

Uploaded CPython 3.8+Windows ARM64

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

Uploaded CPython 3.8+Windows x86-64

tree_sitter_objectscript-1.7.11-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.11-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.11-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.11-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.11-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.11-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.11.tar.gz.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.11.tar.gz
Algorithm Hash digest
SHA256 2c577f02a7aac8feb084387f91b228a132cf9a6b285a8442d32850988dfd2f6a
MD5 f4ab4a77cd401abc0449d15d2506c7a3
BLAKE2b-256 d07980851ae27aa56802da03df38d85d94c904e5cc200203bb32342652dc8cae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.11-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 7424ef9cdaa766a94510376af062fd6d345df8e8eb3efe3cdf9818eb6a0b3036
MD5 e1890e7c3fa3d877b06ee95575dfe4c5
BLAKE2b-256 bd83ec52eeaffcf96fe0eca599f751ef16c769b9db15d16655b8acf0b0747360

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.11-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 53e0a279fe0aee9b2147c10f60965ca6c2d1ccffc3711a2d11f2e0240238cc26
MD5 9385f145305b5f77e3c47a1c4d462eb5
BLAKE2b-256 9906835547de751f6b9210d9e22cdd95f800bd38931aa45b60db6e17533abaf9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.11-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 60b73903887576552774186e858d9f628b1fc33e02cfa6122df0f9541d894663
MD5 4b8ae5a37450d58728a55923ed07ff3e
BLAKE2b-256 c6c53f846aa9576b258e7a7c2aefb2470c1e05f64ab21d818a0fc302438c8df3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.11-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d4407c79f5f9c58fbcd7dbc37db4628f33803e968dd34ed772060a9b36594d10
MD5 3d89cd40e3700c00a5bbd48d4d551957
BLAKE2b-256 a351d58220f3963b6d769c0360abf43ed062821ccb875c85d625b456d1bcce3b

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.11-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.11-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4169f9cc415bb8858bc68378d5a4594128cc5b3df24650bf0a0894dac9b8d3a5
MD5 3a966bf1f4c8c4aaff814315f813c759
BLAKE2b-256 dd5d63438d717ff4cdf0f431d2e86bf17d6624f829750bd16991bf6a43c378ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.11-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 44a14e1ff7249b0a0bb9ba1c1764abc35b203c33b970c2557173263c05ff768b
MD5 ae79d2493b4775b021ebcad3e6baa73e
BLAKE2b-256 298307b83c6db171feba9f9a91462d1a4bd56e35f066d3b395c2e073ef50e013

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.11-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e933fb347debd6e2582e408d3a7f0c196ed18c96087082cf1928bf7dbe37f73
MD5 e4d95048d89163f12b58671834f3ded3
BLAKE2b-256 a76527ce4d94f477040bc6822d288e6452159db1718baf810ea6a9495b77cc8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.11-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0677d6070c78f1d375abd74274805614b01d61688c7581010e660bda08913a6b
MD5 5eb3bab40239f49ca8a43c24824383a7
BLAKE2b-256 bc232ae0a4e3d9b0b3aa46c05394642659fc8e352e0003edc22b7af57abcf06c

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