Seacucumber is a small, interpreted functional programming language written in C. It was inspired by other languages such as scheme, elixir, and OCaml. This project was done as an attempt by me to learn about programming language implementation and compiler theory.
Instructions to build Seacucumber from source. To actually use the transpiler, you will need to have OCaml installed on your system.
# clone this repository
git clone https://github.com/rmrt1n/seacucumber.git
# cd into the repository
cd seacucumber
# build seacucumber
make
scc
is the executable for the tree walking interpreter, while tscc
is the
Seacucumber-to-OCaml transpiler. Below are the commmands to run the programs.
For examples of programs written in Seacucumber, checkout the
examples directory.
# run an interactive prompt
./scc
# interpret seacucumber code
./scc FILENAME
# tscc will compile seacucumber to ocaml,
# and run ocamlc to create an executable
./tscc FILENAME
Here is the BNF grammar of Seacucumber:
program -> form* EOF
form -> (expression | assignment)
assignment -> "let" IDENT "=" expression
expression -> "if" logic_or "then" expression (else expression)?
| "fn" "(" params? ")" "->" expression
| block
| logic_or
params -> IDENT ("," IDENT)*
block -> "do" form* "done" ";"
logic_or -> logic_and ("or" logic_and)*
logic_and -> equality ("and" equality)*
equality -> comparison (("==" | "!=") comparison)*
comparison -> addition (("<" | ">" | "<=" | ">=") addition)*
addition -> multiplication (("+" | "-") multiplication)*
multiplication -> unary (("*" | "/") unary)*
unary -> ("!" | "-") unary | call
call -> primary ("(" args? ")")*
args -> expression ("," expression)*
primary -> NUMBER | STRING | IDENT
| "true" | "false" | "nil"
| "(" expression ")"
Distributed under the MIT License. See LICENSE for more information.