# tree-sitter-lotus

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

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

## Installation

```bash
npm install tree-sitter-lotus
```

## Usage

### In 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

## 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) 