levovixtoProgramming Languages•June 2023 monthly "What are you working on?" threadEnglish
3·
2 years agoI was trying to create a programming language that doesn’t have a parser. It has only AST nodes. The program is edited only inside a special editor.
Nodes in the language are defined as
type Node = ref object
kind: Node
childs: seq[Node]
data: seg[byte]
That is, the node type is literally another node, which allows you to create as many types of nodes as you want without changing the program in any way. Some nodes may be functions.
For example, this is what the “function” and
looks like:
note that and
contains recursion to itself in the error
.
also note that string "false"
is just representation of what this constant means, there is no need to create new string “false” every time.
And this is what the “function” x
looks like, the use of which can be seen in and
:
Nim can compile helloworld to 800 Kb (or, with some tricks, to 50 Kb). This includes static linked libc, garbadge collection, nim std/system, and no compression.