An open API service indexing awesome lists of open source software.

https://github.com/dfgordon/tree-sitter-applesoft

Parser for Applesoft BASIC
https://github.com/dfgordon/tree-sitter-applesoft

Last synced: 2 months ago
JSON representation

Parser for Applesoft BASIC

Awesome Lists containing this project

README

          

# Parser for Applesoft BASIC

![unit tests](https://github.com/dfgordon/tree-sitter-applesoft/actions/workflows/rust.yml/badge.svg)

This is a parser for Applesoft BASIC intended for use with language servers. It is built using the [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) system. The native parser is a C library. Bindings are possible for several languages, but only the [rust crate](https://crates.io/crates/tree-sitter-applesoft) is actively maintained. There is a [node package](https://www.npmjs.com/package/tree-sitter-applesoft) that can be updated upon request.

For details on parser usage and design see the [wiki](https://github.com/dfgordon/tree-sitter-applesoft/wiki).

## Pre-Build Process

If you are changing the grammar, be aware the file `grammar.js` is actually generated by the metaprogram `token_processor.py`. This takes `grammar-src.js`, `scanner-src.c`, and `token_list.txt` as inputs.

## Build Process

Once you have `grammar.js` you run `tree-sitter generate` to produce `src/parser.c` and, in turn, the bindings for whatever languages are specified in `tree-sitter.json`. If you want to compile a WASM parser you can follow up with `tree-sitter build -w`.

## Build Script

The `build.py` script takes care of all of the above steps, and will also run the tests. It produces a case insensitive parser, but can be easily modified to produce a case sensitive one. It can be adjusted to either accept or not accept extended `CALL` syntax.

## References

1. Applesoft BASIC Programmer's Reference Manual - Volume 1
2. Applesoft BASIC Programmer's Reference Manual - Volume 2