Skip to content

8l/gsp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gsp

Gsp is a compiler built on top of Joseph Adams' Gisp. Gsp provides a more complete language environment, including Golang bindings and the Gsp Prelude.

Install

go get github.com/gsp-lang/gsp
cd <GOPATH>/src/github.com/gsp-lang/gsp
go build
echo 'export PATH=$PATH:"${pwd}"' >> ~/.profile
. ~/.bashrc # . ~/.zshrc

Build Prelude

cd <GOPATH>/src/github.com/gsp-lang/stdlib/prelude
gsp prelude.gsp > prelude.go

Example

; Copy into example.gsp
(ns main
    "/fmt"
    "/net/http")

(def hello (fn [w r]
    (fmt/fprintf w "hello")
    ()))

(def main (fn []
    (http/handle-func "/" hello)
    (http/listen-and-serve ":9090" nil)))

To compile & run

gspc example.gsp
./bin/main

Using the Prelude

(ns main
	"/fmt")

(def main (fn []
    (let [[m (/cons 2 (/cons 1 /null))]]
        (fmt/println (/car (/cons 1 /null)))
        (fmt/println (/len (/cons 1 /null)))
        (fmt/println (/car (/map (fn [x] (+ x 20)) m)) (/car m))
        (fmt/println (/len m))
        (fmt/println (/car (/cons 17 m)))
        (fmt/println [1 2 3 4])
        (fmt/println (/car (/cdr (/cdr (/append m (/cdr m))))))
        ())))

More examples

Check out the Prelude. It is written in Gsp.

License

Originally licensed code can be found at https://github.com/jcla1/gisp.

MIT

About

The gsp compiler.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%