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:
SubandFunctiondeclarations with parameters - Classes:
Classdeclarations with methods and properties - Control structures:
If...Then...Else,For...Next,Do...Loop,While...Wend,Select Case - Variable declarations:
Dim,Set,Letstatements - Expressions: Arithmetic, comparison, and logical expressions
- Comments: Single quote (
') andRemcomments - 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
- Install the grammar package
- VS Code will automatically use it for
.lssand.lsfiles - 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 statementsoption_stmt: Option declarationsclass_decl: Class definitionssub_decl: Subroutine definitionsfunction_decl: Function definitionsstatement: Various statement typesexpression: 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
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new features
- Submit a pull request
License
MIT License - see LICENSE file for details.
Related
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ceb32977251aa3f969bae721347040b2fde1752e4200ddf90a7c6211c6feffc9
|
|
| MD5 |
fc9cf2d79cc9530f1866ccee20586d11
|
|
| BLAKE2b-256 |
3c5f2c882d2dac4bae675a207331145c45b958644998de467b19b8b6b350bee3
|
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
- Download URL: tree_sitter_lotus-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 49.0 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66d35e9d9b468587627d9ae4cc93f1e3ad5e17d8b5aca1a1cc5287b91e740f95
|
|
| MD5 |
8b6db0363767a733c6b6cc2486e7da33
|
|
| BLAKE2b-256 |
88a867084fdaa80055b79829f3fd36e141078ba30be2c20c13764083ebd632b1
|