[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [ANN] Cratera Compiler v1.0.1
- From: "Soni \"They/Them\" L." <fakedme@...>
- Date: Wed, 31 Jul 2019 10:58:51 -0300
Apologies for the debug print. v1.0.1 has been released. Nothing has
been changed other than removal of the debug prints. (Also, the magnet
link now uses opentrackr, which should speed up peer discovery.)
On 2019-07-31 1:06 a.m., Soni "They/Them" L. wrote:
Git repo: https://soniex2.autistic.space/git-repos/cratera.git (yes it
says forbidden, that's just because you can't view it on a web
browser. works fine with git.)
(checksums are necessary due to bittorrent being vulnerable to
About 2 months ago I tried to make a pure-Lua Cratera to Lua compiler.
Things didn't go very well at the time and the best I could do was
report a perceived bug with how Lua handles numeric literals (namely,
x=1print(x) not requiring a space between the 1 and the print). This
monday I had the idea to do it completely differently and rather than
reimplement the Lua parser in pure-Lua I decided to use a bit of an
uh, unorthodox method. The Lua parser parses things eagerly, using
what I believe is a hand-written recursive descent parser. However, it
was much easier to just tokenize the whole source and store the tokens
in a table, and then it's just a simple matter of lightly massaging
the source as needed. Yes, it's quite slow, but it works quite nicely!
Additionally, no debug mappings are necessary, as it does its best to
adjust line numbers!
It should support Lua 5.1, Lua 5.2, Lua 5.3 and, for the most part,
LuaJIT. That is, you should be able to pass any Lua 5.1, Lua 5.2, Lua
5.3 and LuaJIT-compatible source code through it. It might have
trouble with LuaJIT-specific extensions tho, such as "ULL" literals.
$ cat README.md
The Cratera Programming Language (and support components)
This repo contains the Cratera to Lua compiler, as well as support
components for the Cratera to Lua compiler, namely a pure-Lua Lua
tokenizer and a table-based parser thing.
Cratera is a language very similar to Lua, and as such most of the Lua
manual applies to it. Additionally, it supports the following syntax
sugar, called "traits":
which is equivalent to:
This syntax sugar is similar to the "methods" syntax sugar ([Lua 5.3
[Lua 5.2 §3.4.9](http://www.lua.org/manual/5.2/manual.html#3.4.9),
[Lua 5.1 §2.5.8](http://www.lua.org/manual/5.1/manual.html#2.5.8)),
and, indeed, `mytable` is only evaluated once.
Why not use LPeg?
The use of a custom parsing library boils down to two reasons:
1. LPeg can't stream or produce partial outputs. This just makes it
difficult to use for making a compiler.
2. LPeg can't process tables. It's still possible to use LPeg to parse
table-based structures, but one must serialize them beforehand, which
is... far from ideal, to say the least.