Files
pipple/README.md

139 lines
2.7 KiB
Markdown
Raw Normal View History

2025-11-10 20:44:10 +11:00
# 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
2025-11-15 13:52:23 +11:00
pipple>
2025-11-10 20:44:10 +11:00
```
Pipple code you write will be run now. Try something like `(print "Hello, World!")`. See what happens!
2025-11-16 18:51:20 +11:00
If you'd like to use Pipple with a file, just add the filename after the executable path, like `pipple path/to/code.ppl`
Pipple also has an experimental transpiler, which will turn your Pipple code into C++. To use, run `pipple -c path/to/code.ppl`. This will print code to the console.
To quickly compile Pipple code, try `pipple -c path/to/code.ppl | g++ -xc++ - -o exename`, where `exename` is the name of the executable to output to.
2025-11-10 20:44:10 +11:00
## 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
2025-11-16 18:51:20 +11:00
`let` initializes a variable for the first time.
`set` changes that variable to something else.
Note: `set` is currently unsupported by the Pipple transpiler.
2025-11-10 20:44:10 +11:00
```
(let x 3.141)
(print x)
(set x 2.712)
(print x)
```
### Math
Remember: Polish notation is the key!
2025-11-16 18:51:20 +11:00
Note: All math is currently unsupported by the Pipple transpiler.
2025-11-10 20:44:10 +11:00
```
(let x (+ 3 4))
(print x)
(let y (* 5 6 2))
(print y)
(print (/ 10 2))
(print (- 10 5))
```
### Conditionals
2025-11-15 13:52:23 +11:00
In Pipple, `nil` is the only non-truthy value. Every non-`nil` value is truthy.
2025-11-16 18:51:20 +11:00
Note: All conditionals are currently unsupported by the Pipple transpiler.
2025-11-10 20:44:10 +11:00
```
(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
2025-11-16 18:51:20 +11:00
Note: `input` is currently unsupported by the Pipple transpiler.
2025-11-10 20:44:10 +11:00
```
(let x (input))
(print "You said" x)
2025-11-15 13:52:23 +11:00
```
### Lists
2025-11-16 18:51:20 +11:00
Note: Lists are currently unsupported by the Pipple transpiler.
2025-11-15 13:52:23 +11:00
```
(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
2025-11-16 18:51:20 +11:00
* list (Currently unsupported by the Pipple transpiler)