Skip to content

kyleect/language-project-template

Repository files navigation

language-project-template

My starter for language projects. Rust, lalrpop, and logos.

Includes

  • Lexing
  • Parsing
  • Capturing spans
  • Error handling & diagnostics
  • Syntax tests for asserting tokens, AST, errors, diagnostics
  • Dockerized CLI

Future

  • Language server
  • VS Code extension

Project

Syntax

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.

Built With

Tests

Specification Tests

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.

Coverage

Run just coverage or coverage.sh to generate a coverage report.

CLI

The CLI can lex or parse files.

cargo run --example language-project-template -- --file-path ./spec/valid/add.expr parse

Docker

The CLI can also be used with Docker.

Build

Build the docker image first.

docker build -t language-project-template:0.0.0 .

Run

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

About

My starter for language/parser projects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published