Crates.io | welly-parser |
lib.rs | welly-parser |
version | 0.3.0 |
source | src |
created_at | 2024-10-10 00:16:24.245679 |
updated_at | 2024-10-26 00:43:29.773757 |
description | An artisanal parser for the Welly programming language |
homepage | https://wellylang.org |
repository | https://github.com/apt1002/welly-parser |
max_upload_size | |
id | 1403250 |
size | 116,120 |
An artisanal parser for the Welly programming language.
It's a recursive descent parser, hand-written (i.e. not using a parser library). It should be fast by design, but I haven't put any effort into optimising it.
The API is incomplete and in flux. The syntax is in less flux, but could still change in the details.
Missing features that I do plan to include in the first release include some type literals. Missing features that I don't plan for the first release include floating point literals. These will be added later.
It is a two-pass parser:
word::AlphaNumeric
.fn(4+5) {}
and 4+5 = foo;
which are not legal in Welly. It also accepts some extra syntax that I plan to use in experimental versions of Welly, e.g. $x
, &x
and x?
.Whitespace and comments are removed. Comments in "doc string positions" will probably be preserved in a future version. If a parse error occurs, the parser does not make a parse tree. Because of these losses, this parser is not suitable for use in a code reformatter.
This parser is suitable for use in a REPL (Read-Eval-Print Loop). Specifically, if you type in half a source file and press "Enter", the parser will not return an incorrect parse tree by mistake, but will instead wait for more input. An example REPL is provided (use cargo run
).