Skip to content

Commit

Permalink
"nothing" removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodan58 committed Jul 8, 2018
1 parent 48da4c2 commit dc9fbf7
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 96 deletions.
6 changes: 2 additions & 4 deletions builtin.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
module : builtin.c
version : 1.1
date : 07/05/18
version : 1.2
date : 07/08/18
*/
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -232,8 +232,6 @@ void print_node(node_t cur)
;
else if (abs(cur) >= 0 && abs(cur) < start_of_prog)
printf("%d ", cur);
else if (cur == start_of_text)
printf("nothing ");
else if (cur > start_of_text && cur < start_of_data) {
if ((ptr = procname((proc_t)cur)) == 0)
printf("%p ", cur);
Expand Down
1 change: 0 additions & 1 deletion builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ void do_neg(void);
void do_neql(void);
void do_not(void);
void do_not_set(void);
void do_nothing(void);
void do_null(void);
void do_null_lst(void);
void do_null_str(void);
Expand Down
5 changes: 2 additions & 3 deletions interp.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
module : interp.c
version : 1.10
date : 07/02/18
version : 1.11
date : 07/08/18
*/
#include "runtime.h"
#include "runtime.c"
Expand Down Expand Up @@ -42,7 +42,6 @@ void interprete(Node *node)
case ANON_FUNCT_:
(*node->u.proc)();
break;
case NOTHING_:
case BOOLEAN_:
case CHAR_:
case INTEGER_:
Expand Down
5 changes: 2 additions & 3 deletions parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ extern int yydebug;
JPUBLIC = 260,
JEQUAL = 261,
END = 262,
NOTHING_ = 1,
USR_ = 2,
ANON_FUNCT_ = 3,
BOOLEAN_ = 4,
Expand All @@ -70,7 +69,7 @@ extern int yydebug;

union YYSTYPE
{
#line 32 "parse.y" /* yacc.c:1909 */
#line 31 "parse.y" /* yacc.c:1909 */

long_t num;
ulong_t set;
Expand All @@ -81,7 +80,7 @@ union YYSTYPE
void (*proc)(void);
void *ptr;

#line 85 "parse.h" /* yacc.c:1909 */
#line 84 "parse.h" /* yacc.c:1909 */
};

typedef union YYSTYPE YYSTYPE;
Expand Down
5 changes: 2 additions & 3 deletions parse.y
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
%{
/*
module : parse.y
version : 1.22
date : 07/02/18
version : 1.23
date : 07/08/18
*/
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -12,7 +12,6 @@

%token MODULE JPRIVATE JPUBLIC JEQUAL END

%token <num> NOTHING_ 1
%token <num> USR_ 2
%token <proc> ANON_FUNCT_ 3
%token <num> BOOLEAN_ 4
Expand Down
1 change: 0 additions & 1 deletion prims.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@
#include "src/neql.c"
#include "src/not.c"
#include "src/not_set.c"
#include "src/nothing.c"
#include "src/null.c"
#include "src/null_str.c"
#include "src/nullary.c"
Expand Down
7 changes: 2 additions & 5 deletions print.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
module : print.c
version : 1.21
date : 07/02/18
version : 1.22
date : 07/08/18
*/
#include <stdio.h>
#include <string.h>
Expand All @@ -17,9 +17,6 @@ void writefactor(Node *node, FILE *stm)
unsigned i, j;

switch (node->op) {
case NOTHING_:
fprintf(stm, "nothing");
break;
case USR_:
fprintf(stm, "%s", dict_descr(node->u.num));
break;
Expand Down
1 change: 0 additions & 1 deletion runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@
#include "src/neql.c"
#include "src/not.c"
#include "src/not_set.c"
#include "src/nothing.c"
#include "src/null.c"
#include "src/null_lst.c"
#include "src/null_str.c"
Expand Down
33 changes: 15 additions & 18 deletions src/stop.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
module : stop.c
version : 1.5
date : 07/05/18
version : 1.6
date : 07/08/18
*/
#ifdef RUNTIME
void do_stop(void)
Expand All @@ -15,25 +15,22 @@ void do_stop(void)
#else
PRIVATE void do_stop(void)
{
int written = 0;

#ifndef NCHECK
COMPILE;
#endif
if (!stk) {
freemem();
return;
}
if (autoput == 2) {
writeterm(stk, stdout);
written = 1;
} else if (autoput == 1) {
do_put();
written = 1;
}
if (written) {
putchar('\n');
fflush(stdout);
if (stk) {
switch (autoput) {
case 0:
break;
case 1:
do_put();
break;
case 2:
writeterm(stk, stdout);
break;
}
if (autoput)
putchar('\n');
}
if (!stk)
freemem();
Expand Down
37 changes: 12 additions & 25 deletions src/uncons.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
/*
module : uncons.c
version : 1.11
date : 07/06/18
version : 1.12
date : 07/08/18
*/
#ifdef RUNTIME
void do_uncons(void)
{
code_t *cur;

TRACE;
if ((cur = (code_t *)stk[-1]) == 0) {
stk[-1] = start_of_text;
do_push(0);
} else {
stk[-1] = cur->num;
do_push((node_t)cur->next);
}
cur = (code_t *)stk[-1];
stk[-1] = cur->num;
do_push((node_t)cur->next);
}
#else
/**
Expand All @@ -39,23 +35,14 @@ PRIVATE void do_uncons(void)
ONEPARAM("uncons");
switch (stk->op) {
case LIST_:
#if 0
CHECKEMPTYLIST(stk->u.lis, "uncons");
#endif
if ((save = stk->u.lis) == 0) {
if (OUTSIDE)
stk->u.num = stk->op = NOTHING_;
else
GUNARY(NOTHING_, (void *)NOTHING_);
PUSH(LIST_, 0);
} else {
if (OUTSIDE) {
stk->op = stk->u.lis->op;
stk->u = stk->u.lis->u;
} else
GUNARY(stk->u.lis->op, stk->u.lis->u.ptr);
PUSH(LIST_, save->next);
}
save = stk->u.lis;
if (OUTSIDE) {
stk->op = stk->u.lis->op;
stk->u = stk->u.lis->u;
} else
GUNARY(stk->u.lis->op, stk->u.lis->u.ptr);
PUSH(LIST_, save->next);
break;
case STRING_:
str = stk->u.str;
Expand Down
34 changes: 11 additions & 23 deletions src/uncons_str.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
module : uncons_str.c
version : 1.1
date : 07/05/18
version : 1.2
date : 07/08/18
*/
#ifdef RUNTIME
void do_uncons_str(void)
Expand All @@ -10,10 +10,7 @@ void do_uncons_str(void)

TRACE;
str = (char *)stk[-1];
if (str)
stk[-1] = *str++;
else
stk[-1] = start_of_text;
stk[-1] = *str++;
do_push((node_t)str);
}
#else
Expand All @@ -29,7 +26,7 @@ PRIVATE void do_uncons_str(void)
ulong_t set;

#ifndef NCHECK
if (compiling && stk && ((stk->op == LIST_ && stk->u.lis->op >= NOTHING_ &&
if (compiling && stk && ((stk->op == LIST_ && stk->u.lis->op > USR_ &&
stk->u.lis->op <= SYMBOL_) || stk->op == STRING_ || stk->op == SET_))
;
else
Expand All @@ -38,23 +35,14 @@ PRIVATE void do_uncons_str(void)
ONEPARAM("uncons");
switch (stk->op) {
case LIST_:
#if 0
CHECKEMPTYLIST(stk->u.lis, "uncons");
#endif
if ((save = stk->u.lis) == 0) {
if (OUTSIDE)
stk->u.num = stk->op = NOTHING_;
else
GUNARY(NOTHING_, (void *)NOTHING_);
PUSH(LIST_, 0);
} else {
if (OUTSIDE) {
stk->op = stk->u.lis->op;
stk->u = stk->u.lis->u;
} else
GUNARY(stk->u.lis->op, stk->u.lis->u.ptr);
PUSH(LIST_, save->next);
}
save = stk->u.lis;
if (OUTSIDE) {
stk->op = stk->u.lis->op;
stk->u = stk->u.lis->u;
} else
GUNARY(stk->u.lis->op, stk->u.lis->u.ptr);
PUSH(LIST_, save->next);
break;
case STRING_:
str = stk->u.str;
Expand Down
1 change: 0 additions & 1 deletion table.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@
{ "neg", "I -> J", "Integer J is the negative of integer I. Also supports float.\n" },
{ "not", "X -> Y", "Y is the complement of set X, logical negation for truth values.\n" },
{ "not_set", "X -> Y", "Y is the complement of set X, logical negation for truth values.\n" },
{ "nothing", "-> nothing", "Pushes the value nothing.\n" },
{ "null", "X -> B", "Tests for empty aggregate X or zero numeric.\n" },
{ "null_lst", "X -> B", "Tests for empty aggregate X or zero numeric.\n" },
{ "null_str", "X -> B", "Tests for empty aggregate X or zero numeric.\n" },
Expand Down
10 changes: 3 additions & 7 deletions test/tutorial.joy
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ interpreter and seems to have no other purpose.
LIBRA
put_bool == [ [ "true" ] [ "false" ] ] index i put ;
nl == 10 putch ;
# > == swap < ;
reverse == [ ] swap shunt ;
step1 == [ dup ] dip1 swap [ ] = [ [ step2 ] [ pop pop ] ] index i ;
step2 == [ uncons ] dip1 dup [ swap ] dip1 [ i ] first1 rollup1 [ step1 ]
Expand All @@ -51,7 +50,6 @@ concat1 == [ reverse ] c shunt ;
dip1 == swap [ i ] first1 swap [ ] cons [ first1 ] cons cons cons i ;
c == [ swap ] dip1 i ;
last == dup rest1 null1 [ first1 ] [ rest1 last ] branch1 ;
# null1 == car nothing sametype ;
null1 == 0 = ;
car == uncons pop ;
first1 == uncons pop ;
Expand Down Expand Up @@ -87,11 +85,9 @@ x1 == dup i ;
y == fix i ;
fix == [ duco ] first1 swap cons duco ;
duco == dup cons ;
# <= == succ < ;
# succ == 1 + ;
factorial_rec == dup 2 < [ pop 1 ] [ dup pred1 factorial_rec * ] branch1 ;
rolldown1 == [ swap ] dip1 swap ;
small1 == uncons null1 swap pop ;
small1 == dup null1 [ [ uncons null1 ] [ true ] ] index i swap pop ;
quicksort == dup small1 [ ] [ partition quicksort [ quicksort ] dip1 concat1 ] branch1 ;
partition == [ [ ] [ ] ] dip1 dup [ first1 > [ cnos ] [ swap [ cnos ] dip1 ] branch1 ] cons [ dup ] first1 cnos step1 ;
quicksort1 == dup small1 [ ] [ partition1 quicksort1 [ quicksort1 ] dip1 concat1 ] branch1 ;
Expand Down Expand Up @@ -151,9 +147,9 @@ reverse length putnl .
[ Smith Jones Robinson ]
[ swap dup rest1 null1 [ car swap pop ] [ cdr swap i ] branch1 ] y .
6 factorial_rec .
6 [ swap dup 1 <= [ pop pop 1 ] [ dup pred1 rolldown1 x1 * ] branch1 ]
6 [ swap dup 2 < [ pop pop 1 ] [ dup pred1 rolldown1 x1 * ] branch1 ]
x1 .
6 [ swap dup 1 <= [ pop pop 1 ] [ dup pred1 rolldown1 i * ] branch1 ]
6 [ swap dup 2 < [ pop pop 1 ] [ dup pred1 rolldown1 i * ] branch1 ]
y .
[ 1 9 2 8 3 7 4 6 5 ] quicksort .
[ 5 6 4 7 3 8 2 9 1 ] quicksort .
Expand Down
1 change: 0 additions & 1 deletion trans.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
{ "neg", "neg", do_neg },
{ "not", "not", do_not },
{ "not_set", "not_set", do_not_set },
{ "nothing", "nothing", do_nothing },
{ "null", "null", do_null },
{ "null_lst", "null_lst", do_null_lst },
{ "null_str", "null_str", do_null_str },
Expand Down

0 comments on commit dc9fbf7

Please sign in to comment.