~madcapjake/yari

Yet Another Rhumb Interpreter
Build out environment and map support
Restructure and begin evaluator
Update generated parsers & add nums, math

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~madcapjake/yari
read/write
git@git.sr.ht:~madcapjake/yari

You can also use your local clone with git send-email.

#🗡️ YARI

A parser and interpreter of Rhumb programs. Currently working on an in-process evaluator (Node). Planning to add two compilation targets (QBE & WAT).

#Rhumb

Rhumb is an esoteric differential-inheritance dynamic functional programming language.

% Tree Example

EmptyTree .= [
  includes .. (x) -> false
  insert   .. (x) -> ~TreeNode(x)
  size     .. 0
  do       .. (sub) -> ~
]

Tree .= () -> (
  ~@type := EmptyTree
)

TreeNodeTraits .= [
  includes .. (x) -> x == ~\contents => true !> (
    sub-tree .= x << ~\contents {
      true  .. ~\left
      false .. ~\right
    }
    sub-tree\includes(x)
  )
  insert .. (x) -> <(^1(x; ~\contents))> {
    _==_ .. ~
    _<<_ .. ~\left\insert(x)
            ~\right\insert(x)
  }
  size .. <(~\left\size ++ 1 ++ ~\right\size)>
  do .. <(~\left\do(^1); ^1(~\contents); ~\right\do(^1); ~)>
  _*_ .. (origin) ->
    ~\left .= origin\*left
    ~\right .= origin\*right
]

TreeNode .= (contents) -> (
  ~@type     .= TreeNodeTraits
  ~\left     := *Tree
  ~\right    := *Tree
  ~\contents := contents
)

Translation of an example from Self: The Power of Simplicity

#Access Order

Maps search through inner labels first (\ or __inner__). Then it reaches into any sub maps (@ or __under__). It searches all inner labels of each sub map. If multiple labels are found, an error is thrown. If nothing is found, it then begins searching through any sub maps of the current set of sub maps. This process continues until there are no more sub maps available to traverse.

Scopes are searched through the prior labels first. Then it searches the outer scope. It continues going into the next outer scope until there are no more outer scopes to traverse.

#Operator Precedence

Name Associativity Operators
Map []
Selector {}
Routine ()
Member Left \, @, ` `
Invocation x()
Access x[]
Effect x{}
Power Right ^^,^/, *^
Prefix Right -, ~, !, #, ^, &, *, +, =, @, ?, ., :
Multiply Left **, //, +/, -/, ~~
Add Left ++, --, +-
Compare Left >>, >=, <<, <=
Conjunctive Left &&
Disjunctive Left ||
Identity Left ==, =~, =\, =@, =*, !=, !~, !\, !@, !*
Conditional Right !!, ??, <>, |>, =>, !>
Applicative Right ->, ~>
Assignment Right .=, :=, .., ::
Literal 10,000.1, "foo", <ref>, label

#Actual Goals

  • 🔳 To use ANTLR-generated JS parser
  • 🔳 To write the evaluator in CoffeeScript
  • ⬜ In-process evaluator REPL
  • ⬜ To generate QBE assembly
  • ⬜ Hook up to C compiler
  • ⬜ QBE/C generator REPL
  • ⬜ To generate WASM assembly (WAT)
  • ⬜ WAT generator REPL
  • ⬜ Package for web use

#Evaluator

Can run programs directly in Node

#QBE Generator

Generates QBE assembly which can then be compiled down to an executable

#WASM Generator

Generates Web Assembly which can then be placed on a website