Browse Source

fix segfault

txlyre 2 tuần trước cách đây
mục cha
commit
4a2749738c
1 tập tin đã thay đổi với 11 bổ sung5 xóa
  1. 11 5
      jk.c

+ 11 - 5
jk.c

@@ -707,8 +707,8 @@ Vt*_partial_conjunction(St*st,vt*self,Vt*x){advt*av=self->bonds->data[0];
   Vt*a=self->bonds->data[1];R Vnv(av->conjunction(st,a,x));}
 Nt*Nn1(enum Ntag_t tag,Nt*a);
 Vt*Swalk(St*st,Nt*node){if(!node)R st->nil;
-  SW(node->tag){CS N_STRAND:{Ar*t=node->l;
-    for(Z i=0;i<t->length;i++)t->data[i]=Swalk(st,t->data[i]);R Vna(node->l);}
+  SW(node->tag){CS N_STRAND:{Ar*t=Ac(node->l);
+    for(Z i=0;i<t->length;i++)t->data[i]=Swalk(st,t->data[i]);R Vna(t);}
   CS N_LITERAL:{Vt*v=node->v;
     Vt*t=N;
     if(v->tag==SYM){S n=v->val.symbol;
@@ -2302,7 +2302,8 @@ typedef struct{Lt*lexer;
   St*st;
   Z pos;
   Z end;
-  Z dp;}Pt;
+  Z dp;
+  B bn;}Pt;
 Pt*Pnew(St*state){Pt*parser=ma(SO(Pt));
   parser->st=state;R parser;}
 V Perror(Pt*parser,S s){fatal(s);}
@@ -2357,7 +2358,8 @@ Nt*PPatom(Pt*parser){Tkt*tok=Plook(parser,0);
     if(tok&&tok->tag==T_RPAR){node=Nnl(parser->st->unit);BR;}
     parser->dp++;
     node=PPexpr(parser);
-    node->dp=parser->dp;
+    if(parser->bn)node->dp=2;
+    else node->dp=parser->dp;
     parser->dp--;
     tok=Plook(parser,0);
     if(!tok||tok->tag!=T_RPAR)Perror(parser,"unmatched");BR;
@@ -2447,7 +2449,11 @@ Nt*PPexpr(Pt*parser){Tkt*tmp;
   Ar*ns=An();
   WH(!Pstop(parser)){if(!ns->data&&(tmp=Plook(parser,0))&&tmp->tag==T_PUNCT&&strcmp(tmp->text,":")==0&&(Plook(parser,1))){Peat(parser);R Nn1(N_FUN,PPexpr(parser));}
     Nt*n=PPnoun(parser,F);
-    if(!ns->data&&n->tag==N_LITERAL&&n->v->tag==SYM&&(tmp=Plook(parser,0))&&tmp->tag==T_PUNCT&&strcmp(tmp->text,":")==0){Peat(parser);R Nn2(N_BIND,n,PPexpr(parser));}
+    if(!ns->data&&n->tag==N_LITERAL&&n->v->tag==SYM&&(tmp=Plook(parser,0))&&tmp->tag==T_PUNCT&&strcmp(tmp->text,":")==0){Peat(parser);
+      B t=parser->bn;
+      parser->bn=T;
+      Nt*r=PPexpr(parser);
+      parser->bn=t;R Nn2(N_BIND,n,r);}
     LOOP{B flag=F;
       n=PPadv(parser,n,&flag);
       n=PPcnj(parser,n,&flag);