tree-sitter-lotus 0.1.1
Tree-sitter grammar for LotusScript
License: MIT
Requires Python: >=3.9
Keywords: incremental, parsing, tree-sitter, lotus

# tree-sitter-lotus

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

## Installation

### Python Package (PyPI)

```bash
pip install tree-sitter-lotus
```

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

### Node.js Package (npm)

```bash
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

```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

```javascript
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

```bash
npm run generate
```

### Running tests

```bash
npm test
```

### Parsing a file

```bash
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

- [Tree-sitter](https://tree-sitter.github.io/tree-sitter/)
- [LotusScript Language Reference](https://help.hcltechsw.com/domino/11.0.1/programming/programming.html)