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, lteqop,gteqop,eqeqop,exceqop,andandop,
barbarop,pluseqop,minuseqop,asteriskeqop,slasheqop, barbarop,pluseqop,minuseqop,asteriskeqop,slasheqop,
percenteqop,ltlteqop,gtgteqop,andeqop,caroteqop, percenteqop,ltlteqop,gtgteqop,andeqop,caroteqop,
bareqop,poundpoundop, bareqop,poundpoundop,dotdotdotsy,
eolsy,eofsy, {control characters} eolsy,eofsy, {control characters}
typedef, {user types} typedef, {user types}
uminus,uand,uasterisk, {converted operations} uminus,uand,uasterisk, {converted operations}

View File

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

View File

@ -1500,13 +1500,18 @@ var
end; {if} end; {if}
if token.kind = commach then begin if token.kind = commach then begin
NextToken; 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; NextToken;
Match(dotch,89); Match(dotch,89);
Match(dotch,89); Match(dotch,89);
varargs := true; varargs := true;
done2 := true; done2 := true;
end; {if} end; {else if}
end {if} end {if}
else else
done2 := true; done2 := true;

View File

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

View File

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