88 lines
1.4 KiB
Markdown
88 lines
1.4 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
|
|
|
|
```
|
|
(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)
|
|
``` |