Skip to main content

Tree-sitter grammar for LotusScript

Project description

tree-sitter-lotus

Tree-sitter grammar for LotusScript, the programming language used in IBM Lotus Notes and Domino.

Installation

Python Package (PyPI)

pip install tree-sitter-lotus

Note: This package requires tree-sitter>=0.24.0 for compatibility with ABI version 15.

Node.js Package (npm)

npm install tree-sitter-lotus

Features

This grammar supports the core LotusScript syntax including:

  • Option statements: Option Public, Option Private, Option Declare, Option Explicit
  • Subroutines and Functions: Sub and Function declarations with parameters
  • Classes: Class declarations with methods and properties
  • Control structures: If...Then...Else, For...Next, Do...Loop, While...Wend, Select Case
  • Variable declarations: Dim, Set, Let statements
  • Expressions: Arithmetic, comparison, and logical expressions
  • Comments: Single quote (') and Rem comments
  • Function calls: Method calls and member expressions

Usage

Python

import tree_sitter
import tree_sitter_lotus

# Create a parser
parser = tree_sitter.Parser()
language = tree_sitter.Language(tree_sitter_lotus.language())
parser.language = language

# Parse some LotusScript code
code = """
Option Public

Sub HelloWorld(name As String)
  Dim message As String
  message = "Hello, " & name & "!"
  Call PrintMessage(message)
End Sub
"""

tree = parser.parse(code.encode('utf-8'))
root = tree.root_node

# Explore the syntax tree
print(f"Root node type: {root.type}")
for child in root.children:
    print(f"  - {child.type}: {child.text.decode('utf-8')}")

Node.js

const Parser = require('tree-sitter');
const LotusScript = require('tree-sitter-lotus');

const parser = new Parser();
parser.setLanguage(LotusScript);

const sourceCode = `
Option Public

Sub HelloWorld(name As String)
  Dim message As String
  message = "Hello, " & name & "!"
  Call PrintMessage(message)
End Sub

Function AddNumbers(a As Integer, b As Integer) As Integer
  AddNumbers = a + b
End Function
`;

const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());

In VS Code

  1. Install the grammar package
  2. VS Code will automatically use it for .lss and .ls files
  3. You'll get syntax highlighting and parsing for LotusScript files

Development

Building the grammar

npm run generate

Running tests

npm test

Parsing a file

npm run parse path/to/your/file.lss

Grammar Structure

The grammar recognizes the following main constructs:

  • source_file: Top-level container for all statements
  • option_stmt: Option declarations
  • class_decl: Class definitions
  • sub_decl: Subroutine definitions
  • function_decl: Function definitions
  • statement: Various statement types
  • expression: Expression parsing with operator precedence

Compatibility

Python

  • Python: 3.9+
  • tree-sitter: 0.24.0+ (for ABI 15 compatibility)
  • Platforms: Windows, macOS, Linux

Node.js

  • Node.js: 12+
  • Platforms: Windows, macOS, Linux

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new features
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Related

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_lotus-0.1.1.tar.gz (67.1 kB view details)

Uploaded Source

Built Distribution

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

tree_sitter_lotus-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (49.0 kB view details)

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

File details

Details for the file tree_sitter_lotus-0.1.1.tar.gz.

File metadata

  • Download URL: tree_sitter_lotus-0.1.1.tar.gz
  • Upload date:
  • Size: 67.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for tree_sitter_lotus-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ceb32977251aa3f969bae721347040b2fde1752e4200ddf90a7c6211c6feffc9
MD5 fc9cf2d79cc9530f1866ccee20586d11
BLAKE2b-256 3c5f2c882d2dac4bae675a207331145c45b958644998de467b19b8b6b350bee3

See more details on using hashes here.

File details

Details for the file tree_sitter_lotus-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_lotus-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 66d35e9d9b468587627d9ae4cc93f1e3ad5e17d8b5aca1a1cc5287b91e740f95
MD5 8b6db0363767a733c6b6cc2486e7da33
BLAKE2b-256 88a867084fdaa80055b79829f3fd36e141078ba30be2c20c13764083ebd632b1

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