1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-30 15:13:03 +00:00

Add utf-8 compatibility in parser. Symbols can

be valid utf-8 strings
This commit is contained in:
bakpakin
2017-12-20 23:03:34 -05:00
parent 8eea6e2a70
commit 34a83839f5
26 changed files with 1871 additions and 521 deletions

View File

@@ -1,6 +1,15 @@
#include "unit.h"
#include <dst/dst.h>
int testprint(DstValue *argv, int32_t argn) {
printf("hello!\n");
return 0;
}
DstReg testreg[] = {
{"print", testprint}
};
int main() {
DstParseResult pres;
DstCompileOptions opts;
@@ -33,6 +42,8 @@ int main() {
opts.flags = 0;
opts.source = pres.value;
opts.sourcemap = pres.map;
opts.env = dst_loadreg(testreg, sizeof(testreg)/sizeof(DstReg));
dst_puts(dst_formatc("initial compile env: %v\n", opts.env));
cres = dst_compile(opts);
if (cres.status == DST_COMPILE_ERROR) {

View File

@@ -1,10 +1,11 @@
#include "unit.h"
#include "../core/gc.h"
#include <dst/dst.h>
#include <stdio.h>
/* Create dud funcdef and function */
static DstFunction *dud_func(uint32_t slotcount, uint32_t arity, int varargs) {
DstFuncDef *def = dst_alloc(DST_MEMORY_FUNCDEF, sizeof(DstFuncDef));
DstFuncDef *def = dst_gcalloc(DST_MEMORY_FUNCDEF, sizeof(DstFuncDef));
def->environments_length = 0;
def->constants_length = 0;
def->bytecode_length = 0;
@@ -14,7 +15,7 @@ static DstFunction *dud_func(uint32_t slotcount, uint32_t arity, int varargs) {
def->flags = varargs ? DST_FUNCDEF_FLAG_VARARG : 0;
def->arity = arity;
def->slotcount = slotcount;
DstFunction *f = dst_alloc(DST_MEMORY_FUNCTION, sizeof(DstFunction));
DstFunction *f = dst_gcalloc(DST_MEMORY_FUNCTION, sizeof(DstFunction));
f->envs = NULL;
f->def = def;
return f;
@@ -84,5 +85,7 @@ int main() {
dst_fiber_funcframe_tail(fiber1, dud_func(20, 0, 0));
debug_print_fiber(fiber1, 1);
//dst_deinit();
return 0;
}