Files
pipple/README.md

121 lines
1.8 KiB
Markdown

# Pipple
Pipple is a simple Lisp-family programming language.
## Getting started
Pipple builds with CMake. Run the following to build Pipple:
```shell
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
```
The `pipple` executable will be placed in the build folder.
## Coding with Pipple
Pipple's interpreter provides a REPL for fast prototyping. Try it out by running the `pipple` command without any arguments.
```
$ ./build/pipple
pipple>
```
Pipple code you write will be run now. Try something like `(print "Hello, World!")`. See what happens!
If you'd like to use Pipple with a file, just add the filename after the executable path.
## Syntax
Pipple's syntax looks like most other Lisps. You enclose your statements in `(` and `)`.
### Printing
```
(print "Hello, World!")
(print 32)
(print 3.141)
```
### Setting and Changing Variables
```
(let x 3.141)
(print x)
(set x 2.712)
(print x)
```
### Math
Remember: Polish notation is the key!
```
(let x (+ 3 4))
(print x)
(let y (* 5 6 2))
(print y)
(print (/ 10 2))
(print (- 10 5))
```
### Conditionals
In Pipple, `nil` is the only non-truthy value. Every non-`nil` value is truthy.
```
(let x 0)
(if (== x 0)
(print "x is zero")
(set x 1)
(print "now it is" x)
)
(while (!= x 5)
(print "x is currently" x "which is not 5. i must make it 5")
(set x (+ x 1))
)
(print "now x is" x)
```
### User console input
```
(let x (input))
(print "You said" x)
```
### Lists
```
(list item1 item2 item3)
(list "hi there" 32 nil)
```
### Functions
Pipple functions require type annotations. They are also first class.
Functions are defined with the following syntax:
`(function returntype [argtype argname argtype argname] (code) (morecode))`
```
(let x (function int [int x]
(return (* x 5))
))
(print (x 3))
```
Valid types in Pipple are:
* int
* double
* string
* list