https://github.com/pb82/pebblescript
A tiny, header-only scripting engine for C++ applications
https://github.com/pb82/pebblescript
Last synced: over 1 year ago
JSON representation
A tiny, header-only scripting engine for C++ applications
- Host: GitHub
- URL: https://github.com/pb82/pebblescript
- Owner: pb82
- Created: 2012-10-07T16:13:55.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2013-08-03T09:05:53.000Z (almost 13 years ago)
- Last Synced: 2025-01-21T13:08:30.886Z (over 1 year ago)
- Language: C++
- Size: 313 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
PebbleScript
============
A toy, header-only scripting engine for C++ applications. PebbleScript implements a little stack-based language mostly inspired by PostScript.
Features:
- Very simple C++ Interop
- Tiny and header only, no linking required
- Tail call optimization (proper tail calls run in constant memory)
License:
MIT
Hello World
-----------
``` C++
#include "../include/PebbleScript.h"
#include "../include/Stdlib.h"
int main () {
PS::VM vm;
PS::Stdlib::install(vm);
vm.eval("'Hello, World!' .");
return 0;
}
```
Embedding
---------
``` C++
#include "../include/PebbleScript.h"
#include "../include/Stdlib.h"
void hello(PS::Environment *env) {
env->push("Hello, World!");
}
int main () {
PS::VM vm;
vm.def("hello", hello);
PS::Stdlib::install(vm);
vm.eval("hello .");
return 0;
}
```
Fibonacci in PebbleScript
-------------------------
```
'fib' {
dup 1 >
{ 1 - dup 1 - fib swap fib + }
if
} def
30 fib . cr
```
Dependencies
------------
Only the STL. Nothing else.