Quick fixes for BSD

This commit is contained in:
Charlie Root 2025-03-22 22:30:48 +00:00
parent 1ac96b0d60
commit 53dad0f47b
4 changed files with 10 additions and 7 deletions

View file

@ -36,7 +36,7 @@ builddir:
@- mv $(wildcard $(BUILD_DIR)/*.o) build-tmp/
yacc: src/parser.y src/parser.l
cd src && yacc -d -g parser.y && lex parser.l
cd src && bison -y -d parser.y && lex parser.l
$(CC) -c src/y.tab.c -o build-tmp/y.tab.o $(CFLAGS)
$(CC) -c src/lex.yy.c -o build-tmp/lex.yy.o $(CFLAGS)

View file

@ -14,10 +14,10 @@ Pre-requisites:
- GNU Make
### Unix
Running `make` twice should work on most Unix systems.
Running `make` (or `gmake` for BSDs) should work on most Unix systems.
It produces an executable called `flisp.amd64`
### Windows
To meet the previously mentionned pre-requisites, you need to use mingw.
I recommend installing w64devkit, then compiling Bison and Flex from source.
Run `make win`, twice.
Run `make win`

View file

@ -599,6 +599,7 @@ Value pop(Value a, Value b){
}
Value write(Value a){
char *nstr;
switch(a.tag.type){
case T_null:
case T_any:
@ -614,7 +615,6 @@ Value write(Value a){
printf("%f",a.v4B.vfl);
break;
case T_str:
char *nstr;
nstr = malloc(a.vstr.len+1);
if(a.vstr.len > 4){
char *str = get_addr(a.vstr.pos);

View file

@ -54,14 +54,16 @@ Value fncall(FnSig *fn, Statement **params){
case 0:
returnv = fn->bi();
break;
case 1:
case 1:{
Value (*fn1)(Value) = (void*)fn->bi;
returnv = fn1(execute(params[0]));
break;
case 2:
}
case 2:{
Value (*fn2)(Value,Value) = (void*)fn->bi;
returnv = fn2(execute(params[0]),execute(params[1]));
break;
}
default:
runtime_err("Call to builtin with >2 params");
break;
@ -146,7 +148,7 @@ Value execute(Statement *stat){
case BI_cast:
returnv = cast(stat->var_type, execute(stat->children[0]));
break;
case ST_Call:
case ST_Call:{
FnSig *fn = stat->func;
Statement **params = NULL;
if(fn->n_param)
@ -154,5 +156,6 @@ Value execute(Statement *stat){
returnv = fncall(fn, params);
break;
}
}
return returnv;
}