shrub/jets/f/ap.c

1054 lines
23 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/ap.c
**
*/
#include "all.h"
2014-09-04 07:10:43 +04:00
2013-09-29 00:21:18 +04:00
/** forward declares
**/
2014-11-06 22:13:57 +03:00
u3_noun u3wfp_rake(u3_noun);
u3_noun u3wfp_open(u3_noun);
u3_noun u3wfp_hack(u3_noun);
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
static u3_noun
_ap_open_l(u3_noun, u3_noun);
2013-09-29 00:21:18 +04:00
// make sure these match the array below!
//
# define _ap_jet_open 0
# define _ap_jet_rake 1
# define _ap_jet_hack 2
2018-01-16 05:24:11 +03:00
#if 0
2014-09-06 00:13:24 +04:00
static u3_noun
_open_in(u3_noun ter, u3_noun gen);
2015-12-12 07:48:54 +03:00
/* ~(. al gen)
*/
static u3_noun
_al_bore(u3_noun ter,
u3_noun gen)
{
u3_noun gat = u3j_hook(u3k(ter), "al");
return u3i_molt(gat, u3x_sam, u3nc(c3__herb, u3k(gen)), 0);
}
2014-09-02 04:10:04 +04:00
/* ~(. al gen)
*/
2014-09-06 00:13:24 +04:00
static u3_noun
2015-08-28 19:34:36 +03:00
_al_core(u3_noun ter,
u3_noun gen)
2014-06-17 22:04:27 +04:00
{
2014-11-06 03:20:01 +03:00
u3_noun gat = u3j_hook(u3k(ter), "al");
2014-09-04 01:33:18 +04:00
2014-11-18 00:56:51 +03:00
return u3i_molt(gat, u3x_sam, u3k(gen), 0);
2014-06-17 22:04:27 +04:00
}
2014-10-10 05:27:02 +04:00
/* van is transferred, gen is retained
*/
static u3_noun
2015-08-28 19:34:36 +03:00
_ap_bunt(u3_noun van,
u3_noun gen)
2014-10-10 05:27:02 +04:00
{
2014-11-06 22:13:57 +03:00
u3_noun pro = u3qfl_bunt(van, gen);
2014-10-10 05:27:02 +04:00
u3z(van);
return pro;
}
2013-09-29 00:21:18 +04:00
/** open cases
**/
#define _open_do_p(stem) \
2014-09-06 00:13:24 +04:00
static u3_noun _open_in_##stem \
( u3_noun ter, u3_noun p_gen)
2013-09-29 00:21:18 +04:00
#define _open_do_pq(stem) \
2014-09-06 00:13:24 +04:00
static u3_noun _open_in_##stem \
( u3_noun ter, u3_noun p_gen, u3_noun q_gen)
2013-09-29 00:21:18 +04:00
#define _open_do_pqr(stem) \
2014-09-06 00:13:24 +04:00
static u3_noun _open_in_##stem \
( u3_noun ter, u3_noun p_gen, u3_noun q_gen, u3_noun r_gen)
2013-09-29 00:21:18 +04:00
#define _open_do_pqrs(stem) \
2014-09-06 00:13:24 +04:00
static u3_noun _open_in_##stem \
( u3_noun ter, u3_noun p_gen, u3_noun q_gen, u3_noun r_gen, \
u3_noun s_gen)
2013-09-29 00:21:18 +04:00
/***
****
***/
2014-06-17 22:04:27 +04:00
_open_do_pq(tsbr) // =:
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__tsls,
_ap_bunt(_al_core(ter, p_gen), p_gen),
u3k(q_gen));
2014-06-17 22:04:27 +04:00
}
_open_do_pq(tscl) // =:
{
2014-09-06 00:13:24 +04:00
return u3nt(c3__tsgr,
u3nt(c3__cncb,
2015-08-28 19:34:36 +03:00
u3nc(u3nc(u3_nul, 1),
u3_nul),
u3k(p_gen)),
u3k(q_gen));
}
_open_do_pqr(tsdt) // =.
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__tsgr,
u3nt(c3__cncb,
u3nc(u3nc(u3_nul, 1),
u3_nul),
u3nc(u3nc(u3k(p_gen),
u3k(q_gen)),
u3_nul)),
u3k(r_gen));
}
2013-09-29 00:21:18 +04:00
_open_do_pq(tsgl) // =<
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__tsgr,
u3k(q_gen),
u3k(p_gen));
2013-09-29 00:21:18 +04:00
}
_open_do_pq(tshp) // =-
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__tsls,
u3k(q_gen),
u3k(p_gen));
2013-09-29 00:21:18 +04:00
}
_open_do_pq(tsls) // =+
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__tsgr,
u3nc(u3k(p_gen),
u3nc(u3_nul, 1)),
u3k(q_gen));
2013-09-29 00:21:18 +04:00
}
2014-06-19 00:09:04 +04:00
_open_do_p(tssg) // =~
{
2014-11-05 04:18:47 +03:00
if ( !_(u3du(p_gen)) ) {
2014-11-04 23:20:44 +03:00
return u3nc(0, 1);
} else {
u3_noun tp_gen = u3t(p_gen);
u3_noun ip_gen = u3h(p_gen);
if ( (u3_nul == p_gen) ) {
return u3nc(u3_blip, 1);
}
else if ( (u3_nul == tp_gen) ) {
return u3k(ip_gen);
}
else {
return u3nt(c3__tsgr,
2015-08-28 19:34:36 +03:00
u3k(ip_gen),
_open_in_tssg(ter, tp_gen));
2014-11-04 23:20:44 +03:00
}
2014-06-19 00:09:04 +04:00
}
}
2013-09-29 00:21:18 +04:00
/***
****
***/
2014-06-17 22:04:27 +04:00
_open_do_p(bccb) // $_
{
2014-10-10 05:27:02 +04:00
return _ap_bunt(_al_core(ter, p_gen), p_gen);
2014-06-17 22:04:27 +04:00
}
_open_do_p(bctr) // $*
{
return
2014-09-06 00:13:24 +04:00
u3nc(c3__ktsg,
2015-08-28 19:34:36 +03:00
_ap_bunt(_al_core(ter, p_gen),
p_gen));
2014-06-17 22:04:27 +04:00
}
_open_do_p(bczp) // $!
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__bccb,
c3__axil,
u3k(p_gen));
}
/***
****
2013-09-29 00:21:18 +04:00
***/
_open_do_p(brhp) // |-
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__tsgl,
u3nc(c3__cnzy, u3_blip),
u3nc(c3__brdt, u3k(p_gen)));
2013-09-29 00:21:18 +04:00
}
_open_do_p(brdt) // |.
{
2015-08-28 19:34:36 +03:00
return u3nc(c3__brcn,
u3nt(u3nt(u3_blip, c3__ash, u3k(p_gen)),
u3_nul,
u3_nul));
2013-09-29 00:21:18 +04:00
}
2014-06-11 01:31:16 +04:00
2013-09-29 00:21:18 +04:00
/***
****
***/
_open_do_p(wtbr) // ?|
{
2014-09-06 00:13:24 +04:00
if ( (u3_nul == p_gen) ) {
2014-11-05 04:18:47 +03:00
return u3nt(c3__dtzz, 'f', c3n);
2013-09-29 00:21:18 +04:00
}
else {
2014-09-06 00:13:24 +04:00
u3_noun ip_gen = u3h(p_gen);
u3_noun tp_gen = u3t(p_gen);
2014-08-21 01:18:34 +04:00
2015-08-28 19:34:36 +03:00
return u3nq(c3__wtcl,
u3k(ip_gen),
u3nt(c3__dtzz, 'f', c3y),
_open_in_wtbr(ter, tp_gen));
2013-09-29 00:21:18 +04:00
}
}
2014-06-11 04:51:43 +04:00
_open_do_pqr(wtkt) // ?^
{
2015-08-28 19:34:36 +03:00
return u3nq(c3__wtcl,
u3nt(c3__wtts,
u3nt(c3__axil, c3__atom, u3_blip),
u3k(p_gen)),
u3k(r_gen),
u3k(q_gen));
2014-06-11 04:51:43 +04:00
}
2013-09-29 00:21:18 +04:00
_open_do_pq(wtgl) // ?<
{
2015-08-28 19:34:36 +03:00
return u3nq(c3__wtcl,
u3k(p_gen),
u3nc(c3__zpzp, u3_nul),
u3k(q_gen));
2013-09-29 00:21:18 +04:00
}
_open_do_pqr(wtdt) // ?.
{
2014-09-06 00:13:24 +04:00
return u3nq(c3__wtcl,
2015-08-28 19:34:36 +03:00
u3k(p_gen),
u3k(r_gen),
u3k(q_gen));
2013-09-29 00:21:18 +04:00
}
_open_do_pq(wtgr) // ?>
{
2015-08-28 19:34:36 +03:00
return u3nq(c3__wtcl,
u3k(p_gen),
u3k(q_gen),
u3nc(c3__zpzp, u3_nul));
2013-09-29 00:21:18 +04:00
}
2014-06-16 23:19:33 +04:00
_open_do_pq(wthp) // ?-
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
if ( (u3_nul == q_gen) ) {
return u3nc(c3__zpfs,
2015-08-28 19:34:36 +03:00
u3nc(c3__cnzz,
u3k(p_gen)));
2013-09-29 00:21:18 +04:00
}
else {
2014-09-06 00:13:24 +04:00
u3_noun iq_gen = u3h(q_gen);
u3_noun tq_gen = u3t(q_gen);
u3_noun piq_gen = u3h(iq_gen);
u3_noun qiq_gen = u3t(iq_gen);
2013-09-29 00:21:18 +04:00
2015-08-28 19:34:36 +03:00
return u3nq(c3__wtcl,
u3nt(c3__wtts,
u3k(piq_gen),
u3k(p_gen)),
u3k(qiq_gen),
_open_in_wthp(ter, p_gen, tq_gen));
2013-09-29 00:21:18 +04:00
}
}
_open_do_p(wtpm) // ?&
{
2014-09-06 00:13:24 +04:00
if ( (u3_nul == p_gen) ) {
2014-11-05 04:18:47 +03:00
return u3nt(c3__dtzz, 'f', c3y);
2013-09-29 00:21:18 +04:00
}
else {
2014-09-06 00:13:24 +04:00
u3_noun ip_gen = u3h(p_gen);
u3_noun tp_gen = u3t(p_gen);
2014-08-21 01:18:34 +04:00
2015-08-28 19:34:36 +03:00
return u3nq(c3__wtcl,
u3k(ip_gen),
_open_in_wtpm(ter, tp_gen),
u3nt(c3__dtzz, 'f', c3n));
2013-09-29 00:21:18 +04:00
}
}
_open_do_pqr(wtls) // ?+
2015-08-28 19:34:36 +03:00
{ u3_noun tul = u3nc(u3nc(u3nc(c3__axil, c3__noun),
u3k(q_gen)),
u3_nul);
2014-11-06 22:13:57 +03:00
u3_noun zal = u3qb_weld(r_gen, tul);
2014-09-06 00:13:24 +04:00
u3_noun ret = u3nt(c3__wthp, u3k(p_gen), zal);
u3z(tul);
2013-09-29 00:21:18 +04:00
return ret;
2014-06-14 00:52:13 +04:00
}
_open_do_pqr(wtpt) // ?@
{
2014-09-06 00:13:24 +04:00
return u3nq(c3__wtcl,
2015-08-28 19:34:36 +03:00
u3nt(c3__wtts,
u3nt(c3__axil,
c3__atom,
u3_blip),
u3k(p_gen)),
2014-09-06 00:13:24 +04:00
u3k(q_gen),
2015-08-28 19:34:36 +03:00
u3k(r_gen));
2014-06-14 00:52:13 +04:00
}
_open_do_pqr(wtsg) // ?~
{
2014-09-06 00:13:24 +04:00
return u3nq(c3__wtcl,
2015-08-28 19:34:36 +03:00
u3nt(c3__wtts,
u3nc(c3__axil, c3__null),
u3k(p_gen)),
u3k(q_gen),
u3k(r_gen));
2013-09-29 00:21:18 +04:00
}
_open_do_p(wtzp) // ?!
{
2015-08-28 19:34:36 +03:00
return u3nq(c3__wtcl,
u3k(p_gen),
u3nt(c3__dtzz, 'f', c3n),
u3nt(c3__dtzz, 'f', c3y));
2013-09-29 00:21:18 +04:00
}
/***
****
2014-06-13 02:22:25 +04:00
***/
2014-06-18 21:38:34 +04:00
_open_do_pq(zpcb) // !_
{
2014-09-06 00:13:24 +04:00
return u3k(q_gen);
2014-06-18 21:38:34 +04:00
}
2014-06-13 02:22:25 +04:00
_open_do_p(zpgr) // !>
{
2015-08-28 19:34:36 +03:00
return u3nq(c3__cnhp,
u3nc(c3__cnzy, c3__onan),
u3nt(c3__zpsm,
u3nc(c3__bctr,
u3nc(c3__herb,
u3nc(c3__cnzy,
c3__abel))),
u3k(p_gen)),
u3_nul);
2014-06-13 02:22:25 +04:00
}
/***
****
2013-09-29 00:21:18 +04:00
***/
2014-06-05 06:46:12 +04:00
_open_do_pq(clhp) // :-
{
2015-08-28 19:34:36 +03:00
return u3nc(u3k(p_gen),
u3k(q_gen));
2014-06-05 06:46:12 +04:00
}
_open_do_pq(clcb) // :_
{
2015-08-28 19:34:36 +03:00
return u3nc(u3k(q_gen),
u3k(p_gen));
2014-06-05 06:46:12 +04:00
}
2014-06-13 02:22:25 +04:00
_open_do_p(clcn) // :%
{
2015-08-28 19:34:36 +03:00
return u3nc(u3nc(c3__clsg,
u3k(p_gen)),
u3nc(c3__bczp, c3__null));
2014-06-13 02:22:25 +04:00
}
2013-09-29 00:21:18 +04:00
_open_do_pqrs(clkt) // :^
{
2015-08-28 19:34:36 +03:00
return u3nq(u3k(p_gen),
u3k(q_gen),
u3k(r_gen),
u3k(s_gen));
2013-09-29 00:21:18 +04:00
}
_open_do_pqr(clls) // :+
{
2015-08-28 19:34:36 +03:00
return u3nt(u3k(p_gen),
u3k(q_gen),
u3k(r_gen));
2013-09-29 00:21:18 +04:00
}
_open_do_p(clsg) // :~
{
2014-09-06 00:13:24 +04:00
if ( (u3_nul == p_gen) ) {
return u3nt(c3__dtzz, 'n', u3_nul);
2013-09-29 00:21:18 +04:00
}
else {
2014-09-06 00:13:24 +04:00
u3_noun ip_gen = u3h(p_gen);
u3_noun tp_gen = u3t(p_gen);
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
return u3nc(u3k(ip_gen),
2014-08-21 01:18:34 +04:00
_open_in_clsg(ter, tp_gen));
2013-09-29 00:21:18 +04:00
}
}
_open_do_p(cltr) // :*
{
2014-09-06 00:13:24 +04:00
if ( (u3_nul == p_gen) ) {
return u3nc(c3__zpzp, u3_nul);
2013-09-29 00:21:18 +04:00
}
else {
2014-09-06 00:13:24 +04:00
u3_noun ip_gen = u3h(p_gen);
u3_noun tp_gen = u3t(p_gen);
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
if ( (u3_nul == tp_gen) ) {
return u3k(ip_gen);
2013-09-29 00:21:18 +04:00
} else {
2015-08-28 19:34:36 +03:00
return u3nc(u3k(ip_gen),
_open_in_cltr(ter, tp_gen));
2013-09-29 00:21:18 +04:00
}
}
}
/***
****
***/
_open_do_pq(cncb) // %_
{
2015-08-28 19:34:36 +03:00
return u3nc(c3__ktls,
u3nq(u3nc(c3__cnzz, u3k(p_gen)),
c3__cnts,
u3k(p_gen),
u3k(q_gen)));
}
2015-03-07 04:15:51 +03:00
#if 0
2013-09-29 00:21:18 +04:00
_open_do_pq(cncl) // %:
{
2014-09-06 00:13:24 +04:00
return u3nq
2014-08-21 01:18:34 +04:00
(c3__cnsg,
2014-09-06 00:13:24 +04:00
u3nc(u3_blip, u3_nul),
u3k(p_gen),
u3k(q_gen));
2013-09-29 00:21:18 +04:00
}
2015-03-07 04:15:51 +03:00
#endif
2013-09-29 00:21:18 +04:00
_open_do_pq(cndt) // %.
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__cnhp,
u3k(q_gen),
u3nc(u3k(p_gen), u3_nul));
2013-09-29 00:21:18 +04:00
}
_open_do_pqrs(cnkt) // %^
{
2015-08-28 19:34:36 +03:00
return u3nq(c3__cnhp,
u3k(p_gen),
u3k(q_gen),
u3nt(u3k(r_gen),
u3k(s_gen),
u3_nul));
2013-09-29 00:21:18 +04:00
}
_open_do_pq(cnhp) // %-
{
2014-09-06 00:13:24 +04:00
if ( (u3_nul == q_gen) ) {
2015-08-28 19:34:36 +03:00
return u3nt(c3__tsgr,
u3k(p_gen),
u3nc(c3__cnzy, u3_blip));
2013-09-29 00:21:18 +04:00
} else {
2014-09-06 00:13:24 +04:00
return u3nq(c3__cncl,
2015-08-28 19:34:36 +03:00
u3k(p_gen),
c3__cltr,
u3k(q_gen));
2013-09-29 00:21:18 +04:00
}
}
_open_do_pqr(cnls) // %+
{
2015-08-28 19:34:36 +03:00
return u3nc(c3__cnhp,
u3nq(u3k(p_gen),
u3k(q_gen),
u3k(r_gen),
u3_nul));
2013-09-29 00:21:18 +04:00
}
_open_do_pqr(cnsg) // %~
{
2015-08-28 19:34:36 +03:00
return u3nq(c3__cntr,
u3k(p_gen),
u3k(q_gen),
u3nc(u3nc(u3nc(u3nc(u3_nul, 6), 0), u3k(r_gen)), 0));
2013-09-29 00:21:18 +04:00
}
_open_do_p(cnzy) // %cnzy
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__cnts,
u3nc(u3k(p_gen), u3_nul),
u3_nul);
}
_open_do_p(cnzz) // %cnzz
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__cnts, u3k(p_gen), u3_nul);
}
2014-06-12 02:29:17 +04:00
/***
****
***/
_open_do_p(hxgl) // #<
{
2015-08-28 19:34:36 +03:00
return u3nq(c3__cnhp,
u3nc(c3__cnzy, c3__noah),
u3nc(c3__zpgr,
u3nc(c3__cltr, u3k(p_gen))),
u3_nul);
2014-06-12 02:29:17 +04:00
}
_open_do_p(hxgr) // #>
{
2015-08-28 19:34:36 +03:00
return u3nq(c3__cnhp,
u3nc(c3__cnzy, c3__cain),
u3nc(c3__zpgr,
u3nc(c3__cltr, u3k(p_gen))),
u3_nul);
2014-06-12 02:29:17 +04:00
}
/***
****
***/
_open_do_pq(ktdt) // ^.
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__ktls,
u3nq(c3__cnhp, u3k(p_gen), u3k(q_gen), u3_nul),
u3k(q_gen));
2014-06-12 02:29:17 +04:00
}
2015-12-12 07:48:54 +03:00
#if 0
2014-06-17 22:04:27 +04:00
_open_do_pq(kthp) // ^-
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__ktls,
2015-12-12 07:48:54 +03:00
_ap_bunt(_al_bore(ter, p_gen), p_gen),
2015-08-28 19:34:36 +03:00
u3k(q_gen));
2014-06-17 22:04:27 +04:00
}
2015-12-12 07:48:54 +03:00
#endif
2013-09-29 00:21:18 +04:00
/***
****
***/
2014-06-11 01:31:16 +04:00
_open_do_pq(brcb) // |_
{
2014-09-06 00:13:24 +04:00
return u3nt(c3__tsls,
u3nc(c3__bctr, u3k(p_gen)),
u3nc(c3__brcn, u3k(q_gen)));
2014-06-11 01:31:16 +04:00
}
_open_do_pq(brkt) // |^
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun diz = u3nc(c3__ash, u3k(p_gen));
2015-08-28 19:34:36 +03:00
u3_noun ret = u3nt(c3__tsgr,
u3nc(c3__brcn,
u3qdb_put(q_gen, u3_blip, diz)),
u3nc(c3__cnzy, u3_blip));
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
u3z(diz);
2013-09-29 00:21:18 +04:00
return ret;
}
_open_do_pq(brls) // |+
{
2014-09-06 00:13:24 +04:00
return u3nc(c3__ktbr,
2015-08-28 19:34:36 +03:00
u3nt(c3__brts,
u3k(p_gen),
u3k(q_gen)));
}
2014-06-13 02:22:25 +04:00
_open_do_p(brwt) // |?
{
2014-09-06 00:13:24 +04:00
return u3nt(c3__ktwt,
2015-08-28 19:34:36 +03:00
c3__brdt,
u3k(p_gen));
2014-06-13 02:22:25 +04:00
}
2013-09-29 00:21:18 +04:00
/***
****
***/
_open_do_pq(sgts) // ~=
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__sggr,
u3nc(c3__germ, u3k(p_gen)),
u3k(q_gen));
2013-09-29 00:21:18 +04:00
}
2015-01-22 06:31:17 +03:00
#if 0
2013-09-29 00:21:18 +04:00
_open_do_pq(sgbr) // ~|
{
2014-09-06 00:13:24 +04:00
return u3nt
2014-08-21 01:18:34 +04:00
(c3__sggr,
u3nc(c3__mean, u3k(p_gen)),
2014-09-06 00:13:24 +04:00
u3k(q_gen));
2013-09-29 00:21:18 +04:00
}
2015-01-22 06:31:17 +03:00
#endif
2013-09-29 00:21:18 +04:00
_open_do_pq(sggl) // ~>
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__tsgl,
u3nq(c3__sggr, u3k(p_gen), u3_nul, 1),
u3k(q_gen));
2013-09-29 00:21:18 +04:00
}
_open_do_pq(sgbc) // ~$
{
2014-09-06 00:13:24 +04:00
return u3nt(c3__sggr,
2015-08-28 19:34:36 +03:00
u3nq(c3__live,
c3__dtzz,
u3_blip,
u3k(p_gen)),
u3k(q_gen));
2014-06-12 02:29:17 +04:00
}
_open_do_pq(sgcb) // ~_
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__sggr,
u3nc(c3__mean,
u3nc(c3__brdt,
u3k(p_gen))),
u3k(q_gen));
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
static u3_noun
2015-08-28 19:34:36 +03:00
_sgcn_a(u3_noun r_gen,
2014-09-06 00:13:24 +04:00
u3_noun nob)
2013-09-29 00:21:18 +04:00
{
2014-11-05 04:18:47 +03:00
if ( c3n == u3du(r_gen) ) {
2014-09-06 00:13:24 +04:00
return u3k(nob);
2013-09-29 00:21:18 +04:00
} else {
2014-09-06 00:13:24 +04:00
u3_noun ir_gen = u3h(r_gen);
u3_noun tr_gen = u3t(r_gen);
u3_noun pir_gen, qir_gen;
2013-09-29 00:21:18 +04:00
2014-11-06 03:20:01 +03:00
u3x_cell(ir_gen, &pir_gen, &qir_gen);
2015-08-28 19:34:36 +03:00
return u3nc(u3nc(u3nt(c3__dtzz, u3_blip, u3k(pir_gen)),
u3nc(c3__zpts, u3k(qir_gen))),
_sgcn_a(tr_gen, nob));
2013-09-29 00:21:18 +04:00
}
}
_open_do_pqrs(sgcn) // ~%
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__sggl,
2017-09-28 03:40:12 +03:00
u3nq(c3__sgcn,
2015-08-28 19:34:36 +03:00
c3__clls,
u3nt(c3__dtzz, u3_blip, u3k(p_gen)),
u3nt(u3nc(c3__zpts, u3k(q_gen)),
c3__clsg,
_sgcn_a(r_gen, u3_nul))),
u3k(s_gen));
2013-09-29 00:21:18 +04:00
}
2014-06-12 02:29:17 +04:00
_open_do_pq(sgfs) // ~/
{
2015-08-28 19:34:36 +03:00
return u3nc(c3__sgcn,
u3nq(u3k(p_gen),
u3nc(u3_nul, 7),
u3_nul,
u3k(q_gen)));
2014-06-12 02:29:17 +04:00
}
2013-09-29 00:21:18 +04:00
_open_do_pq(sgls) // ~+
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__sggr,
2017-09-28 03:40:12 +03:00
u3nq(c3__sgls, c3__dtzz, u3_blip, u3k(p_gen)),
2015-08-28 19:34:36 +03:00
u3k(q_gen));
2013-09-29 00:21:18 +04:00
}
2014-06-18 21:38:34 +04:00
_open_do_pqr(sgpm) // ~&
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__sggr,
u3nt(c3__slog,
u3nt(c3__dtzy, u3_blip, u3k(p_gen)),
u3nq(c3__cnhp, u3nc(c3__cnzy, c3__cain),
u3nc(c3__zpgr, u3k(q_gen)), u3_nul)),
u3k(r_gen));
2014-06-18 21:38:34 +04:00
}
2014-06-14 00:52:13 +04:00
_open_do_pqrs(sgwt) // ~?
{
2015-08-28 19:34:36 +03:00
return u3nt(c3__tsls,
u3nq(c3__wtdt,
u3k(q_gen),
u3nc(c3__bczp, c3__null),
u3nc(u3nc(c3__bczp, c3__null), u3k(r_gen))),
u3nq(c3__wtsg,
u3nc(u3nc(u3_nul, 2),u3_nul),
u3nt(c3__tsgr,
u3nc(u3_nul, 3),
u3k(s_gen)),
u3nq(c3__sgpm,
u3k(p_gen),
u3nc(u3_nul, 5),
u3nt(c3__tsgr,
u3nc(u3_nul, 3),
u3k(s_gen)))));
2014-06-14 00:52:13 +04:00
}
2013-09-29 00:21:18 +04:00
/***
****
***/
2014-09-06 00:13:24 +04:00
static u3_noun
2015-08-28 19:34:36 +03:00
_smcl_in(u3_noun q_gen)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun hq_gen = u3h(q_gen);
u3_noun tq_gen = u3t(q_gen);
2013-09-29 00:21:18 +04:00
2014-11-05 04:18:47 +03:00
if ( c3n == u3du(tq_gen) ) {
2014-09-06 00:13:24 +04:00
return u3nt(c3__tsgr,
2015-08-28 19:34:36 +03:00
u3nc(u3_nul, 3),
u3k(hq_gen));
2013-09-29 00:21:18 +04:00
} else {
2015-08-28 19:34:36 +03:00
return u3nc(c3__cnhp,
u3nq(u3nc(u3_nul, 2),
u3nt(c3__tsgr,
2014-09-06 00:13:24 +04:00
u3nc(u3_nul, 3),
u3k(hq_gen)),
2015-08-28 19:34:36 +03:00
_smcl_in(tq_gen),
u3_nul));
2013-09-29 00:21:18 +04:00
}
}
_open_do_pq(smcl)
{
2014-11-05 04:18:47 +03:00
if ( c3n == u3du(q_gen) ) {
2014-09-06 00:13:24 +04:00
return u3nc(c3__zpzp, u3_nul);
}
2014-09-06 00:13:24 +04:00
else if ( u3_nul == u3t(q_gen) ) {
return u3k(u3h(q_gen));
2013-09-29 00:21:18 +04:00
}
else {
2015-08-28 19:34:36 +03:00
return u3nt(c3__tsls,
u3k(p_gen),
_smcl_in(q_gen));
2013-09-29 00:21:18 +04:00
}
}
2014-06-19 00:09:04 +04:00
#if 0
_open_do_pq(smsm)
{
return
2014-09-06 00:13:24 +04:00
u3nt(c3__tsgr, u3nq(c3__ktts, c3__v, u3_nul, 1),
u3nt(c3__tsls,
u3nt(c3__ktts, c3__a,
u3nt(c3__tsgr, u3nc(c3__cnzy, c3__v),
2015-02-27 09:35:41 +03:00
u3k(p_gen))),
2014-09-06 00:13:24 +04:00
u3nt(c3__tsls,
u3nt(c3__ktts, c3__b,
u3nt(c3__tsgr,
u3nc(c3__cnzy, c3__v),
u3k(q_gen))),
u3nt(c3__tsls,
u3nt(c3__ktts, c3__c,
u3nq(c3__cnhp,
u3nc(c3__cnzy, c3__a),
u3nc(c3__cnzy, c3__b),
u3_nul)),
u3nt(c3__wtgr,
u3nt(c3__dtts,
u3nc(c3__cnzy, c3__c),
u3nc(c3__cnzy, c3__b)),
u3nc(c3__cnzy, c3__c))))));
2014-06-19 00:09:04 +04:00
}
#endif
2014-09-03 09:46:55 +04:00
2013-09-29 00:21:18 +04:00
/* functions
*/
/** open
**/
2014-09-06 00:13:24 +04:00
static u3_noun
2015-08-28 19:34:36 +03:00
_open_in(u3_noun ter,
2014-09-06 00:13:24 +04:00
u3_noun gen)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun p_gen, q_gen, r_gen, s_gen;
2013-09-29 00:21:18 +04:00
2015-12-13 03:35:35 +03:00
return u3_none;
2014-11-05 04:18:47 +03:00
if ( c3y == u3ud(gen) ) {
2013-09-29 00:21:18 +04:00
// printf("studly\n");
2014-09-06 00:13:24 +04:00
// u3_err("stud m", gen);
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__exit);
2013-09-29 00:21:18 +04:00
2015-08-28 19:34:36 +03:00
return u3nt(c3__cnts,
u3nc(u3k(gen), u3_nul),
u3_nul);
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
else switch ( u3h(gen) ) {
2014-11-06 02:36:30 +03:00
default: return u3_none;
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
case u3_nul: {
2015-08-28 19:34:36 +03:00
return u3nt(c3__cnts,
u3nc(u3k(gen), u3_nul),
u3_nul);
2013-09-29 00:21:18 +04:00
}
2013-09-29 00:21:18 +04:00
# define _open_p(stem) \
case c3__##stem: \
2014-09-06 00:13:24 +04:00
return _open_in_##stem(ter, u3t(gen)); \
2013-09-29 00:21:18 +04:00
# define _open_pq(stem) \
case c3__##stem: \
2014-11-06 03:20:01 +03:00
if ( c3n == u3r_cell(u3t(gen), &p_gen, &q_gen) ) { \
return u3m_bail(c3__fail); \
2014-08-21 01:18:34 +04:00
} else return _open_in_##stem(ter, p_gen, q_gen);
2013-09-29 00:21:18 +04:00
# define _open_pqr(stem) \
case c3__##stem: \
2014-11-06 03:20:01 +03:00
if ( c3n == u3r_trel(u3t(gen), &p_gen, &q_gen, &r_gen) ) { \
return u3m_bail(c3__fail); \
2014-08-21 01:18:34 +04:00
} else return _open_in_##stem(ter, p_gen, q_gen, r_gen);
2013-09-29 00:21:18 +04:00
# define _open_pqrs(stem) \
case c3__##stem: \
2014-11-06 03:20:01 +03:00
if ( c3n == u3r_qual\
2014-09-06 00:13:24 +04:00
(u3t(gen), &p_gen, &q_gen, &r_gen, &s_gen) )\
2013-09-29 00:21:18 +04:00
{ \
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__fail); \
2014-08-21 01:18:34 +04:00
} else return _open_in_##stem(ter, p_gen, q_gen, r_gen, s_gen);
2013-09-29 00:21:18 +04:00
2014-06-17 22:04:27 +04:00
_open_p (bccb);
_open_p (bctr);
_open_p (bczp);
2014-06-13 02:22:25 +04:00
2013-09-29 00:21:18 +04:00
_open_p (brdt);
2014-06-11 01:31:16 +04:00
_open_pq (brcb);
_open_p (brhp);
2014-06-11 01:31:16 +04:00
_open_pq (brkt);
_open_pq (brls);
2014-06-13 02:22:25 +04:00
_open_p (brwt);
2014-06-05 06:46:12 +04:00
_open_pq (clcb);
2014-06-13 02:22:25 +04:00
_open_p (clcn);
2014-06-05 06:46:12 +04:00
_open_pq (clhp);
2013-09-29 00:21:18 +04:00
_open_pqrs(clkt);
_open_pqr (clls);
2014-06-05 04:56:24 +04:00
_open_p (cltr);
_open_p (clsg);
_open_pq (cncb);
2015-03-07 04:15:51 +03:00
// _open_pq (cncl);
2013-09-29 00:21:18 +04:00
_open_pq (cndt);
_open_pqrs(cnkt);
_open_pq (cnhp);
_open_pqr (cnls);
2014-06-05 06:46:12 +04:00
_open_pqr (cnsg);
_open_p (cnzy);
_open_p (cnzz);
2014-06-12 02:29:17 +04:00
_open_p (hxgl);
_open_p (hxgr);
_open_pq (ktdt);
2015-12-12 08:01:41 +03:00
// _open_pq (kthp);
2014-06-12 02:29:17 +04:00
_open_pq (sgts);
2015-01-22 06:31:17 +03:00
// _open_pq (sgbr);
_open_pq (sggl);
_open_pq (sgbc);
2014-06-12 02:29:17 +04:00
_open_pq (sgcb);
_open_pqrs(sgcn);
2014-06-12 02:29:17 +04:00
_open_pq (sgfs);
_open_pq (sgls);
2014-06-18 21:38:34 +04:00
_open_pqr (sgpm);
2014-06-14 00:52:13 +04:00
_open_pqrs(sgwt);
2014-06-12 02:29:17 +04:00
2013-09-29 00:21:18 +04:00
_open_pq (smcl);
2014-06-19 00:09:04 +04:00
// _open_pq (smsm);
2014-06-12 02:29:17 +04:00
2014-06-17 22:04:27 +04:00
_open_pq (tsbr);
_open_pq (tscl);
_open_pqr (tsdt);
2014-06-11 01:31:16 +04:00
_open_pq (tsgl);
_open_pq (tshp);
_open_pq (tsls);
2014-06-19 00:09:04 +04:00
_open_p (tssg);
2014-06-12 02:29:17 +04:00
2014-06-11 01:31:16 +04:00
_open_pqr (wtdt);
_open_pq (wtgl);
2014-06-14 00:52:13 +04:00
_open_pqr (wtpt);
_open_pqr (wtsg);
2014-06-11 01:31:16 +04:00
_open_p (wtzp);
_open_p (wtbr);
2014-06-16 23:19:33 +04:00
_open_pq (wthp);
2014-06-11 01:31:16 +04:00
_open_pq (wtgr);
2014-06-11 05:09:47 +04:00
_open_pqr (wtls);
_open_pqr (wtkt);
_open_p (wtpm);
2014-06-13 02:22:25 +04:00
2014-06-18 21:38:34 +04:00
_open_pq (zpcb);
2014-06-13 02:22:25 +04:00
_open_p (zpgr);
2013-09-29 00:21:18 +04:00
}
}
/** rake
**/
2014-09-06 00:13:24 +04:00
u3_noun
2015-08-28 19:34:36 +03:00
u3qfp_rake(u3_noun gen)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun p_gen, q_gen;
2013-09-29 00:21:18 +04:00
2014-11-05 04:18:47 +03:00
if ( c3y == u3ud(gen) ) {
2014-09-06 00:13:24 +04:00
return u3nc(u3k(gen), u3_nul);
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
else switch ( u3h(gen) ) {
2014-11-06 03:20:01 +03:00
default: return u3m_error("rake-twig");
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
case u3_nul: return u3nc(u3k(gen), u3_nul);
2013-09-29 00:21:18 +04:00
2014-01-05 07:18:06 +04:00
case c3__cnzy: {
2014-09-06 00:13:24 +04:00
return u3nc(u3k(u3t(gen)), u3_nul);
2014-01-05 07:18:06 +04:00
}
case c3__cnzz: {
2014-09-06 00:13:24 +04:00
return u3k(u3t(gen));
2014-01-05 07:18:06 +04:00
}
2013-09-29 00:21:18 +04:00
case c3__cnts: {
2014-11-06 03:20:01 +03:00
if ( c3n == u3r_cell(u3t(gen), &p_gen, &q_gen) ) {
return u3m_bail(c3__fail);
2013-09-29 00:21:18 +04:00
}
else {
2014-09-06 00:13:24 +04:00
if ( u3_nul != q_gen ) {
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__fail);
2013-09-29 00:21:18 +04:00
}
else {
2014-09-06 00:13:24 +04:00
return u3k(p_gen);
2013-09-29 00:21:18 +04:00
}
}
}
case c3__zpcb: {
2014-11-06 03:20:01 +03:00
if ( c3n == u3r_cell(u3t(gen), &p_gen, &q_gen) ) {
return u3m_bail(c3__fail);
2013-09-29 00:21:18 +04:00
}
2014-11-06 22:13:57 +03:00
else return u3qfp_rake(q_gen);
2013-09-29 00:21:18 +04:00
}
}
}
2014-09-06 00:13:24 +04:00
u3_noun
2015-08-28 19:34:36 +03:00
u3wfp_rake(u3_noun cor)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun gen;
2013-09-29 00:21:18 +04:00
2014-11-18 00:56:51 +03:00
if ( u3_none == (gen = u3r_at(u3x_sam, cor)) ) {
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-11-06 22:13:57 +03:00
return u3qfp_rake(gen);
2013-09-29 00:21:18 +04:00
}
}
/** hack
**/
2014-09-06 00:13:24 +04:00
u3_noun
2015-08-28 19:34:36 +03:00
u3qfp_hack(u3_noun ter,
u3_noun gen)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun p_gen, q_gen;
u3_noun ret;
2013-09-29 00:21:18 +04:00
2014-11-05 04:18:47 +03:00
if ( c3y == u3du(u3h(gen)) ) {
return u3nt(c3y,
2015-08-28 19:34:36 +03:00
u3k(u3h(gen)),
u3k(u3t(gen)));
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
else switch ( u3h(gen) ) {
2014-11-06 03:20:01 +03:00
case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen);
2013-09-29 00:21:18 +04:00
{
2014-11-05 04:18:47 +03:00
if ( (c3n == u3du(p_gen)) || (u3_nul != u3h(p_gen)) ) {
return u3nc(c3n, u3k(gen));
2013-09-29 00:21:18 +04:00
}
else {
2014-11-06 22:13:57 +03:00
u3_noun pyr = u3qfp_hack(ter, q_gen);
2014-09-06 00:13:24 +04:00
2014-11-05 04:18:47 +03:00
if ( c3y == u3h(pyr) ) {
2015-08-28 19:34:36 +03:00
ret = u3nt(c3y,
u3nt(c3__tsgr,
u3k(p_gen),
u3k(u3h(u3t(pyr)))),
u3nt(c3__tsgr,
u3k(p_gen),
u3k(u3t(u3t(pyr)))));
2013-09-29 00:21:18 +04:00
}
else {
2015-08-28 19:34:36 +03:00
ret = u3nc(c3n,
u3nt(c3__tsgr,
u3k(p_gen),
u3k(u3t(pyr))));
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
u3z(pyr);
2013-09-29 00:21:18 +04:00
return ret;
}
}
2014-11-06 03:20:01 +03:00
case c3__zpcb: u3x_cell(u3t(gen), &p_gen, &q_gen);
2013-09-29 00:21:18 +04:00
{
2014-11-06 22:13:57 +03:00
u3_noun pyr = u3qfp_hack(ter, q_gen);
2014-09-06 00:13:24 +04:00
2014-11-05 04:18:47 +03:00
if ( c3y == u3h(pyr) ) {
2015-08-28 19:34:36 +03:00
ret = u3nt(c3y,
u3nt(c3__zpcb,
u3k(p_gen),
u3k(u3h(u3t(pyr)))),
u3nt(c3__zpcb,
u3k(p_gen),
u3k(u3t(u3t(pyr)))));
2013-09-29 00:21:18 +04:00
}
else {
2015-08-28 19:34:36 +03:00
ret = u3nc(c3n,
u3nt(c3__zpcb,
u3k(p_gen),
u3k(u3t(pyr))));
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
u3z(pyr);
2013-09-29 00:21:18 +04:00
return ret;
}
2013-09-29 00:21:18 +04:00
default: break;
}
{
2014-09-06 00:13:24 +04:00
u3_noun voq = _ap_open_l(ter, gen);
2013-09-29 00:21:18 +04:00
2014-11-06 02:36:30 +03:00
if ( u3_none == voq ) {
2014-11-05 04:18:47 +03:00
return u3nc(c3n, u3k(gen));
2013-09-29 00:21:18 +04:00
}
2014-11-06 03:20:01 +03:00
else if ( c3y == u3r_sing(voq, gen) ) {
2014-11-05 04:18:47 +03:00
return u3nc(c3n, voq);
2013-09-29 00:21:18 +04:00
}
else {
2014-11-06 22:13:57 +03:00
ret = u3qfp_hack(ter, voq);
2013-09-29 00:21:18 +04:00
2014-09-06 00:13:24 +04:00
u3z(voq);
2013-09-29 00:21:18 +04:00
return ret;
}
}
}
2014-09-06 00:13:24 +04:00
u3_noun
2015-08-28 19:34:36 +03:00
u3wfp_hack(u3_noun cor)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun gen;
2013-09-29 00:21:18 +04:00
2014-11-18 00:56:51 +03:00
if ( u3_none == (gen = u3r_at(u3x_sam, cor)) ) {
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-11-18 00:56:51 +03:00
u3_noun ter = u3r_at(u3x_con, cor);
2013-09-29 00:21:18 +04:00
2014-11-06 22:13:57 +03:00
return u3qfp_hack(ter, gen);
2013-09-29 00:21:18 +04:00
}
}
2018-01-16 05:24:11 +03:00
#endif
2013-09-29 00:21:18 +04:00
/* boilerplate
*/
2017-09-28 03:40:12 +03:00
static u3_noun
2015-08-28 19:34:36 +03:00
_ap_core(u3_noun ter,
u3_noun gen)
2014-09-04 01:33:18 +04:00
{
2014-11-06 03:20:01 +03:00
u3_noun gat = u3j_hook(u3k(ter), "ap");
2014-09-04 01:33:18 +04:00
2014-11-18 00:56:51 +03:00
return u3i_molt(gat, u3x_sam, u3k(gen), 0);
2013-09-29 00:21:18 +04:00
}
/* open
*/
2014-09-06 00:13:24 +04:00
static u3_noun
_ap_open_n(u3_noun ter,
u3_noun gen)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun cor = _ap_core(ter, gen);
2013-09-29 00:21:18 +04:00
2014-11-06 03:20:01 +03:00
return u3j_soft(cor, "open");
}
2014-09-06 00:13:24 +04:00
static u3_noun
2015-08-28 19:34:36 +03:00
_ap_open_l(u3_noun ter,
u3_noun gen)
2013-09-29 00:21:18 +04:00
{
2018-01-16 05:24:11 +03:00
#if 0
2014-09-06 00:13:24 +04:00
u3_noun pro = _open_in(ter, gen);
2013-09-29 00:21:18 +04:00
2014-11-06 02:36:30 +03:00
if ( u3_none != pro ) {
2013-09-29 00:21:18 +04:00
return pro;
} else {
2014-09-04 01:33:18 +04:00
return _ap_open_n(ter, gen);
2013-09-29 00:21:18 +04:00
}
2018-01-16 05:24:11 +03:00
#else
return _ap_open_n(ter, gen);
#endif
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
u3_noun
2015-08-28 19:34:36 +03:00
u3qfp_open(u3_noun ter,
u3_noun gen)
2013-09-29 00:21:18 +04:00
{
2014-09-04 01:33:18 +04:00
return _ap_open_l(ter, gen);
2013-09-29 00:21:18 +04:00
}
u3_noun
u3qfp_nepo(u3_noun ter,
u3_noun gen)
{
2018-01-16 05:24:11 +03:00
return _ap_open_l(ter, gen);
}
u3_noun
2018-01-16 05:24:11 +03:00
u3wfp_open(u3_noun cor)
{
u3_noun gen;
if ( u3_none == (gen = u3r_at(u3x_sam, cor)) ) {
return u3m_bail(c3__fail);
} else {
u3_noun ter = u3r_at(u3x_con, cor);
2018-01-16 05:24:11 +03:00
return u3qfp_open(ter, gen);
}
}
2018-01-16 05:24:11 +03:00