|
@@ -558,6 +558,94 @@ struct _Nt{enum Ntag_t{N_STRAND,N_LITERAL,N_INDEX1,N_INDEX2,N_FUN,N_MONAD,N_DYAD
|
|
Nt*a;
|
|
Nt*a;
|
|
Nt*b;
|
|
Nt*b;
|
|
Nt*c;};
|
|
Nt*c;};
|
|
|
|
+S Nshow(Nt*n){SW(n->tag){CS N_STRAND:{Bt*buf=Bnew();
|
|
|
|
+ for(Z i=0;i<n->l->length;i++){if(i!=0)BappendS(buf,",:");
|
|
|
|
+ S s=Nshow(n->l->data[i]);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);}
|
|
|
|
+ R Bread(buf);}
|
|
|
|
+ CS N_LITERAL:R Vshow(n->v);
|
|
|
|
+ CS N_INDEX1:{S s;
|
|
|
|
+ Bt*buf=Bnew();
|
|
|
|
+ s=Nshow(n->a);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ Bappend(buf,' ');
|
|
|
|
+ s=Nshow(n->b);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);R Bread(buf);}
|
|
|
|
+ CS N_INDEX2:{S s;
|
|
|
|
+ Bt*buf=Bnew();
|
|
|
|
+ s=Nshow(n->a);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ Bappend(buf,' ');
|
|
|
|
+ s=Nshow(n->b);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ Bappend(buf,' ');
|
|
|
|
+ s=Nshow(n->c);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);R Bread(buf);}
|
|
|
|
+ CS N_FUN:{Bt*buf=Bnew();
|
|
|
|
+ Bappend(buf,':');
|
|
|
|
+ S s=Nshow(n->a);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);R Bread(buf);}
|
|
|
|
+ CS N_MONAD:CS N_HOOK:CS N_BOND:CS N_OVER:{S s;
|
|
|
|
+ Bt*buf=Bnew();
|
|
|
|
+ s=Nshow(n->a);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ s=Nshow(n->b);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);R Bread(buf);}
|
|
|
|
+ CS N_DYAD:{S s;
|
|
|
|
+ Bt*buf=Bnew();
|
|
|
|
+ s=Nshow(n->b);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ s=Nshow(n->a);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ s=Nshow(n->c);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);R Bread(buf);}
|
|
|
|
+ CS N_ADV:CS N_PARTIAL_CONJ:{Bt*buf=Bnew();
|
|
|
|
+ S s=Nshow(n->a);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ BappendS(buf,n->av->name);R Bread(buf);}
|
|
|
|
+ CS N_CONJ:{S s;
|
|
|
|
+ Bt*buf=Bnew();
|
|
|
|
+ s=Nshow(n->a);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ BappendS(buf,n->av->name);
|
|
|
|
+ s=Nshow(n->b);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);R Bread(buf);}
|
|
|
|
+ CS N_FORK:{S s;
|
|
|
|
+ Bt*buf=Bnew();
|
|
|
|
+ s=Nshow(n->a);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ s=Nshow(n->b);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ s=Nshow(n->c);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);R Bread(buf);}
|
|
|
|
+ CS N_BIND:{S s;
|
|
|
|
+ Bt*buf=Bnew();
|
|
|
|
+ s=Nshow(n->a);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);
|
|
|
|
+ Bappend(buf,':');
|
|
|
|
+ s=Nshow(n->b);
|
|
|
|
+ BappendS(buf,s);
|
|
|
|
+ FR(s);R Bread(buf);}}
|
|
|
|
+ R sdup("<?>");}
|
|
Vt*_fork_m(St*st,vt*self,Vt*x){vt*f=Ai(self->bonds,0);
|
|
Vt*_fork_m(St*st,vt*self,Vt*x){vt*f=Ai(self->bonds,0);
|
|
vt*g=Ai(self->bonds,1);
|
|
vt*g=Ai(self->bonds,1);
|
|
vt*h=Ai(self->bonds,2);
|
|
vt*h=Ai(self->bonds,2);
|
|
@@ -635,7 +723,11 @@ Vt*Swalk(St*st,Nt*node){if(!node)R st->nil;
|
|
vt*nv=vnew();
|
|
vt*nv=vnew();
|
|
if(argc>0)nv->is_fun=T;
|
|
if(argc>0)nv->is_fun=T;
|
|
nv->bonds=An();
|
|
nv->bonds=An();
|
|
- nv->name=sdup(argc==0?":...":argc==1?":x":":xy");
|
|
|
|
|
|
+ S s=Nshow(node->a);
|
|
|
|
+ Z z=strlen(s)+2;
|
|
|
|
+ nv->name=ma(z);
|
|
|
|
+ snprintf(nv->name,z,":%s",s);
|
|
|
|
+ FR(s);
|
|
nv->rank[0]=0;
|
|
nv->rank[0]=0;
|
|
nv->rank[1]=0;
|
|
nv->rank[1]=0;
|
|
nv->rank[2]=0;
|
|
nv->rank[2]=0;
|
|
@@ -754,6 +846,8 @@ Vt*Swalk(St*st,Nt*node){if(!node)R st->nil;
|
|
nca(b,&argc);
|
|
nca(b,&argc);
|
|
if(argc!=0)b=Nn1(N_FUN,b);
|
|
if(argc!=0)b=Nn1(N_FUN,b);
|
|
Vt*r=Swalk(st,b);
|
|
Vt*r=Swalk(st,b);
|
|
|
|
+ if(argc!=0){FR(r->val.verb->name);
|
|
|
|
+ r->val.verb->name=l->val.symbol;}
|
|
if(r->tag==VERB&&argc==0)r->val.verb->mark=T;
|
|
if(r->tag==VERB&&argc==0)r->val.verb->mark=T;
|
|
Vt*ov=Tget(st->env,l->val.symbol);
|
|
Vt*ov=Tget(st->env,l->val.symbol);
|
|
if(ov&&ov->tag==VERB&&ov->val.verb->is_fun&&r->tag==VERB&&r->val.verb->is_fun){if(!ov->val.verb->monad&&r->val.verb->monad){As(ov->val.verb->bonds,0,r->val.verb->bonds->data[0]);
|
|
if(ov&&ov->tag==VERB&&ov->val.verb->is_fun&&r->tag==VERB&&r->val.verb->is_fun){if(!ov->val.verb->monad&&r->val.verb->monad){As(ov->val.verb->bonds,0,r->val.verb->bonds->data[0]);
|
|
@@ -783,7 +877,7 @@ Vt*vunbind(St*st,vt*self,Vt*x){if(xt==SYM){Tdelete(st->env,xY);R st->nil;}
|
|
Vt*vobverse(St*st,vt*self,Vt*x,Vt*y){if(xt==VERB&&yt==VERB){vt*vx=xV;
|
|
Vt*vobverse(St*st,vt*self,Vt*x,Vt*y){if(xt==VERB&&yt==VERB){vt*vx=xV;
|
|
if(!yV->monad)
|
|
if(!yV->monad)
|
|
R st->udf;
|
|
R st->udf;
|
|
- if(strcmp(vx->name,":...")==0||strcmp(vx->name,":x")==0||strcmp(vx->name,":xy")==0)R st->udf;
|
|
|
|
|
|
+ if(vx->is_fun)R st->udf;
|
|
if(Thas(Inverses,vx->name))R st->udf;
|
|
if(Thas(Inverses,vx->name))R st->udf;
|
|
Tset(Inverses,vx->name,yV);R st->nil;}
|
|
Tset(Inverses,vx->name,yV);R st->nil;}
|
|
R st->udf;}
|
|
R st->udf;}
|