Skip to main content

tree-sitter-t32

CI Status status-badge

Lauterbach TRACE32® script language grammar for tree-sitter. Support for HLL expressions was adapted from tree-sitter-c.

A demo is available here.

Features

  • Full coverage of the PRACTICE script language including TRACE32® commands & functions
  • Extended support for HLL expressions

Quick Start

Dependencies

Commands

Generate parser

Create and build the tree-sitter parser for the TRACE32® grammar.

tree-sitter generate

Parse TRACE32® Script

Use tree-sitter to parse a TRACE32® script.

Example:

; --------------------------------------------------------------------------------
; @Title: Beautify an existing PRACTICE script
; @Description:
;   Beautifies the script, fixing the CamelCasing and indentation.
; @Keywords: PRACTICE, EDIT.FORMAT, CamelCasing, indent, beautify
; @Author: MOB
; @Copyright: (C) 1989-2020 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: beautify.cmm 19661 2022-07-29 15:43:03Z rweiss $

PARAMETERS &script

IF "&script"==""
(
  DIALOG.File.open *.cmm
  ENTRY %LINE &script
)

IF FILE.EXIST("&script")
(
  ECHO %COLOR.GRAY "beautifying: &script"
  SETUP.EDITOR.TYPE PowerView ; required for EDIT.FORMAT
  PEDIT "&script"
  EDIT.FORMAT /Beautify
  EDIT.SAVE "&script"
  EDIT.CLOSE "&script"
  ECHO %COLOR.GREEN "beautified: &script"
)
ELSE
(
  ECHO %ERROR "Error: no such file: &script"
)

ENDDO
tree-sitter parse <path>
Prints the syntax tree
(script [0, 0] - [34, 0]
  (comment [0, 0] - [1, 0])
  (comment [1, 0] - [2, 0])
  (comment [2, 0] - [3, 0])
  (comment [3, 0] - [4, 0])
  (comment [4, 0] - [5, 0])
  (comment [5, 0] - [6, 0])
  (comment [6, 0] - [7, 0])
  (comment [7, 0] - [8, 0])
  (comment [8, 0] - [9, 0])
  (parameter_declaration [10, 0] - [11, 0]
    command: (identifier [10, 0] - [10, 10])
    macro: (macro [10, 11] - [10, 18]))
  (if_block [12, 0] - [18, 0]
    command: (identifier [12, 0] - [12, 2])
    condition: (binary_expression [12, 3] - [12, 16]
      left: (string [12, 3] - [12, 12]
        (macro [12, 4] - [12, 11]))
      right: (string [12, 14] - [12, 16]))
    (block [13, 0] - [17, 0]
      (command_expression [14, 2] - [15, 0]
        command: (identifier [14, 2] - [14, 18])
        arguments: (argument_list [14, 18] - [14, 24]
          (path [14, 19] - [14, 24])))
      (parameter_declaration [15, 2] - [16, 0]
        command: (identifier [15, 2] - [15, 7])
        (identifier [15, 8] - [15, 13])
        macro: (macro [15, 14] - [15, 21]))))
  (if_block [18, 0] - [32, 0]
    command: (identifier [18, 0] - [18, 2])
    condition: (call_expression [18, 3] - [18, 24]
      function: (identifier [18, 3] - [18, 13])
      arguments: (argument_list [18, 13] - [18, 24]
        (string [18, 14] - [18, 23]
          (macro [18, 15] - [18, 22]))))
    (block [19, 0] - [28, 0]
      (command_expression [20, 2] - [21, 0]
        command: (identifier [20, 2] - [20, 6])
        arguments: (argument_list [20, 6] - [20, 41]
          (format_expression [20, 7] - [20, 18]
            value: (identifier [20, 8] - [20, 13])
            value: (identifier [20, 14] - [20, 18]))
          (string [20, 19] - [20, 41]
            (macro [20, 33] - [20, 40]))))
      (command_expression [21, 2] - [22, 0]
        command: (identifier [21, 2] - [21, 19])
        arguments: (argument_list [21, 19] - [21, 29]
          (identifier [21, 20] - [21, 29]))
        (comment [21, 29] - [22, 0]))
      (command_expression [22, 2] - [23, 0]
        command: (identifier [22, 2] - [22, 7])
        arguments: (argument_list [22, 7] - [22, 17]
          (string [22, 8] - [22, 17]
            (macro [22, 9] - [22, 16]))))
      (command_expression [23, 2] - [24, 0]
        command: (identifier [23, 2] - [23, 13])
        arguments: (argument_list [23, 13] - [23, 23]
          (option_expression [23, 14] - [23, 23]
            option: (identifier [23, 15] - [23, 23]))))
      (command_expression [24, 2] - [25, 0]
        command: (identifier [24, 2] - [24, 11])
        arguments: (argument_list [24, 11] - [24, 21]
          (string [24, 12] - [24, 21]
            (macro [24, 13] - [24, 20]))))
      (command_expression [25, 2] - [26, 0]
        command: (identifier [25, 2] - [25, 12])
        arguments: (argument_list [25, 12] - [25, 22]
          (string [25, 13] - [25, 22]
            (macro [25, 14] - [25, 21]))))
      (command_expression [26, 2] - [27, 0]
        command: (identifier [26, 2] - [26, 6])
        arguments: (argument_list [26, 6] - [26, 41]
          (format_expression [26, 7] - [26, 19]
            value: (identifier [26, 8] - [26, 13])
            value: (identifier [26, 14] - [26, 19]))
          (string [26, 20] - [26, 41]
            (macro [26, 33] - [26, 40])))))
    (else_block [28, 0] - [32, 0]
      command: (identifier [28, 0] - [28, 4])
      (block [29, 0] - [32, 0]
        (command_expression [30, 2] - [31, 0]
          command: (identifier [30, 2] - [30, 6])
          arguments: (argument_list [30, 6] - [30, 44]
            (format_expression [30, 7] - [30, 13]
              value: (identifier [30, 8] - [30, 13]))
            (string [30, 14] - [30, 44]
              (macro [30, 36] - [30, 43])))))))
  (command_expression [33, 0] - [34, 0]
    command: (identifier [33, 0] - [33, 5])))

Highlight TRACE32® Script

Use tree-sitter to highlight a TRACE32® script.

tree-sitter highlight <path>
Prints the highlighted file

asciicast

Create Code Navigation Tags

Use tree-sitter to create a tags file from a TRACE32® script.
; --------------------------------------------------------------------------------
; @Title: Example test case for Unittests
; @Description:
;   This is an example for a test case which can be executed with lbunit.cmm.
; @Keywords: lbtest test case
; @Author: MOB
; @Copyright: (C) 1989-2015 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: test_example.cmm 8648 2015-09-03 17:04:05Z mobermeir $

; the following block must be present in the beginning of every test case
PRIVATE &func &args &result
ENTRY &func %LINE &args
GOSUB &func &args // call subroutine and return result
ENTRY %LINE &result
ENDDO &result
; end of mandatory block

; SetupTestCase will be called once at the beginning of the test case
; It can be removed if it is not needed.
SetupTestCase:
(
  PRIVATE &date
  &date=DATE.DATE()+" "+DATE.TIME()
  PUTS "test case started at: &date"
  RETURN
)

; SetupTest will be called just before every test
; It can be removed if it is not needed.
SetupTest:
(
  ; here can be some setup
  Data.Set VM:0x0--0xFF 0xA
  RETURN
)

; All tests must start with "Test_"
Test_MyFirstTest:
(
  ; Assertions can be used:
  A_FALSE FALSE()
  A_TRUE (1.+1.==2.)
  RETURN
)

Test_MySecondTest:
(
  A_NUM_EQ 0xA Data.Byte(VM:0x0)
  A_X_PASS Data.Set VM:0x0 0xB
  A_NUM_EQ 0xB Data.Byte(VM:0x0)
  RETURN
)

Test_MyThirdTest:
(
  ; Tests can return "PASS", "FAIL" or "NOT_EXEC"
  ; (alternatively or in addition to assertions)
  IF (0xA!=Data.Byte(VM:0x0))
  (
    RETURN "FAIL"
  )
  ELSE IF (0xB==Data.Byte(VM:0x0))
  (
    RETURN "NOT_EXEC"
  )
  ELSE
  (
    RETURN "PASS"
  )
  RETURN // same as "PASS"
)

MyHelper:
(
  A_NUM_EQ 0xA Data.Byte(VM:0x10)
  RETURN
)

Test_MyFourthTest:
(
  ; tests can call helper functions
  RePeaT 2.
  (
    GOSUB MyHelper
  )
  RETURN
)

DisabledTest_MyFifthTest:
(
  ; this routine will not be executed since it doesn't start with "Test_"
  RETURN
)

; TearDownTest will be called just after every test
; It can be removed if it is not needed.
TearDownTest:
(
  ; here could be some cleanup
  Break.RESet
  RETURN
)

; TearDownTestCase will be called once at the end of the test case
; It can be removed if it is not needed.
TearDownTestCase:
(
  PRIVATE &date
  &date=DATE.DATE()+" "+DATE.TIME()
  PUTS "test case ended at: &date"
  RETURN
)
tree-sitter tags <path>
Prints a list of tags
func      	 | call    	ref (13, 7) - (13, 11) `GOSUB &func &args // call subroutine and return result`
SetupTestCase	 | function	def (20, 0) - (20, 13) `SetupTestCase:`
SetupTest 	 | function	def (30, 0) - (30, 9) `SetupTest:`
Test_MyFirstTest	 | function	def (38, 0) - (38, 16) `Test_MyFirstTest:`
Test_MySecondTest	 | function	def (46, 0) - (46, 17) `Test_MySecondTest:`
Test_MyThirdTest	 | function	def (54, 0) - (54, 16) `Test_MyThirdTest:`
MyHelper  	 | function	def (73, 0) - (73, 8) `MyHelper:`
Test_MyFourthTest	 | function	def (79, 0) - (79, 17) `Test_MyFourthTest:`
MyHelper  	 | call    	ref (84, 10) - (84, 18) `GOSUB MyHelper`
DisabledTest_MyFifthTest	 | function	def (89, 0) - (89, 24) `DisabledTest_MyFifthTest:`
TearDownTest	 | function	def (97, 0) - (97, 12) `TearDownTest:`
TearDownTestCase	 | function	def (106, 0) - (106, 16) `TearDownTestCase:`

Development

There is a makefile to simplify the most common activities. The makefile expects you to have Yarn installed and set up.

To build the parser from the grammar:

make build

To run all tests:

make test-all

Editor Support

Editor Plugin Syntax Highlighting Local Variables Folds Indents
Neovim nvim-treesitter ✓ ✓ ✓ ✓
Helix ✓

nvim-treesitter

Run

:TSInstall t32

to automatically install the supported grammar.

Limitations

  • (symbol) nodes that represent an unquoted module, like \module, cannot be differentiated from user-defined TRACE32 internal HLL variables, e.g. \x.
  • (symbol) nodes that depend on the hex radix mode cannot always be kept apart from (address) nodes, e.g. P:A::B:0x800. To avoid conflicts always add the radix mode to the number.
  • Commands from the Var command group that contain multiple chained (format_expression) (_hll_expression) blocks
  • Unquoted (path) nodes are not clearly distinguishable from other literal types in command argument lists.
  • For HLL expressions used at the top level of commands, the use of spaces is more restricted than for nested expressions inside parentheses. The grammar only models the strict behavior.
  • (recursive_macro_expansion) nodes are restricted to the left-hand side of assignment expressions. In other contexts, recursive PRACTICE macro expansions cannot be distinguished from && operators.

Packages

Language Package Download
Node.js npm
Python PyPI 📦
Rust crates.io

Mirrors

This repository is mirrored to https://gitlab.com/xasc/tree-sitter-t32 and https://github.com/xasc/tree-sitter-t32. The main repository is https://codeberg.org/xasc/tree-sitter-t32.

Contributing

For the time being, we are not accepting pull requests. However, please feel free to open issues for changes you would like to see.

License

Distributed under the MIT license. REUSE is used for managing licensing information throughout the project. For more accurate licensing information, please check the individual files.

References

Metadata

Release files for tree-sitter-t32 10.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tree-sitter-t32 10.0.0
File Size Uploaded Provenance Actions
tree_sitter_t32-10.0.0.tar.gz 278.8 kB Without provenance Details for tree_sitter_t32-10.0.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-t32 10.0.0
File Actions
tree_sitter_t32-10.0.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for tree_sitter_t32-10.0.0-cp310-abi3-win_arm64.whl
tree_sitter_t32-10.0.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for tree_sitter_t32-10.0.0-cp310-abi3-win_amd64.whl
tree_sitter_t32-10.0.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for tree_sitter_t32-10.0.0-cp310-abi3-musllinux_1_2_x86_64.whl
tree_sitter_t32-10.0.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for tree_sitter_t32-10.0.0-cp310-abi3-musllinux_1_2_aarch64.whl
tree_sitter_t32-10.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for tree_sitter_t32-10.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
tree_sitter_t32-10.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64, Linux glibc 2.17+ ARM64 Details for tree_sitter_t32-10.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
tree_sitter_t32-10.0.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for tree_sitter_t32-10.0.0-cp310-abi3-macosx_11_0_arm64.whl
tree_sitter_t32-10.0.0-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details for tree_sitter_t32-10.0.0-cp310-abi3-macosx_10_9_x86_64.whl

Total release size: 1.4 MB

Release files / tree_sitter_t32-10.0.0.tar.gz

Download URL tree_sitter_t32-10.0.0.tar.gz
Size 278.8 kB
Tags Source
SHA-256 checksum
How to use checksums
52e1aaef1b7270a14a04682bd4603327a8457622d58761f1bb3d2272d160e127
BLAKE2b-256 checksum
How to use checksums
ba4a2982722a1d5ab18a69ab71c0e8c73e463763078aa69c6903535420a3d496
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_t32-10.0.0-cp310-abi3-win_arm64.whl

Download URL tree_sitter_t32-10.0.0-cp310-abi3-win_arm64.whl
Size 131.2 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
72768c9da8617f6906a0723a08804a270322b8fc26cca7e6655ed8c29df9d8b2
BLAKE2b-256 checksum
How to use checksums
8456e8b0af0d3a073f7f299618abf22b5c33c99654d684e717947624c35f744a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_t32-10.0.0-cp310-abi3-win_amd64.whl

Download URL tree_sitter_t32-10.0.0-cp310-abi3-win_amd64.whl
Size 131.4 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9bd3e8de79afbf937e2c2bf9197abba200108f9568a062953c8fcd54ee5d93c8
BLAKE2b-256 checksum
How to use checksums
8621c4d877d41485fe4d7f98ded6a429060d191dc850d2b29ad091ae05bc6c95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_t32-10.0.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_t32-10.0.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 154.3 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
2ea88ff3e17c9bc74f82af9f680d21271a7e817811991db6a20123a19cd0848b
BLAKE2b-256 checksum
How to use checksums
2e4357529efde087e062eff993d7ac2645bb79c390f78679060c43e43731230b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_t32-10.0.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_t32-10.0.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 154.7 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
0e1f38a62402dbc31d20eec489681bb4e8ae2105818d42f8557067d495732566
BLAKE2b-256 checksum
How to use checksums
62b13f76ffe3025a645efa6b2935f22b45c03eeef0b9da722e0d919635559a48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_t32-10.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL tree_sitter_t32-10.0.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 154.9 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
c0d59202e3dc7086adcf7467ade0a13b4228b40edab439bdc2767a54d9dc2f31
BLAKE2b-256 checksum
How to use checksums
d24d70cf311e5545cbeb081e334740cb8a03d2ca6b3323ec8fd249b02ad50888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_t32-10.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_t32-10.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 155.9 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
5d011706cc84915707469a0b6923479bbc154b2d9bc316bd2b45337502ceb1d3
BLAKE2b-256 checksum
How to use checksums
4e1331c47b62d34663a464dc68845c408ed486dd9e3f9166aa6ee7c26e185059
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_t32-10.0.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_t32-10.0.0-cp310-abi3-macosx_11_0_arm64.whl
Size 136.4 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c026ecfbd2d27c7ef2350a974979ece29438243ed1e1aad2e728535b8edebc40
BLAKE2b-256 checksum
How to use checksums
dba5ffc641761832a096789fda5fe4235a2662e9a85df496d63986a6525b50f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tree_sitter_t32-10.0.0-cp310-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_t32-10.0.0-cp310-abi3-macosx_10_9_x86_64.whl
Size 128.9 kB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
ae1a388f126cb254e9de70a373559a570dc787ed04bed3322509aa2e9589a7e9
BLAKE2b-256 checksum
How to use checksums
911c54da39ec7c75ec3ff958e7fcfddcbdd5dfd6898cf5ab4c74c0baeaa5bf9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for tree-sitter-t32 10.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page