diff --git a/compiler/libpc300/sc.h b/compiler/libpc300/sc.h index 2d8c8c24..1c3cfe0c 100755 --- a/compiler/libpc300/sc.h +++ b/compiler/libpc300/sc.h @@ -370,8 +370,9 @@ typedef struct s_stringpair { #define tSYMBOL 330 #define tLABEL 331 #define tSTRING 332 -#define tEXPR 333 /* for assigment to "lastst" only */ -#define tEMPTYBLOCK 334 /* empty blocks for AM bug 4825 */ +#define tPENDING_STRING 333 +#define tEXPR 334 /* for assigment to "lastst" only */ +#define tEMPTYBLOCK 335 /* empty blocks for AM bug 4825 */ /* (reversed) evaluation of staging buffer */ #define sSTARTREORDER 0x01 @@ -811,6 +812,8 @@ SC_VDECL FILE *outf; /* file written to */ SC_VDECL jmp_buf errbuf; /* target of longjmp() on a fatal error */ +SC_VDECL SC_VDEFINE char sLiteralQueueDisabled; + #if !defined SC_LIGHT SC_VDECL int sc_makereport; /* generate a cross-reference report */ #endif diff --git a/compiler/libpc300/sc1.c b/compiler/libpc300/sc1.c index 45f9d344..0fe2b086 100755 --- a/compiler/libpc300/sc1.c +++ b/compiler/libpc300/sc1.c @@ -2296,6 +2296,7 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur, { cell dsize,totalsize; int idx,abortparse; + char disable = FALSE; assert(cur>=0 && cur=0); @@ -2332,6 +2333,13 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur, totalsize+=dsize; if (*errorfound || !matchtoken(',')) abortparse=TRUE; + disable = sLiteralQueueDisabled; + sLiteralQueueDisabled = TRUE; + if (matchtoken('}')) { + abortparse = TRUE; + lexpush(); + } + sLiteralQueueDisabled = disable; } /* for */ needtoken('}'); assert(counteddim!=NULL); diff --git a/compiler/libpc300/sc2.c b/compiler/libpc300/sc2.c index d5072cf4..1fcd5aac 100755 --- a/compiler/libpc300/sc2.c +++ b/compiler/libpc300/sc2.c @@ -1857,7 +1857,7 @@ char *sc_tokens[] = { "#endscript", "#error", "#file", "#if", "#include", "#line", "#pragma", "#tryinclude", "#undef", ";", ";", "-integer value-", "-rational value-", "-identifier-", - "-label-", "-string-" + "-label-", "-string-", "-string-" }; SC_FUNC int lex(cell *lexvalue,char **lexsym) @@ -1976,6 +1976,10 @@ SC_FUNC int lex(cell *lexvalue,char **lexsym) } /* if */ } else if (*lptr=='\"' || (*lptr==sc_ctrlchar && *(lptr+1)=='\"')) { /* unpacked string literal */ + if (sLiteralQueueDisabled) { + _lextok=tPENDING_STRING; + return _lextok; + } _lextok=tSTRING; stringflags= (*lptr==sc_ctrlchar) ? RAWMODE : 0; *lexvalue=_lexval=litidx; @@ -2045,6 +2049,10 @@ SC_FUNC int lex(cell *lexvalue,char **lexsym) */ SC_FUNC void lexpush(void) { + if (_lextok == tPENDING_STRING) { + // Don't push back fake tokens. + return; + } assert(_pushed==FALSE); _pushed=TRUE; } @@ -2204,6 +2212,7 @@ static void chk_grow_litq(void) */ SC_FUNC void litadd(cell value) { + assert(!sLiteralQueueDisabled); chk_grow_litq(); assert(litidx=0 && pos<=litidx); diff --git a/compiler/libpc300/scvars.c b/compiler/libpc300/scvars.c index 8afba17f..4a38f149 100755 --- a/compiler/libpc300/scvars.c +++ b/compiler/libpc300/scvars.c @@ -100,6 +100,8 @@ SC_VDEFINE jmp_buf errbuf; SC_VDEFINE HashTable *sp_Globals = NULL; +SC_VDEFINE char sLiteralQueueDisabled = FALSE; + #if !defined SC_LIGHT SC_VDEFINE int sc_makereport=FALSE; /* generate a cross-reference report */ #endif