https://github.com/brandondyer64/kscript
A pipelined, fully functional programming language that compiles to JavaScript
https://github.com/brandondyer64/kscript
Last synced: 3 months ago
JSON representation
A pipelined, fully functional programming language that compiles to JavaScript
- Host: GitHub
- URL: https://github.com/brandondyer64/kscript
- Owner: BrandonDyer64
- License: mit
- Created: 2019-06-05T23:47:22.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T12:29:58.000Z (over 2 years ago)
- Last Synced: 2025-01-24T07:23:22.678Z (5 months ago)
- Language: JavaScript
- Size: 106 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KScript
A pipelined, fully functional programming language that compiles to JavaScript
```js
; let Fibonacci = (a = 0, b = 1) => {
if (_ == 0) {
| a + b
} else {
| _ - 1
Fibonacci(b, a + b)
}
}| 50
Fibonacci()
> console.log
```KScript uses a flowing stack that "falls" through the program.
This:
```js
| X
Thing1
Thing2
Thing3(a)
```Becomes this:
```js
X
|> Thing1
|> Thing2
|> Thing3(a)
```Compiles to this:
```js
let _;
_ = X
_ = Thing1(_)
_ = Thing2(_)
_ = Thing3(a)(_)
```### Operators
```js
-> Set + Eval
| -> Set
: -> Eval
; ->x
_ = x(_)| x
_ = x: x
x(_); x
x
```### Scoping
This:
```js
{
a
b
}
```Compiles to this:
```js
_ = ( _ => {
_ = a(_)
_ = b(_)
return _
})(_)
```### Escaped scope
```js
| 1
{
Add(2)
}
// : 3| 1
; {
Add(2)
}
// : 1// And you can set a variable to the value of a scope
| 1
; let x = ({
Add(2)
})(_)
// : 1
// x: 3
```### Functions and Floating Scopes
```js
// Function
; let Add = (x) => {
x +
}// Floating scope
; let Add2 = {
Add(2)
}| 1
Add2
Add(3)
// : 6
```