From 35190f55fb2e648a3e65a2911e6fccc80a6b728e Mon Sep 17 00:00:00 2001 From: Zeex Date: Fri, 3 Apr 2015 23:15:05 +0600 Subject: [PATCH] Incremental ... initialization of 2d arrays This is fully supported now: new arr[3][3] = {{0, 1, ...}, {0, 2, ...}, ...}; will produce: {{0, 1, 2}, {0, 2, 4}, {0, 3, 6}} and this: new arr[3][3] = {{0, 1, ...}, ...}; will yield: {{0, 1, 2}, {0, 1, 2}, {0, 1, 2}} Refs #48 --- source/compiler/sc1.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 8e6709a..25dc4de 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -2460,18 +2460,14 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur, int startlit,int counteddim[],constvalue *lastdim, constvalue *enumroot,int *errorfound) { - cell dsize,totalsize; - int idx,numvectors,abortparse,ellips; - const char *initptr,*prev_initptr; + cell dsize,totalsize=0; + int idx=0,vec_idx,abortparse=FALSE; + cell *prev1=NULL,*prev2=NULL; assert(cur>=0 && cur=0); assert(cur+2<=numdim); /* there must be 2 dimensions or more to do */ assert(errorfound!=NULL && *errorfound==FALSE); - idx=0; - prev_initptr=NULL; - totalsize=0; - abortparse=FALSE; needtoken('{'); do { int ellips=FALSE; @@ -2493,28 +2489,29 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur, dsize=initarray(ident,tag,dim,numdim,cur+1,startlit,counteddim, lastdim,enumroot,errorfound); } else { - initptr=lptr; - numvectors=idx+1; - if ((ellips=matchtoken(tELLIPS))!=0) - numvectors=dim[cur]; - dsize=0; - while (idx