Skip to content

cwru-compilers/type-check-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Language with a Type Checker

This is a simple language with a type checker. It is an interpreted language expression oriented functional language. Which features:

- First class functions
- Closures
- Integers, floats, strings

Running:

$ go get github.com/cwru-compilers/type-check-example
$ type-check-example -T ./ex/simple.x

Example Computing the Fibonacci Sequence

file ./ex/ex3.x

add = fn(x int) fn(int) int {
	fn(y int) int {
		x + y
	}
}

fib = fn(i int) int {
	if i <= 1 {
		1
	} else {
		add(self(i-1))(self(i-2))
	}
}

fib(0)
fib(1)
fib(2)
fib(3)
fib(4)
fib(5)
fib(6)
$ ./bin/type-check-example ex/ex3.x 
> lexing ex/ex3.x
> parsing ex/ex3.x
> type checking
> evaluating
unit
unit
1
1
2
3
5
8
13

About

A simple language with a type checker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages