My starter for language projects. Rust, lalrpop, and logos.
- Lexing
- Parsing
- Capturing spans
- Error handling & diagnostics
- Syntax tests for asserting tokens, AST, errors, diagnostics
- Dockerized CLI
- Language server
- VS Code extension
- Getting Started
- Lexer
- Parser, Grammar, AST
- Valid & Invalid Syntax Examples
- Specification & Integration Tests
Syntax | Description |
---|---|
1 , 100 |
A number |
5 + 5 , 25 - 10 , 10 * 10 , 20 / 5 |
Infix operations |
(5 + 10) - 2 |
Grouping |
See /spec for more syntax examples.
The specification tests read in *.expr
files in the spec/
directory and compare the output against their corrosponding expected result files (e.g. *.expr.tokens
). These [spec]((./spec) files are split between valid and invalid examples.
Run just coverage
or coverage.sh to generate a coverage report.
The CLI can lex or parse files.
cargo run --example language-project-template -- --file-path ./spec/valid/add.expr parse
The CLI can also be used with Docker.
Build the docker image first.
docker build -t language-project-template:0.0.0 .
The docker image will run any of the repo's spec files.
docker run -it --rm --read-only language-project-template:0.0.0 --file-path ./spec/valid/add.expr parse
If you'd like to run local files, you'll need to mount the directory inside the container directory /usr/local/src
docker run -it --rm --read-only -v ./example:/usr/local/src/example language-project-template:0.0.0 --file-path ./example/file.expr parse