jet +mino, allow one invalid branch in nock 6

- change the nock interpreter to bail [1 block] instead of [1 block ~]
- modify mink jet to rewrite this error ball to the old style
- add a mino jet that takes advantage of the new style

%hand hints aren't handled by the normal interpreter, so they
were disabled in the test generator.

there was a mismatch in the case of a nock 6 with one invalid branch
(either yes or no), which necessitated a little extra logic when
compiling nock 6. invalid nock is rare in the wild and there are no
tests for this (somewhat subtle) behavior. previously, either branch
invalid was (incorrectly) considered an invalid formula and would not
compile.
This commit is contained in:
Paul Driver 2019-12-01 15:25:08 -08:00 committed by Jared Tobin
parent 50aaa27ed1
commit a233fd5eb3
No known key found for this signature in database
GPG Key ID: 0E4647D58F8A69E4
5 changed files with 127 additions and 5 deletions

View File

@ -37,13 +37,13 @@
:~ [%spot 1]
[%lose 2]
[%mean 3]
[%hand 4]
:: [%hand 4]
[%hunk 5]
==
%+ mino
:- 0
:* 11 [%hunk 1 5]
11 [%hand 1 4]
:: 11 [%hand 1 4]
11 [%mean 1 3]
11 [%lose 1 2]
11 [%spot 1 1]

View File

@ -111,6 +111,7 @@
u3_noun u3we_loss(u3_noun);
u3_noun u3we_lune(u3_noun);
u3_noun u3we_mink(u3_noun);
u3_noun u3we_mino(u3_noun);
u3_noun u3we_mule(u3_noun);
u3_noun u3we_repg(u3_noun);
u3_noun u3we_rexp(u3_noun);

View File

@ -8,6 +8,38 @@
{
u3_noun bus, fol, gul;
if ( c3n == u3r_mean(cor, u3x_sam_4, &bus,
u3x_sam_5, &fol,
u3x_sam_3, &gul,
0) )
{
return u3m_bail(c3__exit);
}
else {
u3_noun som;
som = u3n_nock_et(u3k(gul), u3k(bus), u3k(fol));
c3_assert( c3y == u3du(som) );
if ( 1 == u3h(som) ) {
// legacy support: the interpreter now leaves the 0 off the end
// to match +tono. convert to +tone.
u3_noun mos = u3nt(1, u3k(u3t(som)), 0);
u3z(som);
return mos;
}
else {
return som;
}
}
}
u3_noun
u3we_mino(u3_noun cor)
{
u3_noun bus, fol, gul;
if ( c3n == u3r_mean(cor, u3x_sam_4, &bus,
u3x_sam_5, &fol,
u3x_sam_3, &gul,

View File

@ -849,6 +849,10 @@ static c3_c* _141_qua_mink_ha[] = {
"fd66c7ed46e5440ea759e6ace2341e6170aec48c79de27ffff3d179d1b5e491e",
0
};
static u3j_harm _141_qua_mino_a[] = {{".2", u3we_mino}, {}};
static c3_c* _141_qua_mino_ha[] = {
0
};
static u3j_harm _141_qua_mule_a[] = {{".2", u3we_mule}, {}};
static c3_c* _141_qua_mule_ha[] = {
"d54688d726565ddade7f2636741cad7209ea40fab28d3335555d8a02ff6001c4",
@ -882,6 +886,7 @@ static u3j_core _141_qua_d[] =
{ "sfix", 7, _141_qua_sfix_a, 0, _141_qua_sfix_ha },
{ "mink", 7, _141_qua_mink_a, 0, _141_qua_mink_ha },
{ "mino", 7, _141_qua_mino_a, 0, _141_qua_mino_ha },
{ "mule", 7, _141_qua_mule_a, 0, _141_qua_mule_ha },
{}
};

View File

@ -1100,6 +1100,68 @@ _n_bint(u3_noun* ops, u3_noun hif, u3_noun nef, c3_o los_o, c3_o tel_o)
}
}
static c3_t
_n_formulaic(u3_noun fol)
{
u3_noun op, ar, a, b, c;
if ( c3n == u3r_cell(fol, &op, &ar) ) {
return 0;
}
if ( c3y == u3du(op) ) {
return _n_formulaic(op) && _n_formulaic(ar);
}
else switch ( op ) {
case 0:
return ( c3y == u3ud(ar) );
case 1:
return 1;
case 3:
case 4:
return _n_formulaic(ar);
case 2:
case 5:
case 7:
case 8:
case 12:
return (c3y == u3r_cell(ar, &a, &b))
&& _n_formulaic(a) && _n_formulaic(b);
case 6:
return ( c3y == u3r_trel(ar, &a, &b, &c) )
&& _n_formulaic(a) &&
(_n_formulaic(b) || _n_formulaic(c));
case 9:
return (c3y == u3r_cell(ar, &a, &b))
&& (c3y == u3ud(a))
&& _n_formulaic(b);
case 10:
if ( c3n == u3r_cell(ar, &a, &b) ) {
return 0;
}
if ( c3n == u3du(a) ) {
return 0;
}
if ( c3n == u3ud(u3h(a)) ) {
return 0;
}
return _n_formulaic(u3t(a)) && _n_formulaic(b);
case 11:
if ( c3n == u3r_cell(ar, &a, &b) ) {
return 0;
}
if ( !_n_formulaic(b) ) {
return 0;
}
if ( c3y == u3ud(a) ) {
return 1;
}
else {
return ( c3y == u3ud(u3h(a)) ) && _n_formulaic(u3t(a));
}
default:
return 0;
}
}
/* _n_comp(): compile nock formula to reversed opcode list
* ops is a pointer to a list (to be emitted to)
* fol is the nock formula to compile. RETAIN.
@ -1246,10 +1308,32 @@ _n_comp(u3_noun* ops, u3_noun fol, c3_o los_o, c3_o tel_o)
yep = u3_nul,
nop = u3_nul;
c3_w yep_w, nop_w;
c3_t yep_t, nop_t;
u3x_trel(arg, &hed, &mid, &tel);
tot_w += _n_comp(ops, hed, c3n, c3n);
yep_t = _n_formulaic(mid);
nop_t = _n_formulaic(tel);
if ( !yep_t && !nop_t ) {
u3m_bail(c3__exit);
break;
}
if ( yep_t ) {
yep_w = _n_comp(&yep, mid, los_o, tel_o);
}
else {
++yep_w; _n_emit(&yep, BAIL);
}
if ( nop_t ) {
nop_w = _n_comp(&nop, tel, los_o, tel_o);
}
else {
++nop_w; _n_emit(&nop, BAIL);
}
// SBIP and SBIN get sized during assembly
++yep_w; _n_emit(&yep, u3nc(SBIP, nop_w));
++tot_w; _n_emit(ops, u3nc(SBIN, yep_w));
@ -2086,7 +2170,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off)
u3t_on(noc_o);
if ( c3n == u3du(x) ) {
u3m_bail(u3nt(1, o, 0));
u3m_bail(u3nc(1, o));
return u3_none;
}
else if ( c3n == u3du(u3t(x)) ) {