ReMonkey: An implementation of the Monkey Langauge written in ReScript

Hello friends,

I wrote an implementation of the Monkey Language (a toy language designed to teach interpreters) using ReScript. It includes Lexer, Parser and Interpreter.

As my first ReScript project, any feedback is welcome. I’l write a blog post about it in the near future

https://github.com/MarioAriasC/ReMonkey/

6 Likes

Cool!

Did you try using the char datatype for it before? It’s at least very convenient if ASCII is sufficient to your needs, since you can check ranges, e.g.:

let isLetter = char =>
  switch char {
  | 'a' .. 'z' | 'A' .. 'Z' | '_' => true
  | _ => false
  }

let isDigit = char =>
  switch char {
  | '0' .. '9' => true
  | _ => false
  }

let isWhitespace = char =>
  switch char {
  | ' ' | '\t' | '\n' | '\r' => true
  | _ => false
  }

But it’s a bit quirky to use since it was inherited from the OCaml standard library, which is why we want to change it a bit (see RFC: RFC: Revise `char` primitive · Issue #7028 · rescript-lang/rescript · GitHub)

I am impressed that you tried to implement it in a whole bunch of languages, I guess you want to compare the strengths and weaknesses of all of them in that blog post.

I am looking forward to it!

2 Likes

Thanks, I didn’t know that.

The blog post is part of an ongoing series,

https://marioarias.hashnode.dev/comparing-implementations-of-the-monkey-language-ix-a-monkey-and-his-bun-typescript

2 Likes

Looking forward to the next episode :grin:

1 Like