Skip to content

Commit

Permalink
Back to standard
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodan58 committed Nov 6, 2023
1 parent a290816 commit dc60166
Show file tree
Hide file tree
Showing 46 changed files with 265 additions and 218 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# module : CMakeLists.txt
# version : 1.17
# date : 10/26/23
# version : 1.18
# date : 11/06/23
#
cmake_minimum_required(VERSION 3.0)
project(Moy VERSION 1.0)
Expand Down Expand Up @@ -36,7 +36,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
include_directories(bdwgc/include)
add_subdirectory(bdwgc)
else()
set(CF "-DCOPYRIGHT -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter")
set(CF "-DCOPYRIGHT -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage") # debug, no optimization
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") # enabling coverage
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ See also

Implementation|Dependencies
---|---
[Joy - NOBDW](https://github.com/Wodan58/Joy)|
[joy1 - BDW](https://github.com/Wodan58/joy1)|[BDW garbage collector](https://github.com/ivmai/bdwgc)
[Moy](https://github.com/Wodan58/Moy)|[BDW garbage collector](https://github.com/ivmai/bdwgc) and [Lex & Yacc](https://sourceforge.net/projects/winflexbison/files/win_flex_bison-latest.zip)
[Joy](https://github.com/Wodan58/Joy)|
[joy1](https://github.com/Wodan58/joy1)|[BDW garbage collector](https://github.com/ivmai/bdwgc)
14 changes: 5 additions & 9 deletions arty.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
module : arty.c
version : 1.5
date : 10/02/23
version : 1.6
date : 11/06/23
*/
#include "globals.h"

Expand All @@ -14,15 +14,13 @@
*/
PUBLIC int arity(pEnv env, NodeList *quot, int num)
{
int i, j;
char *str;
Entry ent;
NodeList *list;
Node node, prev;

list = pvec_init();
for (i = 0, j = pvec_cnt(quot); i < j; i++)
list = pvec_add(list, pvec_nth(quot, i)); /* make a copy */
pvec_copy(list, quot); /* make a copy */
prev.u.lis = 0;
prev.op = 0;
while (pvec_cnt(list)) {
Expand All @@ -31,8 +29,7 @@ PUBLIC int arity(pEnv env, NodeList *quot, int num)
case USR_:
ent = vec_at(env->symtab, node.u.ent);
if (ent.u.body && !pvec_getused(ent.u.body)) {
for (i = 0, j = pvec_cnt(ent.u.body); i < j; i++)
list = pvec_add(list, pvec_nth(ent.u.body, i));
list = pvec_concat(list, ent.u.body);
pvec_setused(ent.u.body); /* prevent recursion */
}
break;
Expand All @@ -47,8 +44,7 @@ PUBLIC int arity(pEnv env, NodeList *quot, int num)
} else if (*str == 'P') { /* previous */
if (prev.op != LIST_)
return -1;
for (i = 0, j = pvec_cnt(prev.u.lis); i < j; i++)
list = pvec_add(list, pvec_nth(prev.u.lis, i));
list = pvec_concat(list, prev.u.lis);
} else if (*str == 'U') /* unknown */
return -1;
break;
Expand Down
10 changes: 6 additions & 4 deletions eval.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* module : eval.c
* version : 1.12
* date : 10/02/23
* version : 1.13
* date : 11/06/23
*/
#include "globals.h"

Expand Down Expand Up @@ -51,8 +51,10 @@ void trace(pEnv env, FILE *fp)
if (!env->debugging)
return;
writestack(env, env->stck, fp);
fprintf(fp, " : ");
writeterm(env, env->prog, fp);
if (env->debugging == 2) {
fprintf(fp, " : ");
writeterm(env, env->prog, fp);
}
fputc('\n', fp);
fflush(fp);
}
Expand Down
5 changes: 3 additions & 2 deletions globals.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
module : globals.h
version : 1.25
date : 10/26/23
version : 1.26
date : 11/06/23
*/
#ifndef GLOBALS_H
#define GLOBALS_H
Expand All @@ -21,6 +21,7 @@
#if 0
#define USE_BIGNUM_ARITHMETIC
#define USE_MULTI_THREADS_JOY
#define WRITE_USING_RECURSION
#endif

#include <gc.h> /* system installed BDW or local gc.h */
Expand Down
4 changes: 2 additions & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# module : CMakeLists.txt
# version : 1.2
# date : 08/28/23
# version : 1.3
# date : 11/05/23
#
macro(exe9 src)
add_custom_target(${src}.out ALL
Expand Down
4 changes: 2 additions & 2 deletions lib/agglib.joy
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ LIBRA

(* on two operands *)

null2 == over null over null or;
null2 == nulld null or;
cons2 == swapd cons consd;
uncons2 == unconsd uncons swapd;
swons2 == swapd swons swonsd;
Expand All @@ -49,7 +49,7 @@ LIBRA

from-to == (* lo hi agg *)
[] cons [pop pop] swoncat
[over over >] swap
[>] swap
[ [dup succ] dip ]
[cons]
linrec;
Expand Down
2 changes: 1 addition & 1 deletion lib/fib.joy
Original file line number Diff line number Diff line change
@@ -1 +1 @@
39 [dup small] [] [pred dup pred] [+] binrec.
40 [small] [] [pred dup pred] [+] binrec.
4 changes: 2 additions & 2 deletions lib/flatjoy.joy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ P3 == [ [[1 2][3 4][5] []] [[dup *] map] map ]. # double nesting
DEFINE
c == concat;
j2f-f ==
[ dup list ]
[ list ]
[ [[[]] concat] dip [j2f-f] step [[] cons c] concat ]
[ [] cons [c] cons concat ]
ifte;
Expand Down Expand Up @@ -38,7 +38,7 @@ P3 j2f-forwards i i .
DEFINE
s == swoncat;
j2f-r ==
[ dup list ]
[ list ]
[ [[swons] swoncat] dip [j2f-r] step [] swons ]
[ [] cons [s] cons swoncat ]
ifte;
Expand Down
4 changes: 2 additions & 2 deletions lib/gcd.joy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!../joy
#!../build/joy

argv rest [10 strtol] map uncons uncons pop # get two params
[dup 0 >] [dup rollup rem] while pop # find gcd
[0 >] [dup rollup rem] while pop # find gcd
put '\n putch.
quit.
32 changes: 16 additions & 16 deletions lib/grmlib.joy
Original file line number Diff line number Diff line change
Expand Up @@ -49,49 +49,49 @@ IN
"generate B" gen-trace
unswons
# binary operators
[ [ [dup [ | ] in ]
[ [ [[ | ] in]
pop
[ [] cons cons cons dup ] dip
uncons first
[ swap
[[i] dip generate] dip ]
dip
[i] dip generate ]
[ [dup [ _ ] in ]
[ [[ _ ] in ]
pop uncons first
[ [generate] cons swons ]
dip generate ]
# unary operators
[ [dup [ ? ] in ]
[ [[ ? ] in ]
pop
[ [] cons cons cons dup
[i unswons i] dip ]
dip
[i] dip first generate ]
[ [dup [ + ] in ]
[ [[ + ] in ]
swons
[] cons cons cons cons dup
[ i second generate ] dip
i dup
[ [generate] cons swons ] dip
second generate ]
[ [dup [ * ] in ]
[ [[ * ] in ]
swons
[ [] cons cons cons dup
[i unswons i] dip ]
dip
dup
[ [i] dip [generate] cons swons ] dip
second generate ]
[ [dup [ $ ] in]
[ [[ $ ] in]
pop first i
Min2Tre generate ]
[ [dup [QUOTE] in ]
[ [[QUOTE] in ]
pop first
swap [swons] dip
unswons i ]
# operands
[ [dup [epsilon] in ]
[ [[epsilon] in ]
pop pop
unswons i ]
[ # default: an atom
Expand Down Expand Up @@ -144,49 +144,49 @@ IN
"parse B" prs-trace
unswons
# binary operators
[ [ [dup [ | ] in]
[ [ [[ | ] in]
pop
[ [] cons cons dup ] dip
uncons first
[ swap
[[i] dip parse] dip ]
dip
[i] dip parse ]
[ [dup [ _ ] in ]
[ [[ _ ] in ]
pop uncons first swap # in generate there is no swap
[ [parse] cons swons ]
dip parse ]
# unary operators
[ [dup [ ? ] in ]
[ [[ ? ] in ]
pop
[ [] cons cons dup
[i unswons i] dip ]
dip
[i] dip first parse ]
[ [dup [ + ] in ]
[ [[ + ] in ]
swons
[] cons cons cons dup
[ i second parse ] dip
i dup
[ [parse] cons swons ] dip
second parse ]
[ [dup [ * ] in ]
[ [[ * ] in ]
swons
[ [] cons cons dup
[i unswons i] dip ]
dip
dup
[ [i] dip [parse] cons swons ] dip
second parse ]
[ [dup [ $ ] in]
[ [[ $ ] in]
pop first i
Min2Tre parse ]
[ [dup [QUOTE] in ]
[ [[QUOTE] in ]
pop first
swap [swons] dip
unswons i ]
# operands
[ [dup [epsilon] in ]
[ [[epsilon] in ]
pop pop
unswons i ]
[ # default: an atom
Expand Down
2 changes: 1 addition & 1 deletion lib/grmtst.joy
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ DEFINE

DEFINE
string2charlist ==
[dup null] [pop []] [uncons] [cons] linrec.
[null] [pop []] [uncons] [cons] linrec.


"CNpApKpp" string2charlist Polish prs-test.
Expand Down
2 changes: 1 addition & 1 deletion lib/inilib.joy
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ LIBRA

verbose == false;
libload ==
[ dup '_ swons intern body null ]
[ '_ swons intern body null ]
[ ".joy" concat include ]
[ [ verbose ]
[ putchars " is already loaded\n" putchars ]
Expand Down
Loading

0 comments on commit dc60166

Please sign in to comment.