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:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user