From e1082f64bc4171884316621f6f62a49c45d97e81 Mon Sep 17 00:00:00 2001 From: Zeex Date: Fri, 3 Apr 2015 12:05:07 +0600 Subject: [PATCH] Add partial support for ... inintialization of 2d arrays Refs #48 --- source/compiler/sc1.c | 45 +++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 102cc4b..8e6709a 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -2461,15 +2461,20 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur, constvalue *enumroot,int *errorfound) { cell dsize,totalsize; - int idx,abortparse; + int idx,numvectors,abortparse,ellips; + const char *initptr,*prev_initptr; assert(cur>=0 && cur=0); - assert(cur+2<=numdim);/* there must be 2 dimensions or more to do */ + 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('{'); - for (idx=0,abortparse=FALSE; !abortparse; idx++) { + do { + int ellips=FALSE; /* In case the major dimension is zero, we need to store the offset * to the newly detected sub-array into the indirection table; i.e. * this table needs to be expanded and updated. @@ -2481,24 +2486,40 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur, if (dim[cur]==0) { litinsert(0,startlit); } else if (idx>=dim[cur]) { - error(18); /* initialization data exceeds array size */ + error(18); /* initialization data exceeds array size */ break; } /* if */ - if (cur+20) {