Parse ... as a single punctuator token.

This accords with its definition in the C standards. For the time being, the old form of three separate tokens is still accepted too, because the ... token may not be scanned correctly in the obscure case where there is a line continuation between the second and third dots.

One observable effect of this is that there are no longer spaces between the dots in #pragma expand output.
This commit is contained in:
Stephen Heumann 2022-10-10 18:06:01 -05:00
parent f263066f61
commit 4fe9c90942
5 changed files with 34 additions and 15 deletions

View File

@ -195,7 +195,7 @@ type
lteqop,gteqop,eqeqop,exceqop,andandop,
barbarop,pluseqop,minuseqop,asteriskeqop,slasheqop,
percenteqop,ltlteqop,gtgteqop,andeqop,caroteqop,
bareqop,poundpoundop,
bareqop,poundpoundop,dotdotdotsy,
eolsy,eofsy, {control characters}
typedef, {user types}
uminus,uand,uasterisk, {converted operations}

View File

@ -18,7 +18,7 @@ uses CCommon, MM, Scanner, Symbol, CGI;
{$segment 'SCANNER'}
const
symFileVersion = 28; {version number of .sym file format}
symFileVersion = 29; {version number of .sym file format}
var
inhibitHeader: boolean; {should .sym includes be blocked?}

View File

@ -1500,13 +1500,18 @@ var
end; {if}
if token.kind = commach then begin
NextToken;
if token.kind = dotch then begin
if token.kind = dotdotdotsy then begin
NextToken;
varargs := true;
done2 := true;
end {if}
else if token.kind = dotch then begin
NextToken;
Match(dotch,89);
Match(dotch,89);
varargs := true;
done2 := true;
end; {if}
end; {else if}
end {if}
else
done2 := true;

View File

@ -1039,6 +1039,8 @@ case token.kind of
else
write('%:%:');
dotdotdotsy: write('...');
macroParm: write('$', token.pnum:1);
parameteroper,
@ -2583,17 +2585,21 @@ var
done := false;
end; {if}
end {if}
else if token.kind = dotch then begin
NextToken;
if token.kind = dotch then begin
NextToken;
if token.kind = dotch then
NextToken
else if token.kind in [dotch,dotdotdotsy] then begin
if token.kind = dotdotdotsy then
NextToken
else begin
NextToken;
if token.kind = dotch then begin
NextToken;
if token.kind = dotch then
NextToken
else
Error(89);
end
else
Error(89);
end
else
Error(89);
end; {else}
new(np);
np^.next := nil;
np^.str := '__VA_ARGS__';
@ -5229,7 +5235,13 @@ case charKinds[ord(ch)] of
DoNumber(false)
else begin
NextCh;
token.kind := dotch;
if (ch = '.') and (chPtr <> eofPtr) and (chr(chPtr^) = '.') then begin
token.kind := dotdotdotsy;
NextCh;
NextCh;
end {if}
else
token.kind := dotch;
end; {else}
end;

View File

@ -308,7 +308,7 @@ charSym start single character symbols
enum (lteqop,gteqop,eqeqop,exceqop,andandop)
enum (barbarop,pluseqop,minuseqop,asteriskeqop,slasheqop)
enum (percenteqop,ltlteqop,gtgteqop,andeqop,caroteqop)
enum (bareqop,poundpoundop)
enum (bareqop,poundpoundop,dotdotdotsy)
enum (eolsy,eofsy) control characters
enum (typedef) user types
enum (uminus,uand,uasterisk) converted operations
@ -464,6 +464,7 @@ icp start in-coming priority for expression
dc i1'3' caroteqop
dc i1'3' bareqop
dc i1'200' poundpoundop
dc i1'200' dotdotdotsy
dc i1'200' eolsy
dc i1'200' eofsy
dc i1'200' typedef
@ -639,6 +640,7 @@ isp start in stack priority for expression
dc i1'2' caroteqop
dc i1'2' bareqop
dc i1'0' poundpoundop
dc i1'0' dotdotdotsy
dc i1'0' eolsy
dc i1'0' eofsy
dc i1'0' typedef