9 #include "../src/vendor/rline.c"
13 #define SIMPLE_REPL_ENABLE_RLINE
14 #include "simple-repl.h"
16 KRK_Function(demofunc1) {
18 const char * b = NULL;
22 (
const char *[]){
"a",
"b"},
29 fprintf(stderr,
"a=%d\n", a);
30 fprintf(stderr,
"b=%s\n", b);
35 KRK_Function(demofunc2) {
43 "iii|iii?", (
const char *[]){
"a",
"b",
"c",
"d",
"e",
"f"},
45 &d, &e, &has_f, &f)) {
49 fprintf(stderr,
"a=%d\n", a);
50 fprintf(stderr,
"b=%d\n", b);
51 fprintf(stderr,
"c=%d\n", c);
52 fprintf(stderr,
"d=%d\n", d);
53 fprintf(stderr,
"e=%d\n", e);
54 fprintf(stderr,
"has_f=%d\n", has_f);
55 fprintf(stderr,
"f=%d\n", f);
60 KRK_Function(demofunc3) {
64 (
const char*[]){
"a",
"b",
"c"},
65 KRK_BASE_CLASS(list), &list,
66 KRK_BASE_CLASS(dict), &dict,
67 KRK_BASE_CLASS(set), &set
73 "Correctly passed values: %R %R %R",
77 KRK_Function(demofunc4) {
80 int a, b = 0, c = 1, d = 2;
83 (
const char *[]){
"a",
"b",
"c",
"d"},
91 fprintf(stderr,
"a=%d b=%d c=%d d=%d\n", a, b, c, d);
92 fprintf(stderr,
"%d extra args\n", argcount);
98 KRK_Function(takeschars) {
99 int a = 0, b = 0, c = 0;
102 "C|CC", (
const char *[]){
"a",
"b",
"c"},
107 fprintf(stderr,
"a=%d b=%d c=%d\n", a, b, c);
112 KRK_Function(parseints) {
116 if (!
krk_parseArgs(
"bIn",(
const char*[]){
"a",
"b",
"c"}, &a, &b, &c))
return NONE_VAL();
118 fprintf(stderr,
"%d %u %zd\n", a, b, c);
122 KRK_Function(parsefloats) {
126 if (!
krk_parseArgs(
"fd",(
const char*[]){
"f",
"d"}, &f, &d))
return NONE_VAL();
128 fprintf(stderr,
"%f %f\n", f, d);
132 int main(
int argc,
char * argv[]) {
KrkValue krk_runtimeError(KrkClass *type, const char *fmt,...)
Produce and raise an exception with a formatted message.
void krk_freeVM(void)
Release resources from the VM.
void krk_initVM(int flags)
Initialize the VM at program startup.
Stack reference or primative value.
Utilities for creating native bindings.
#define krk_parseArgs(f, n,...)
Parse arguments to a function while accepting keyword arguments.
Core API for the bytecode virtual machine.
krk_threadLocal KrkThreadState krk_currentThread
Thread-local VM state.
#define vm
Convenience macro for namespacing.
KrkInstance * krk_startModule(const char *name)
Set up a new module object in the current thread.