From 5905e3200951989b70a17b70230392b1bb11da8e Mon Sep 17 00:00:00 2001 From: Wodan58 Date: Sat, 26 Aug 2023 22:01:32 +0200 Subject: [PATCH] Align with Joy --- CMakeLists.txt | 6 +- README.md | 2 - globals.h | 8 +- parm.c | 9 +- pars.y | 7 +- src/_treegenrec.c | 6 +- src/_treerec.c | 6 +- src/casting.c | 6 +- src/filetime.c | 6 +- src/over.c | 6 +- src/pick.c | 6 +- src/round.c | 6 +- src/typeof.c | 6 +- test2/CMakeLists.txt | 452 ++++++++++++++++++++-------------------- test2/__memoryindex.joy | 6 +- test2/__memorymax.joy | 6 +- test2/__symtabindex.joy | 6 +- test2/__symtabmax.joy | 6 +- test2/gc.joy | 8 +- test2/maxint.joy | 6 +- test2/nullary.joy | 8 +- 21 files changed, 285 insertions(+), 293 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84e7d314..8cbcedc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # # module : CMakeLists.txt -# version : 1.11 -# date : 08/23/23 +# version : 1.12 +# date : 08/24/23 # cmake_minimum_required(VERSION 3.0) project(Moy VERSION 1.0) @@ -21,7 +21,7 @@ else() FLEX_TARGET(MyScanner ${CMAKE_SOURCE_DIR}/lexr.l ${CMAKE_SOURCE_DIR}/lexr.c) endif() ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser) -add_definitions(-DSYMBOLS -DCOPYRIGHT -DJVERSION="${CMAKE_BUILD_TYPE} ${CMAKE_PROJECT_VERSION}") +add_definitions(-DCOPYRIGHT -DJVERSION="${CMAKE_BUILD_TYPE} ${CMAKE_PROJECT_VERSION}") add_executable(joy arty.c comp.c dtim.c eval.c ${FLEX_MyScanner_OUTPUTS} main.c manl.c modl.c parm.c ${BISON_MyParser_OUTPUTS} prog.c read.c repl.c save.c scan.c undo.c util.c writ.c ylex.c) diff --git a/README.md b/README.md index 468438c2..f47a4bbc 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,6 @@ There is a customized version of usrlib.joy waiting in the build directory. Changes ------- -Some builtins have been added compared to Joy: `casting`, `filetime`, `over`, -`pick`, `round`, and `typeof`. Directives borrowed from [42minjoy](https://github.com/Wodan58/42minjoy) are: `%INCLUDE`, `%PUT`, and `%LISTING`. The build system requires new builtins in only one location: as a .c file in diff --git a/globals.h b/globals.h index 3b123e50..ee357cb8 100644 --- a/globals.h +++ b/globals.h @@ -1,7 +1,7 @@ /* module : globals.h - version : 1.7 - date : 08/23/23 + version : 1.8 + date : 08/24/23 */ #ifndef GLOBALS_H #define GLOBALS_H @@ -166,10 +166,6 @@ typedef struct Env { vector(Entry) *symtab; /* symbol table */ khash_t(Symtab) *hash; NodeList *stck, *prog; /* stack, code, and quotations are vectors */ -#if 0 - TokList *tokens; /* read ahead table */ - SymList *symtab; /* symbol table */ -#endif clock_t startclock; /* main */ char *pathname; char **g_argv; diff --git a/parm.c b/parm.c index 213f7cc2..d97e57c7 100644 --- a/parm.c +++ b/parm.c @@ -1,7 +1,7 @@ /* - module : parm.c - date : 1.6 - version : 08/23/23 + module : %M% + date : %I% + version : %G% */ #include "globals.h" @@ -50,8 +50,7 @@ PUBLIC void parm(pEnv env, int num, Params type, char *file) one quote is needed: */ case DIP: - if (leng < 2) - execerror("two parameters", file); + checknum(num, leng, file); first = lst_back(env->stck); if (first.op != LIST_) execerror("quotation as top parameter", file); diff --git a/pars.y b/pars.y index 77a843df..ae9e6d04 100644 --- a/pars.y +++ b/pars.y @@ -1,8 +1,8 @@ %{ /* - module : pars.y - version : 1.6 - date : 08/23/23 + module : %M% + version : %I% + date : %G% */ #include "globals.h" %} @@ -129,6 +129,7 @@ factor : USR_ { NodeList *list = 0; Node node; Entry ent; | CHAR_ { YYSTYPE u; u.num = $1; $$ = newnode(CHAR_, u); } | INTEGER_ { YYSTYPE u; u.num = $1; $$ = newnode(INTEGER_, u); } | STRING_ { YYSTYPE u; u.str = $1; $$ = newnode(STRING_, u); } + | BIGNUM_ { YYSTYPE u; u.str = $1; $$ = newnode(BIGNUM_, u); } | FLOAT_ { YYSTYPE u; u.dbl = $1; $$ = newnode(FLOAT_, u); } | list { YYSTYPE u; u.lis = $1; $$ = newnode(LIST_, u); } | set { YYSTYPE u; u.set = $1; $$ = newnode(SET_, u); } ; diff --git a/src/_treegenrec.c b/src/_treegenrec.c index bb871238..01cc1b96 100644 --- a/src/_treegenrec.c +++ b/src/_treegenrec.c @@ -1,13 +1,13 @@ /* module : _treegenrec.c - version : 1.2 - date : 08/23/23 + version : 1.3 + date : 08/26/23 */ #ifndef _TREEGENREC_C #define _TREEGENREC_C /** -OK 3180 (_treegenrec) : DDDDU T [O1] [O2] [C] -> ... +OK 3190 (_treegenrec) : DDDDU T [O1] [O2] [C] -> ... T is a tree. If T is a leaf, executes O1. Else executes O2 and then [[[O1] [O2] C] treegenrec] C. */ diff --git a/src/_treerec.c b/src/_treerec.c index bcc47390..12bcb6d2 100644 --- a/src/_treerec.c +++ b/src/_treerec.c @@ -1,13 +1,13 @@ /* module : _treerec.c - version : 1.2 - date : 08/23/23 + version : 1.3 + date : 08/26/23 */ #ifndef _TREEREC_C #define _TREEREC_C /** -OK 3190 (_treerec) : DDDU T [O] [C] -> ... +OK 3180 (_treerec) : DDDU T [O] [C] -> ... T is a tree. If T is a leaf, executes O. Else executes [[[O] C] treerec] C. */ void _treerec_(pEnv env) diff --git a/src/casting.c b/src/casting.c index fd1bde46..87f3c564 100644 --- a/src/casting.c +++ b/src/casting.c @@ -1,13 +1,13 @@ /* module : casting.c - version : 1.2 - date : 08/23/23 + version : 1.3 + date : 08/26/23 */ #ifndef CASTING_C #define CASTING_C /** -OK 3200 casting : DDA X Y -> Z +OK 2326 casting : DDA X Y -> Z Z takes the value from X and the type from Y. */ void casting_(pEnv env) diff --git a/src/filetime.c b/src/filetime.c index fd5117c9..f2899e9a 100644 --- a/src/filetime.c +++ b/src/filetime.c @@ -1,7 +1,7 @@ /* module : filetime.c - version : 1.3 - date : 08/23/23 + version : 1.4 + date : 08/26/23 */ #ifndef FILETIME_C #define FILETIME_C @@ -9,7 +9,7 @@ #include /** -OK 3210 filetime : DA F -> T +OK 1943 filetime : DA F -> T T is the modification time of file F. */ void filetime_(pEnv env) diff --git a/src/over.c b/src/over.c index 9f542c42..742b686b 100644 --- a/src/over.c +++ b/src/over.c @@ -1,13 +1,13 @@ /* module : over.c - version : 1.2 - date : 08/23/23 + version : 1.3 + date : 08/26/23 */ #ifndef OVER_C #define OVER_C /** -OK 3220 over : A X Y -> X Y X +OK 1213 over : A X Y -> X Y X Pushes an extra copy of the second item X on top of the stack. */ void over_(pEnv env) diff --git a/src/pick.c b/src/pick.c index 8367bd53..50582c59 100644 --- a/src/pick.c +++ b/src/pick.c @@ -1,13 +1,13 @@ /* module : pick.c - version : 1.3 - date : 08/23/23 + version : 1.4 + date : 08/26/23 */ #ifndef PICK_C #define PICK_C /** -OK 3230 pick : DA X Y Z 2 -> X Y Z X +OK 1216 pick : DA X Y Z 2 -> X Y Z X Pushes an extra copy of nth (e.g. 2) item X on top of the stack. */ void pick_(pEnv env) diff --git a/src/round.c b/src/round.c index 4a7d7769..5d366fbf 100644 --- a/src/round.c +++ b/src/round.c @@ -1,13 +1,13 @@ /* module : round.c - version : 1.2 - date : 08/23/23 + version : 1.3 + date : 08/26/23 */ #ifndef ROUND_C #define ROUND_C /** -OK 3240 round : DA F -> G +OK 1693 round : DA F -> G G is F rounded to the nearest integer. */ double round2(double num) diff --git a/src/typeof.c b/src/typeof.c index 4f89242e..6d27dece 100644 --- a/src/typeof.c +++ b/src/typeof.c @@ -1,13 +1,13 @@ /* module : typeof.c - version : 1.2 - date : 08/23/23 + version : 1.3 + date : 08/26/23 */ #ifndef TYPEOF_C #define TYPEOF_C /** -OK 3250 typeof : DA X -> I +OK 2323 typeof : DA X -> I Replace X by its type. */ void typeof_(pEnv env) diff --git a/test2/CMakeLists.txt b/test2/CMakeLists.txt index b98d6820..594ef6db 100644 --- a/test2/CMakeLists.txt +++ b/test2/CMakeLists.txt @@ -1,7 +1,7 @@ # # module : CMakeLists.txt -# version : 1.1 -# date : 07/10/23 +# version : 1.6 +# date : 08/26/23 # macro(exe9 src) add_custom_target(${src}.out ALL @@ -9,227 +9,227 @@ add_custom_target(${src}.out ALL COMMAND joy ${CMAKE_SOURCE_DIR}/test2/${src}.joy >${src}.out) endmacro(exe9) -exe9(__dump) -exe9(__html_manual) -exe9(__latex_manual) -exe9(__manual_list) -exe9(__memoryindex) -exe9(__memorymax) -exe9(__settracegc) -exe9(__symtabindex) -exe9(__symtabmax) -exe9(_help) -exe9(abort) -exe9(abs) -exe9(acos) -exe9(add) -exe9(all) -exe9(and) -exe9(app1) -exe9(app11) -exe9(app12) -exe9(app2) -exe9(app3) -exe9(app4) -exe9(argc) -exe9(argv) -exe9(asin) -exe9(at) -exe9(atan) -exe9(atan2) -exe9(autoput) -exe9(binary) -exe9(binrec) -exe9(body) -exe9(branch) -exe9(case) -exe9(casting) -exe9(ceil) -exe9(char) -exe9(choice) -exe9(chr) -exe9(cleave) -exe9(clock) -exe9(compare) -exe9(concat) -exe9(cond) -exe9(condlinrec) -exe9(condnestrec) -exe9(cons) -exe9(construct) -exe9(conts) -exe9(cos) -exe9(cosh) -exe9(dip) -exe9(div) -exe9(divide) -exe9(drop) -exe9(dup) -exe9(dupd) -exe9(echo) -exe9(enconcat) -exe9(eql) -exe9(equal) -exe9(exp) -exe9(false) -exe9(fclose) -exe9(feof) -exe9(ferror) -exe9(fflush) -exe9(fget) -exe9(fgetch) -exe9(fgets) -exe9(file) -exe9(filetime) -exe9(filter) -exe9(first) -exe9(float) -exe9(floor) -exe9(fold) -exe9(fopen) -exe9(format) -exe9(formatf) -exe9(fput) -exe9(fputch) -exe9(fputchars) -exe9(fputstring) -exe9(fread) -exe9(fremove) -exe9(frename) -exe9(frexp) -exe9(fseek) -exe9(ftell) -exe9(fwrite) -exe9(gc) -exe9(genrec) -exe9(geql) -exe9(get) -exe9(getch) -exe9(getenv) -exe9(gmtime) -exe9(greater) -exe9(has) -exe9(help) -exe9(helpdetail) -exe9(i) -exe9(id) -exe9(ifchar) -exe9(iffile) -exe9(iffloat) -exe9(ifinteger) -exe9(iflist) -exe9(iflogical) -exe9(ifset) -exe9(ifstring) -exe9(ifte) -exe9(in) -exe9(include) -exe9(infra) -exe9(integer) -exe9(intern) -exe9(ldexp) -exe9(leaf) -exe9(leql) -exe9(less) -exe9(linrec) -exe9(list) -exe9(localtime) -exe9(log) -exe9(log10) -exe9(logical) -exe9(manual) -exe9(map) -exe9(max) -exe9(maxint) -exe9(min) -exe9(mktime) -exe9(modf) -exe9(mul) -exe9(name) -exe9(neg) -exe9(neql) -exe9(not) -exe9(null) -exe9(nullary) -exe9(of) -exe9(opcase) -exe9(or) -exe9(ord) -exe9(over) -exe9(pick) -exe9(pop) -exe9(popd) -exe9(pow) -exe9(pred) -exe9(primrec) -exe9(put) -exe9(putch) -exe9(putchars) -exe9(quit) -exe9(rand) -exe9(rem) -exe9(rest) -exe9(rolldown) -exe9(rolldownd) -exe9(rollup) -exe9(rollupd) -exe9(rotate) -exe9(rotated) -exe9(round) -exe9(sametype) -exe9(set) -exe9(setautoput) -exe9(setecho) -exe9(setsize) -exe9(setundeferror) -exe9(sign) -exe9(sin) -exe9(sinh) -exe9(size) -exe9(small) -exe9(some) -exe9(split) -exe9(sqrt) -exe9(srand) -exe9(stack) -exe9(stderr) -exe9(stdin) -exe9(stdout) -exe9(step) -exe9(stop) -exe9(strftime) -exe9(string) -exe9(strtod) -exe9(strtol) -exe9(sub) -exe9(succ) -exe9(swap) -exe9(swapd) -exe9(swons) -exe9(system) -exe9(tailrec) -exe9(take) -exe9(tan) -exe9(tanh) -exe9(ternary) -exe9(time) -exe9(times) -exe9(treegenrec) -exe9(treerec) -exe9(treestep) -exe9(true) -exe9(trunc) -exe9(typeof) -exe9(unary) -exe9(unary2) -exe9(unary3) -exe9(unary4) -exe9(uncons) -exe9(undeferror) -exe9(undefs) -exe9(unstack) -exe9(unswons) -exe9(user) -exe9(while) -exe9(x) -exe9(xor) +exe9(__dump.joy) +exe9(__html_manual.joy) +exe9(__latex_manual.joy) +exe9(__manual_list.joy) +exe9(__memoryindex.joy) +exe9(__memorymax.joy) +exe9(__settracegc.joy) +exe9(__symtabindex.joy) +exe9(__symtabmax.joy) +exe9(_help.joy) +exe9(abort.joy) +exe9(abs.joy) +exe9(acos.joy) +exe9(add.joy) +exe9(all.joy) +exe9(and.joy) +exe9(app1.joy) +exe9(app11.joy) +exe9(app12.joy) +exe9(app2.joy) +exe9(app3.joy) +exe9(app4.joy) +exe9(argc.joy) +exe9(argv.joy) +exe9(asin.joy) +exe9(at.joy) +exe9(atan.joy) +exe9(atan2.joy) +exe9(autoput.joy) +exe9(binary.joy) +exe9(binrec.joy) +exe9(body.joy) +exe9(branch.joy) +exe9(case.joy) +exe9(casting.joy) +exe9(ceil.joy) +exe9(char.joy) +exe9(choice.joy) +exe9(chr.joy) +exe9(cleave.joy) +exe9(clock.joy) +exe9(compare.joy) +exe9(concat.joy) +exe9(cond.joy) +exe9(condlinrec.joy) +exe9(condnestrec.joy) +exe9(cons.joy) +exe9(construct.joy) +exe9(conts.joy) +exe9(cos.joy) +exe9(cosh.joy) +exe9(dip.joy) +exe9(div.joy) +exe9(divide.joy) +exe9(drop.joy) +exe9(dup.joy) +exe9(dupd.joy) +exe9(echo.joy) +exe9(enconcat.joy) +exe9(eql.joy) +exe9(equal.joy) +exe9(exp.joy) +exe9(false.joy) +exe9(fclose.joy) +exe9(feof.joy) +exe9(ferror.joy) +exe9(fflush.joy) +exe9(fget.joy) +exe9(fgetch.joy) +exe9(fgets.joy) +exe9(file.joy) +exe9(filetime.joy) +exe9(filter.joy) +exe9(first.joy) +exe9(float.joy) +exe9(floor.joy) +exe9(fold.joy) +exe9(fopen.joy) +exe9(format.joy) +exe9(formatf.joy) +exe9(fput.joy) +exe9(fputch.joy) +exe9(fputchars.joy) +exe9(fputstring.joy) +exe9(fread.joy) +exe9(fremove.joy) +exe9(frename.joy) +exe9(frexp.joy) +exe9(fseek.joy) +exe9(ftell.joy) +exe9(fwrite.joy) +exe9(gc.joy) +exe9(genrec.joy) +exe9(geql.joy) +exe9(get.joy) +exe9(getch.joy) +exe9(getenv.joy) +exe9(gmtime.joy) +exe9(greater.joy) +exe9(has.joy) +exe9(help.joy) +exe9(helpdetail.joy) +exe9(i.joy) +exe9(id.joy) +exe9(ifchar.joy) +exe9(iffile.joy) +exe9(iffloat.joy) +exe9(ifinteger.joy) +exe9(iflist.joy) +exe9(iflogical.joy) +exe9(ifset.joy) +exe9(ifstring.joy) +exe9(ifte.joy) +exe9(in.joy) +exe9(include.joy) +exe9(infra.joy) +exe9(integer.joy) +exe9(intern.joy) +exe9(ldexp.joy) +exe9(leaf.joy) +exe9(leql.joy) +exe9(less.joy) +exe9(linrec.joy) +exe9(list.joy) +exe9(localtime.joy) +exe9(log.joy) +exe9(log10.joy) +exe9(logical.joy) +exe9(manual.joy) +exe9(map.joy) +exe9(max.joy) +exe9(maxint.joy) +exe9(min.joy) +exe9(mktime.joy) +exe9(modf.joy) +exe9(mul.joy) +exe9(name.joy) +exe9(neg.joy) +exe9(neql.joy) +exe9(not.joy) +exe9(null.joy) +exe9(nullary.joy) +exe9(of.joy) +exe9(opcase.joy) +exe9(or.joy) +exe9(ord.joy) +exe9(over.joy) +exe9(pick.joy) +exe9(pop.joy) +exe9(popd.joy) +exe9(pow.joy) +exe9(pred.joy) +exe9(primrec.joy) +exe9(put.joy) +exe9(putch.joy) +exe9(putchars.joy) +exe9(quit.joy) +exe9(rand.joy) +exe9(rem.joy) +exe9(rest.joy) +exe9(rolldown.joy) +exe9(rolldownd.joy) +exe9(rollup.joy) +exe9(rollupd.joy) +exe9(rotate.joy) +exe9(rotated.joy) +exe9(round.joy) +exe9(sametype.joy) +exe9(set.joy) +exe9(setautoput.joy) +exe9(setecho.joy) +exe9(setsize.joy) +exe9(setundeferror.joy) +exe9(sign.joy) +exe9(sin.joy) +exe9(sinh.joy) +exe9(size.joy) +exe9(small.joy) +exe9(some.joy) +exe9(split.joy) +exe9(sqrt.joy) +exe9(srand.joy) +exe9(stack.joy) +exe9(stderr.joy) +exe9(stdin.joy) +exe9(stdout.joy) +exe9(step.joy) +exe9(stop.joy) +exe9(strftime.joy) +exe9(string.joy) +exe9(strtod.joy) +exe9(strtol.joy) +exe9(sub.joy) +exe9(succ.joy) +exe9(swap.joy) +exe9(swapd.joy) +exe9(swons.joy) +exe9(system.joy) +exe9(tailrec.joy) +exe9(take.joy) +exe9(tan.joy) +exe9(tanh.joy) +exe9(ternary.joy) +exe9(time.joy) +exe9(times.joy) +exe9(treegenrec.joy) +exe9(treerec.joy) +exe9(treestep.joy) +exe9(true.joy) +exe9(trunc.joy) +exe9(typeof.joy) +exe9(unary.joy) +exe9(unary2.joy) +exe9(unary3.joy) +exe9(unary4.joy) +exe9(uncons.joy) +exe9(undeferror.joy) +exe9(undefs.joy) +exe9(unstack.joy) +exe9(unswons.joy) +exe9(user.joy) +exe9(while.joy) +exe9(x.joy) +exe9(xor.joy) diff --git a/test2/__memoryindex.joy b/test2/__memoryindex.joy index 428e1b24..367fa04d 100644 --- a/test2/__memoryindex.joy +++ b/test2/__memoryindex.joy @@ -1,7 +1,7 @@ (* module : __memoryindex.joy - version : 1.3 - date : 08/20/22 + version : 1.4 + date : 08/26/23 *) 0 1 2 3 4 5 6 7 8 9 10 -__memoryindex dup 30 =. +__memoryindex. diff --git a/test2/__memorymax.joy b/test2/__memorymax.joy index fd2795ea..a31228b8 100644 --- a/test2/__memorymax.joy +++ b/test2/__memorymax.joy @@ -1,7 +1,7 @@ (* module : __memorymax.joy - version : 1.2 - date : 08/20/22 + version : 1.3 + date : 08/26/23 *) 0 1 2 3 4 5 6 7 8 9 10 -__memorymax dup 31 =. +__memorymax. diff --git a/test2/__symtabindex.joy b/test2/__symtabindex.joy index a5be488d..f00fd1a3 100644 --- a/test2/__symtabindex.joy +++ b/test2/__symtabindex.joy @@ -1,6 +1,6 @@ (* module : __symtabindex.joy - version : 1.3 - date : 08/20/22 + version : 1.4 + date : 08/26/23 *) -__symtabindex 229 =. +__symtabindex. diff --git a/test2/__symtabmax.joy b/test2/__symtabmax.joy index 3cf6df4a..b0b676e6 100644 --- a/test2/__symtabmax.joy +++ b/test2/__symtabmax.joy @@ -1,6 +1,6 @@ (* module : __symtabmax.joy - version : 1.2 - date : 08/20/22 + version : 1.3 + date : 08/26/23 *) -__symtabmax 256 =. +__symtabmax. diff --git a/test2/gc.joy b/test2/gc.joy index 89e431d4..18907904 100644 --- a/test2/gc.joy +++ b/test2/gc.joy @@ -1,10 +1,10 @@ (* module : gc.joy - version : 1.4 - date : 07/10/23 + version : 1.5 + date : 08/26/23 *) 1 100 from-to-list pop. -__memorymax +__memoryindex gc -__memorymax >. +__memoryindex >. diff --git a/test2/maxint.joy b/test2/maxint.joy index 24196b10..c06cedb4 100644 --- a/test2/maxint.joy +++ b/test2/maxint.joy @@ -1,6 +1,6 @@ (* module : maxint.joy - version : 1.2 - date : 08/20/22 + version : 1.3 + date : 08/26/23 *) -"maxint" intern [] cons i 9223372036854775807 =. +"maxint" intern [] cons i pred 9223372036854775806 =. diff --git a/test2/nullary.joy b/test2/nullary.joy index 55599c21..87bd3bec 100644 --- a/test2/nullary.joy +++ b/test2/nullary.joy @@ -1,11 +1,9 @@ (* module : nullary.joy - version : 1.4 - date : 05/23/23 + version : 1.5 + date : 08/26/23 *) -"../lib/inilib.joy" include. -"../lib/numlib.joy" include. -"../lib/agglib.joy" include. +"numlib" libload. 2 20 from-to-list dup [prime] map zip [second] filter [first] map [2 3 5 7 11 13 17 19] equal.