Skip to content

Commit

Permalink
Align with Joy
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodan58 committed Aug 26, 2023
1 parent 83b3118 commit 5905e32
Show file tree
Hide file tree
Showing 21 changed files with 285 additions and 293 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.11
# date : 08/23/23
# version : 1.12
# date : 08/24/23
#
cmake_minimum_required(VERSION 3.0)
project(Moy VERSION 1.0)
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions globals.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions parm.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
module : parm.c
date : 1.6
version : 08/23/23
module : %M%
date : %I%
version : %G%
*/
#include "globals.h"

Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions pars.y
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
%{
/*
module : pars.y
version : 1.6
date : 08/23/23
module : %M%
version : %I%
date : %G%
*/
#include "globals.h"
%}
Expand Down Expand Up @@ -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); } ;
Expand Down
6 changes: 3 additions & 3 deletions src/_treegenrec.c
Original file line number Diff line number Diff line change
@@ -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.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/_treerec.c
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/casting.c
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/filetime.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
module : filetime.c
version : 1.3
date : 08/23/23
version : 1.4
date : 08/26/23
*/
#ifndef FILETIME_C
#define FILETIME_C

#include <sys/stat.h>

/**
OK 3210 filetime : DA F -> T
OK 1943 filetime : DA F -> T
T is the modification time of file F.
*/
void filetime_(pEnv env)
Expand Down
6 changes: 3 additions & 3 deletions src/over.c
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/pick.c
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/round.c
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/typeof.c
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Loading

0 comments on commit 5905e32

Please sign in to comment.