Skip to content
A lisp-looking language with interpreter and compiler to JS
Haskell JavaScript MATLAB M
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
src
.gitignore
LICENSE
README.md
Setup.hs
echoforever.m
example.m
fib.m
parser.cabal
stack.yaml
x.m

README.md

Bad Language

Bad language is a simple lipsy language to help teach myself to write a compiler in Haskell.

I have not used any formal methods here I have just made it up as I have gone along. By compiling to JS there isn't really much 'compiling' to do as JS is quite rich and has the constructs I need to just translate.

Have a look at the .m files (m is a random extension name, you can choose anything) and you get an idea of what this language can do. Not much at the moment, but just enough for a Fibonacci Sequence.

Examples

Fibonacci

(do 
	(set f1 0)
	(set f2 1)
	(set x 0)
	(while
		(neq (get x) 50)
		(do	
			(set x (+ (get x) 1))
			(set next (+ (get f1) (get f2)))
			(set f1 (get f2))
			(set f2 (get next))
			(print (get f2))
		)
	)
)

Echo

(do
	(set last "")
	(while 
		(neq (get last) "q")
		(do
			(set last (input))
			(print (get last))
		)
	)
)

Running

You can build and run the program using Haskell Stack.

You can’t perform that action at this time.