Added some %persistents, improved behaviour of preprocessor, and other
minor mods
This commit is contained in:
parent
c483664bb1
commit
1b08effa77
|
@ -321,7 +321,7 @@ firstline:
|
||||||
while (ch != '\'') {
|
while (ch != '\'') {
|
||||||
if (ch == '\n') {
|
if (ch == '\n') {
|
||||||
lexerror("newline in character constant");
|
lexerror("newline in character constant");
|
||||||
LineNumber++;
|
PushBack();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ch == '\\') {
|
if (ch == '\\') {
|
||||||
|
@ -522,7 +522,7 @@ string_token(nm, stop_char, plen)
|
||||||
while (ch != stop_char) {
|
while (ch != stop_char) {
|
||||||
if (ch == '\n') {
|
if (ch == '\n') {
|
||||||
lexerror("newline in %s", nm);
|
lexerror("newline in %s", nm);
|
||||||
LineNumber++;
|
PushBack();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ch == EOI) {
|
if (ch == EOI) {
|
||||||
|
|
|
@ -291,7 +291,7 @@ arrayer(arith *sizep;)
|
||||||
|
|
||||||
formal_list (struct formal **fmp;)
|
formal_list (struct formal **fmp;)
|
||||||
:
|
:
|
||||||
formal(fmp) [ ',' formal(fmp) ]*
|
formal(fmp) [ %persistent ',' formal(fmp) ]*
|
||||||
;
|
;
|
||||||
|
|
||||||
formal(struct formal **fmp;)
|
formal(struct formal **fmp;)
|
||||||
|
|
|
@ -167,12 +167,18 @@ skip_block(to_endif)
|
||||||
on the same level.
|
on the same level.
|
||||||
*/
|
*/
|
||||||
switch(tk.tk_idf->id_resmac) {
|
switch(tk.tk_idf->id_resmac) {
|
||||||
|
default:
|
||||||
|
SkipRestOfLine();
|
||||||
|
break;
|
||||||
case K_IF:
|
case K_IF:
|
||||||
case K_IFDEF:
|
case K_IFDEF:
|
||||||
case K_IFNDEF:
|
case K_IFNDEF:
|
||||||
push_if();
|
push_if();
|
||||||
|
SkipRestOfLine();
|
||||||
break;
|
break;
|
||||||
case K_ELIF:
|
case K_ELIF:
|
||||||
|
if (ifstack[nestlevel])
|
||||||
|
lexwarning("#elif without corresponding #if");
|
||||||
if (! to_endif && nestlevel == skiplevel) {
|
if (! to_endif && nestlevel == skiplevel) {
|
||||||
nestlevel--;
|
nestlevel--;
|
||||||
push_if();
|
push_if();
|
||||||
|
@ -181,12 +187,15 @@ skip_block(to_endif)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else SkipRestOfLine();
|
||||||
break;
|
break;
|
||||||
case K_ELSE:
|
case K_ELSE:
|
||||||
|
if (ifstack[nestlevel])
|
||||||
|
lexwarning("#else without corresponding #if");
|
||||||
|
SkipRestOfLine();
|
||||||
if (! to_endif) {
|
if (! to_endif) {
|
||||||
++(ifstack[nestlevel]);
|
++(ifstack[nestlevel]);
|
||||||
if (nestlevel == skiplevel) {
|
if (nestlevel == skiplevel) {
|
||||||
SkipRestOfLine();
|
|
||||||
NoUnstack--;
|
NoUnstack--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -194,8 +203,8 @@ skip_block(to_endif)
|
||||||
break;
|
break;
|
||||||
case K_ENDIF:
|
case K_ENDIF:
|
||||||
ASSERT(nestlevel > nestlow);
|
ASSERT(nestlevel > nestlow);
|
||||||
if (nestlevel == skiplevel) {
|
|
||||||
SkipRestOfLine();
|
SkipRestOfLine();
|
||||||
|
if (nestlevel == skiplevel) {
|
||||||
nestlevel--;
|
nestlevel--;
|
||||||
NoUnstack--;
|
NoUnstack--;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -72,7 +72,8 @@ parameter_list(struct expr **expp;)
|
||||||
:
|
:
|
||||||
assignment_expression(expp)
|
assignment_expression(expp)
|
||||||
{any2opnd(expp, PARCOMMA);}
|
{any2opnd(expp, PARCOMMA);}
|
||||||
[ ','
|
[ %persistent
|
||||||
|
','
|
||||||
assignment_expression(&e1)
|
assignment_expression(&e1)
|
||||||
{any2opnd(&e1, PARCOMMA);}
|
{any2opnd(&e1, PARCOMMA);}
|
||||||
{ch7bin(expp, PARCOMMA, e1);}
|
{ch7bin(expp, PARCOMMA, e1);}
|
||||||
|
|
|
@ -557,8 +557,8 @@ ch_array(tpp, ex)
|
||||||
struct expr *ex;
|
struct expr *ex;
|
||||||
{
|
{
|
||||||
register struct type *tp = *tpp;
|
register struct type *tp = *tpp;
|
||||||
register arith length = ex->SG_LEN;
|
register int length = ex->SG_LEN, i;
|
||||||
char *s;
|
register char *to, *from, *s;
|
||||||
|
|
||||||
ASSERT(ex->ex_class == String);
|
ASSERT(ex->ex_class == String);
|
||||||
if (tp->tp_size == (arith)-1) {
|
if (tp->tp_size == (arith)-1) {
|
||||||
|
@ -575,10 +575,14 @@ ch_array(tpp, ex)
|
||||||
}
|
}
|
||||||
/* throw out the characters of the already prepared string */
|
/* throw out the characters of the already prepared string */
|
||||||
s = Malloc((unsigned) (length));
|
s = Malloc((unsigned) (length));
|
||||||
clear(s, (int) (length));
|
clear(s, length);
|
||||||
strncpy(s, ex->SG_VALUE, (int) length);
|
i = length <= ex->SG_LEN ? length : ex->SG_LEN;
|
||||||
|
to = s; from = ex->SG_VALUE;
|
||||||
|
while(--i >= 0) {
|
||||||
|
*to++ = *from++;
|
||||||
|
}
|
||||||
free(ex->SG_VALUE);
|
free(ex->SG_VALUE);
|
||||||
str_cst(s, (int) (length));
|
str_cst(s, length);
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue