Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions compiler/libpc300/sc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions compiler/libpc300/sc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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<numdim);
assert(startlit>=0);
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion compiler/libpc300/sc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -2204,6 +2212,7 @@ static void chk_grow_litq(void)
*/
SC_FUNC void litadd(cell value)
{
assert(!sLiteralQueueDisabled);
chk_grow_litq();
assert(litidx<litmax);
litq[litidx++]=value;
Expand All @@ -2219,6 +2228,7 @@ SC_FUNC void litadd(cell value)
*/
SC_FUNC void litinsert(cell value,int pos)
{
assert(!sLiteralQueueDisabled);
chk_grow_litq();
assert(litidx<litmax);
assert(pos>=0 && pos<=litidx);
Expand Down
2 changes: 2 additions & 0 deletions compiler/libpc300/scvars.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down