-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
write a little docs and rebrand to piperscipt
- Loading branch information
1 parent
c2dd64c
commit 7e6e004
Showing
6 changed files
with
92 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,48 @@ | ||
# Lasagnalang | ||
# PiperScript | ||
|
||
This project is an interpreter for the language Lasagnalang. | ||
This project is an interpreter for the language PiperScript. | ||
|
||
It is intented as a learning exercise based on the book [Writing An Interpreter | ||
in Go](https://interpreterbook.com/). At the current state the intepreter is | ||
adapted from the Go to Rust, with the goal of learning more about interpreters | ||
and Rust. At a later stage I hope to create a | ||
[LSP](https://microsoft.github.io/language-server-protocol/) for Lasagnalang, | ||
as well as implementing some more novel idea for the language. | ||
adapted from Go to Rust, with the goal of learning more about interpreters | ||
and Rust. | ||
|
||
Lasagnalang may look something like this: | ||
PiperScript looks something like this: | ||
|
||
``` | ||
foo: 5 | ||
let foo: "hei" | ||
let bar: fn(x): | ||
return x + "ok" | ||
~ | ||
if foo == 5: | ||
foo + 10 | ||
if bar == foo: | ||
print(bar) | ||
else: | ||
1 + 1 | ||
print(foo) | ||
~ | ||
add: fn(x, y): return x + y~ | ||
let adder: fn(x): | ||
return fn(y): return x + y ~ | ||
~ | ||
add 5 1 | ||
let array: [2, 5, 6] | ||
print(array[2]) | ||
complex: fn(x, y, k): | ||
foo: add x y | ||
return k(foo) | ||
~ | ||
let hash: {"mee", 5, "boo", 1} | ||
print(hash["mee"]) | ||
power: fn(x): return x * x~ | ||
let one: 1 | ||
print(hash["mee"] / 8 * (array[1] + one)) | ||
complex 5 3 power // 64 | ||
res: complex 5 3 power | ||
print(last(array)) | ||
push(array, 5) | ||
``` | ||
|
||
There is nothing interesting or worthwhile about the language, the project is | ||
entirely about the exercise of creating an interpreter. | ||
## Additonal documentation | ||
|
||
See the following readme's for more technical docs: | ||
|
||
- [Interpreter](crates/interpreter/README.md) | ||
- [LSP](crates/son_of_anton/README.md) | ||
- [Formatter](crates/piperfmt/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Interpreter | ||
|
||
The interpreter is currently a tree-walking interpreter. | ||
|
||
## Parsing | ||
|
||
The main entry point is in `parser.rs`, see `Parser` structs new function. | ||
|
||
The parser holds a lexer, that walks the source code and produces | ||
tokens for the parser. | ||
|
||
The parser is a [Pratt Parser](https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html), also known as | ||
recursive descent parsing. | ||
|
||
The parser produces human readable "compile-time" errors. | ||
|
||
## Evaluating | ||
|
||
Currently a tree-walking interpreter. Will be rewritten to | ||
byte-code interpreter soon. | ||
|
||
Main entry point is in `eval.rs`, see `eval::eval()` | ||
|
||
Evaluator produces runtime errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Piperfmt | ||
|
||
Early version of formatter, will build upon slowly. | ||
|
||
Strategy will be storing tokens together with statements/expressions, | ||
and formatting based on those tokens. | ||
|
||
The formatter will be 100% opinionated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Son of Anton | ||
|
||
Son of Anton is PiperScrips LSP implementation. | ||
|
||
See the [specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/) | ||
|
||
Server is a JSON-RPC server over stdin and stdout. | ||
|
||
To install: | ||
`cargo install --package son_of_anton` | ||
|
||
To use in i.e. neovim: | ||
|
||
```lua | ||
local root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1]) | ||
local client = vim.lsp.start({ | ||
name = "anton", | ||
cmd = { "son_of_anton" }, | ||
root_dir = root_dir, | ||
}) | ||
vim.lsp.buf_attach_client(0, client) | ||
``` | ||
|
||
## Features | ||
|
||
Currently supports these capabilites: | ||
|
||
- Intitialize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters