All Projects → yangtau → hedgehog

yangtau / hedgehog

Licence: MIT License
a toy programming language

Programming Languages

c
50402 projects - #5 most used programming language
Yacc
648 projects
Lex
420 projects
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to hedgehog

samlang
Sam's Programming Language
Stars: ✭ 22 (-8.33%)
Mutual labels:  interpreter
hopes
Higher Order Prolog with Extensional Semantics
Stars: ✭ 43 (+79.17%)
Mutual labels:  interpreter
warpy
WebAssembly interpreter in RPython
Stars: ✭ 54 (+125%)
Mutual labels:  interpreter
boba-js
Toy programming language. Now being reimplemented in Rust: https://github.com/poteto/monkers
Stars: ✭ 22 (-8.33%)
Mutual labels:  interpreter
cosy
A simple and pleasant programming language.
Stars: ✭ 21 (-12.5%)
Mutual labels:  interpreter
Square
The Square Programming Language. A tiny programming language under 200kb.
Stars: ✭ 23 (-4.17%)
Mutual labels:  interpreter
js-slang
Implementations of the Source languages, which are small sublanguages of JavaScript designed for SICP JS
Stars: ✭ 41 (+70.83%)
Mutual labels:  interpreter
frobtads
Linux and macOS development tools and text-mode interpreter for TADS adventure games.
Stars: ✭ 41 (+70.83%)
Mutual labels:  interpreter
monkers
Bytecode compiler and VM for the Monkeylang language, written in Rust
Stars: ✭ 34 (+41.67%)
Mutual labels:  interpreter
pip
Pip: an imperative code-golf language
Stars: ✭ 22 (-8.33%)
Mutual labels:  interpreter
js-ziju
Compile javascript to LLVM IR, x86 assembly and self interpreting
Stars: ✭ 112 (+366.67%)
Mutual labels:  interpreter
go-jdk
Run JVM-based code in Go efficiently
Stars: ✭ 61 (+154.17%)
Mutual labels:  interpreter
zeta-lang
The Zeta Programming langauge
Stars: ✭ 34 (+41.67%)
Mutual labels:  interpreter
free-monads-functional-web-apps
Delving into Free Monads and using them to write pure functional web applications
Stars: ✭ 18 (-25%)
Mutual labels:  interpreter
sebasic4
SE Basic IV 4.2 Cordelia - A free BASIC interpreter written in Z80 assembly language
Stars: ✭ 44 (+83.33%)
Mutual labels:  interpreter
esoo
Like the Programming Languages Zoo but with esoteric languages.
Stars: ✭ 18 (-25%)
Mutual labels:  interpreter
retro12
This repo is retired. See http://forthworks.com:8000/
Stars: ✭ 18 (-25%)
Mutual labels:  interpreter
ATS-blockchain
⛓️ Blockchain + Smart contracts from scratch
Stars: ✭ 18 (-25%)
Mutual labels:  interpreter
interp
Interpreter experiment. Testing dispatch methods: Switching, Direct/Indirect Threaded Code, Tail-Calls and Inlining
Stars: ✭ 32 (+33.33%)
Mutual labels:  interpreter
Corium
Corium is a modern scripting language which combines simple, safe and efficient programming.
Stars: ✭ 18 (-25%)
Mutual labels:  interpreter

Hedgehog

It is hard to design a good programming language 😭.

fn fac(n) {
  if n <=1 { return 1 } else { return n * fac(n-1) }
}

# tail call version:
fn fac_tailcall(n) {
  fn f(acc, n) {
    if n <= 1 { return acc} else { return fn(acc*n, n-1) }
  }
  return f(1, n)
}

Modules

-- math.
m = {}
m.pi = 3.14159

m.add = fn (x, y) { return x+y }

return m
math = require("math") -- math is a local number
print = require("std").print

math.add(3, 9) --> 12
print(math.pi) --> 3.14159
# a modules looks like this for interpreter:
fu () {
    m = {}
    m.pi = 3.14159

    m.add = fn (x, y) { return x+y }

    return m
}()

OOP

fn Car(speed) {
  car = {.postion = 0}

  -- methods of a object
  car.run = fn (time) { car.postion += time }
  return car
}

car = Car(4)
car.run(3)
print(car.postion) --> 12
fn Base() {
  return {.hello: fn () { return "hello from base" }}
}

base = Base()

fn A() {
  a = {}
  setmeta(a, base)
  return a
}

a = A()
a.hello() -- `hello` of base will be called

functional

fn Fun(t) {
  m = {}
  setmeta(t, m)
  
  m.map = fn (f) {
    res = {}
    setmeta(res, m)
    for k, v in t {
      res[k] = f(v)
    }
    return res
  }
    
  m.filter = fn (f) {
    res = {}
    setmeta(res, m)
    for k, v in t {
      res[k] = f(v)
    }
    return res
  }
  
  return t
}

Fun({1, 2, 3, 4}).
    filter(>0).
    map(+1)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].