mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-15 23:29:44 +00:00
Support "other character" preprocessing tokens.
This implements the catch-all category for preprocessing tokens for "each non-white-space character that cannot be one of the above" (C17 section 6.4). These may appear in skipped code, or in macros or macro parameters if they are never expanded or are stringized during macro processing. The affected characters are $, @, `, and many extended characters. It is still an error if these tokens are used in contexts where they remain present after preprocessing. If #pragma ignore bit 0 is clear, these characters are also reported as errors in skipped code or preprocessor constructs.
This commit is contained in:
parent
d96a5f86f9
commit
9cc72c8845
|
@ -196,6 +196,7 @@ type
|
||||||
barbarop,pluseqop,minuseqop,asteriskeqop,slasheqop,
|
barbarop,pluseqop,minuseqop,asteriskeqop,slasheqop,
|
||||||
percenteqop,ltlteqop,gtgteqop,andeqop,caroteqop,
|
percenteqop,ltlteqop,gtgteqop,andeqop,caroteqop,
|
||||||
bareqop,poundpoundop,dotdotdotsy,
|
bareqop,poundpoundop,dotdotdotsy,
|
||||||
|
otherch, {other non-whitespace char (pp-token)}
|
||||||
eolsy,eofsy, {control characters}
|
eolsy,eofsy, {control characters}
|
||||||
typedef, {user types}
|
typedef, {user types}
|
||||||
uminus,uand,uasterisk, {converted operations}
|
uminus,uand,uasterisk, {converted operations}
|
||||||
|
@ -209,14 +210,15 @@ type
|
||||||
(illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc,
|
(illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc,
|
||||||
ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string,
|
ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string,
|
||||||
ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon,
|
ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon,
|
||||||
ch_backslash,letter,digit);
|
ch_backslash,ch_other,letter,digit);
|
||||||
|
|
||||||
{prefixes of a character/string literal}
|
{prefixes of a character/string literal}
|
||||||
charStrPrefixEnum = (prefix_none,prefix_L,prefix_u16,prefix_U32,prefix_u8);
|
charStrPrefixEnum = (prefix_none,prefix_L,prefix_u16,prefix_U32,prefix_u8);
|
||||||
|
|
||||||
tokenSet = set of tokenEnum;
|
tokenSet = set of tokenEnum;
|
||||||
tokenClass = (reservedWord,reservedSymbol,identifier,intConstant,longConstant,
|
tokenClass = (reservedWord,reservedSymbol,identifier,intConstant,longConstant,
|
||||||
longlongConstant,realConstant,stringConstant,macroParameter);
|
longlongConstant,realConstant,stringConstant,otherCharacter,
|
||||||
|
macroParameter);
|
||||||
identPtr = ^identRecord; {^ to a symbol table entry}
|
identPtr = ^identRecord; {^ to a symbol table entry}
|
||||||
tokenType = record {a token}
|
tokenType = record {a token}
|
||||||
kind: tokenEnum; {kind of token}
|
kind: tokenEnum; {kind of token}
|
||||||
|
@ -233,6 +235,7 @@ type
|
||||||
stringConstant: (sval: longstringPtr;
|
stringConstant: (sval: longstringPtr;
|
||||||
ispstring: boolean;
|
ispstring: boolean;
|
||||||
prefix: charStrPrefixEnum);
|
prefix: charStrPrefixEnum);
|
||||||
|
otherCharacter: (ch: char); {used for preprocessing tokens only}
|
||||||
macroParameter: (pnum: integer);
|
macroParameter: (pnum: integer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ uses CCommon, MM, Scanner, Symbol, CGI;
|
||||||
{$segment 'HEADER'}
|
{$segment 'HEADER'}
|
||||||
|
|
||||||
const
|
const
|
||||||
symFileVersion = 31; {version number of .sym file format}
|
symFileVersion = 32; {version number of .sym file format}
|
||||||
|
|
||||||
var
|
var
|
||||||
inhibitHeader: boolean; {should .sym includes be blocked?}
|
inhibitHeader: boolean; {should .sym includes be blocked?}
|
||||||
|
@ -721,6 +721,7 @@ procedure EndInclude {chPtr: ptr};
|
||||||
WriteByte(ord(token.ispstring));
|
WriteByte(ord(token.ispstring));
|
||||||
WriteByte(ord(token.prefix));
|
WriteByte(ord(token.prefix));
|
||||||
end;
|
end;
|
||||||
|
otherCharacter: WriteByte(ord(token.ch));
|
||||||
macroParameter: WriteWord(token.pnum);
|
macroParameter: WriteWord(token.pnum);
|
||||||
reservedSymbol: if token.kind in [lbracech,rbracech,lbrackch,
|
reservedSymbol: if token.kind in [lbracech,rbracech,lbrackch,
|
||||||
rbrackch,poundch,poundpoundop] then
|
rbrackch,poundch,poundpoundop] then
|
||||||
|
@ -1360,6 +1361,7 @@ var
|
||||||
token.ispstring := ReadByte <> 0;
|
token.ispstring := ReadByte <> 0;
|
||||||
token.prefix := charStrPrefixEnum(ReadByte);
|
token.prefix := charStrPrefixEnum(ReadByte);
|
||||||
end;
|
end;
|
||||||
|
otherCharacter: token.ch := chr(ReadByte);
|
||||||
macroParameter: token.pnum := ReadWord;
|
macroParameter: token.pnum := ReadWord;
|
||||||
reservedSymbol: if token.kind in [lbracech,rbracech,lbrackch,
|
reservedSymbol: if token.kind in [lbracech,rbracech,lbrackch,
|
||||||
rbrackch,poundch,poundpoundop] then
|
rbrackch,poundch,poundpoundop] then
|
||||||
|
|
|
@ -465,7 +465,7 @@ cch equ 13
|
||||||
enum (illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc),0
|
enum (illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc),0
|
||||||
enum (ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string)
|
enum (ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string)
|
||||||
enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon)
|
enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon)
|
||||||
enum (ch_backslash,letter,digit)
|
enum (ch_backslash,ch_other,letter,digit)
|
||||||
|
|
||||||
! begin {NextCh}
|
! begin {NextCh}
|
||||||
tsc create stack frame
|
tsc create stack frame
|
||||||
|
|
26
Scanner.pas
26
Scanner.pas
|
@ -77,6 +77,7 @@ var
|
||||||
macros: ^macroTable; {preprocessor macro list}
|
macros: ^macroTable; {preprocessor macro list}
|
||||||
pathList: pathRecordPtr; {additional search paths}
|
pathList: pathRecordPtr; {additional search paths}
|
||||||
printMacroExpansions: boolean; {print the token list?}
|
printMacroExpansions: boolean; {print the token list?}
|
||||||
|
preprocessing: boolean; {doing pp directive or macro params?}
|
||||||
suppressMacroExpansions: boolean; {suppress printing even if requested?}
|
suppressMacroExpansions: boolean; {suppress printing even if requested?}
|
||||||
reportEOL: boolean; {report eolsy as a token?}
|
reportEOL: boolean; {report eolsy as a token?}
|
||||||
token: tokenType; {next token to process}
|
token: tokenType; {next token to process}
|
||||||
|
@ -1060,6 +1061,8 @@ case token.kind of
|
||||||
|
|
||||||
dotdotdotsy: write('...');
|
dotdotdotsy: write('...');
|
||||||
|
|
||||||
|
otherch: write(token.ch);
|
||||||
|
|
||||||
macroParm: write('$', token.pnum:1);
|
macroParm: write('$', token.pnum:1);
|
||||||
|
|
||||||
parameteroper,
|
parameteroper,
|
||||||
|
@ -1838,6 +1841,7 @@ var
|
||||||
i: integer; {loop counter}
|
i: integer; {loop counter}
|
||||||
inhibit: boolean; {inhibit parameter expansion?}
|
inhibit: boolean; {inhibit parameter expansion?}
|
||||||
lexpandMacros: boolean; {local copy of expandMacros}
|
lexpandMacros: boolean; {local copy of expandMacros}
|
||||||
|
lPreprocessing: boolean; {local copy of preprocessing}
|
||||||
lSuppressMacroExpansions: boolean; {local copy of suppressMacroExpansions}
|
lSuppressMacroExpansions: boolean; {local copy of suppressMacroExpansions}
|
||||||
mPtr: macroRecordPtr; {for checking list of macros}
|
mPtr: macroRecordPtr; {for checking list of macros}
|
||||||
newParm: parameterPtr; {for building a new parameter entry}
|
newParm: parameterPtr; {for building a new parameter entry}
|
||||||
|
@ -1861,6 +1865,8 @@ parms := nil; {no parms so far}
|
||||||
if macro^.parameters >= 0 then begin {find the values of the parameters}
|
if macro^.parameters >= 0 then begin {find the values of the parameters}
|
||||||
NextToken; {get the '(' (we hope...)}
|
NextToken; {get the '(' (we hope...)}
|
||||||
if token.kind = lparench then begin
|
if token.kind = lparench then begin
|
||||||
|
lPreprocessing := preprocessing;
|
||||||
|
preprocessing := true;
|
||||||
NextToken; {skip the '('}
|
NextToken; {skip the '('}
|
||||||
paramCount := 0; {process the parameters}
|
paramCount := 0; {process the parameters}
|
||||||
parmEnd := nil;
|
parmEnd := nil;
|
||||||
|
@ -1912,6 +1918,7 @@ if macro^.parameters >= 0 then begin {find the values of the parameters}
|
||||||
PutBackToken(token, true);
|
PutBackToken(token, true);
|
||||||
Error(12);
|
Error(12);
|
||||||
end; {if}
|
end; {if}
|
||||||
|
preprocessing := lPreprocessing;
|
||||||
end {if}
|
end {if}
|
||||||
else begin
|
else begin
|
||||||
Error(13);
|
Error(13);
|
||||||
|
@ -3294,6 +3301,7 @@ var
|
||||||
|
|
||||||
|
|
||||||
begin {PreProcess}
|
begin {PreProcess}
|
||||||
|
preprocessing := true;
|
||||||
lSuppressMacroExpansions := suppressMacroExpansions; {inhibit token printing}
|
lSuppressMacroExpansions := suppressMacroExpansions; {inhibit token printing}
|
||||||
suppressMacroExpansions := true;
|
suppressMacroExpansions := true;
|
||||||
lReportEOL := reportEOL; {we need to see eol's}
|
lReportEOL := reportEOL; {we need to see eol's}
|
||||||
|
@ -3693,6 +3701,7 @@ expandMacros := true;
|
||||||
reportEOL := lReportEOL; {restore flags}
|
reportEOL := lReportEOL; {restore flags}
|
||||||
suppressMacroExpansions := lSuppressMacroExpansions;
|
suppressMacroExpansions := lSuppressMacroExpansions;
|
||||||
skipping := tskipping;
|
skipping := tskipping;
|
||||||
|
preprocessing := false;
|
||||||
if nextLineNumber >= 0 then
|
if nextLineNumber >= 0 then
|
||||||
lineNumber := nextLineNumber;
|
lineNumber := nextLineNumber;
|
||||||
end; {PreProcess}
|
end; {PreProcess}
|
||||||
|
@ -4447,6 +4456,7 @@ customDefaultName := nil; {no custom default name}
|
||||||
pragmaKeepFile := nil; {no #pragma keep file so far}
|
pragmaKeepFile := nil; {no #pragma keep file so far}
|
||||||
doingFakeFile := false; {not doing a fake file}
|
doingFakeFile := false; {not doing a fake file}
|
||||||
doingDigitSequence := false; {not expecting a digit sequence}
|
doingDigitSequence := false; {not expecting a digit sequence}
|
||||||
|
preprocessing := false; {not preprocessing}
|
||||||
|
|
||||||
{error codes for lint messages}
|
{error codes for lint messages}
|
||||||
{if changed, also change maxLint}
|
{if changed, also change maxLint}
|
||||||
|
@ -5681,9 +5691,19 @@ case charKinds[ord(ch)] of
|
||||||
CheckIdentifier;
|
CheckIdentifier;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
digit : {numeric constants}
|
digit : {numeric constants}
|
||||||
DoNumber(false);
|
DoNumber(false);
|
||||||
|
|
||||||
|
ch_other: begin {other non-whitespace char (pp-token)}
|
||||||
|
token.kind := otherch;
|
||||||
|
token.class := otherCharacter;
|
||||||
|
token.ch := ch;
|
||||||
|
NextCh;
|
||||||
|
if skipping or preprocessing then
|
||||||
|
if not skipIllegalTokens then
|
||||||
|
Error(1);
|
||||||
|
end;
|
||||||
|
|
||||||
otherwise: Error(57);
|
otherwise: Error(57);
|
||||||
end; {case}
|
end; {case}
|
||||||
tokenEnd := currentChPtr; {record the end of the token}
|
tokenEnd := currentChPtr; {record the end of the token}
|
||||||
|
@ -5728,6 +5748,10 @@ if doingPPExpression then begin
|
||||||
end; {if}
|
end; {if}
|
||||||
if printMacroExpansions and not suppressMacroExpansions then
|
if printMacroExpansions and not suppressMacroExpansions then
|
||||||
PrintToken(token); {print the token stream}
|
PrintToken(token); {print the token stream}
|
||||||
|
if token.kind = otherch then
|
||||||
|
if not (skipping or preprocessing or suppressMacroExpansions)
|
||||||
|
or doingPPExpression then
|
||||||
|
Error(1);
|
||||||
end; {NextToken}
|
end; {NextToken}
|
||||||
|
|
||||||
|
|
||||||
|
|
104
Table.asm
104
Table.asm
|
@ -19,7 +19,7 @@ charKinds start character set
|
||||||
enum (illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc),0
|
enum (illegal,ch_special,ch_dash,ch_plus,ch_lt,ch_gt,ch_eq,ch_exc),0
|
||||||
enum (ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string)
|
enum (ch_and,ch_bar,ch_dot,ch_white,ch_eol,ch_eof,ch_char,ch_string)
|
||||||
enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon)
|
enum (ch_asterisk,ch_slash,ch_percent,ch_carot,ch_pound,ch_colon)
|
||||||
enum (ch_backslash,letter,digit)
|
enum (ch_backslash,ch_other,letter,digit)
|
||||||
|
|
||||||
! STANDARD
|
! STANDARD
|
||||||
dc i'ch_eof' nul
|
dc i'ch_eof' nul
|
||||||
|
@ -58,7 +58,7 @@ charKinds start character set
|
||||||
dc i'ch_exc' !
|
dc i'ch_exc' !
|
||||||
dc i'ch_string' "
|
dc i'ch_string' "
|
||||||
dc i'ch_pound' #
|
dc i'ch_pound' #
|
||||||
dc i'illegal' $
|
dc i'ch_other' $
|
||||||
dc i'ch_percent' %
|
dc i'ch_percent' %
|
||||||
dc i'ch_and' &
|
dc i'ch_and' &
|
||||||
dc i'ch_char' '
|
dc i'ch_char' '
|
||||||
|
@ -86,7 +86,7 @@ charKinds start character set
|
||||||
dc i'ch_eq' =
|
dc i'ch_eq' =
|
||||||
dc i'ch_gt' >
|
dc i'ch_gt' >
|
||||||
dc i'ch_special' ?
|
dc i'ch_special' ?
|
||||||
dc i'illegal' @
|
dc i'ch_other' @
|
||||||
dc i'letter' A
|
dc i'letter' A
|
||||||
dc i'letter' B
|
dc i'letter' B
|
||||||
dc i'letter' C
|
dc i'letter' C
|
||||||
|
@ -118,7 +118,7 @@ charKinds start character set
|
||||||
dc i'ch_special' ]
|
dc i'ch_special' ]
|
||||||
dc i'ch_carot' ^
|
dc i'ch_carot' ^
|
||||||
dc i'letter' _
|
dc i'letter' _
|
||||||
dc i'illegal' `
|
dc i'ch_other' `
|
||||||
dc i'letter' a
|
dc i'letter' a
|
||||||
dc i'letter' b
|
dc i'letter' b
|
||||||
dc i'letter' c
|
dc i'letter' c
|
||||||
|
@ -183,24 +183,24 @@ charKinds start character set
|
||||||
dc i'letter' gs
|
dc i'letter' gs
|
||||||
dc i'letter' rs
|
dc i'letter' rs
|
||||||
dc i'letter' us
|
dc i'letter' us
|
||||||
dc i'illegal' space
|
dc i'ch_other' space
|
||||||
dc i'illegal' !
|
dc i'ch_other' !
|
||||||
dc i'illegal' "
|
dc i'ch_other' "
|
||||||
dc i'illegal' #
|
dc i'ch_other' #
|
||||||
dc i'illegal' $
|
dc i'ch_other' $
|
||||||
dc i'illegal' %
|
dc i'ch_other' %
|
||||||
dc i'illegal' &
|
dc i'ch_other' &
|
||||||
dc i'letter' '
|
dc i'letter' '
|
||||||
dc i'illegal' (
|
dc i'ch_other' (
|
||||||
dc i'illegal' )
|
dc i'ch_other' )
|
||||||
dc i'illegal' *
|
dc i'ch_other' *
|
||||||
dc i'illegal' +
|
dc i'ch_other' +
|
||||||
dc i'illegal' ,
|
dc i'ch_other' ,
|
||||||
dc i'ch_special' -
|
dc i'ch_special' -
|
||||||
dc i'letter' .
|
dc i'letter' .
|
||||||
dc i'letter' /
|
dc i'letter' /
|
||||||
dc i'illegal' 0
|
dc i'ch_other' 0
|
||||||
dc i'illegal' 1
|
dc i'ch_other' 1
|
||||||
dc i'ch_special' 2
|
dc i'ch_special' 2
|
||||||
dc i'ch_special' 3
|
dc i'ch_special' 3
|
||||||
dc i'letter' 4
|
dc i'letter' 4
|
||||||
|
@ -209,49 +209,49 @@ charKinds start character set
|
||||||
dc i'letter' 7
|
dc i'letter' 7
|
||||||
dc i'letter' 8
|
dc i'letter' 8
|
||||||
dc i'letter' 9
|
dc i'letter' 9
|
||||||
dc i'illegal' :
|
dc i'ch_other' :
|
||||||
dc i'letter' ;
|
dc i'letter' ;
|
||||||
dc i'letter' <
|
dc i'letter' <
|
||||||
dc i'letter' =
|
dc i'letter' =
|
||||||
dc i'letter' >
|
dc i'letter' >
|
||||||
dc i'letter' ?
|
dc i'letter' ?
|
||||||
dc i'illegal' @
|
dc i'ch_other' @
|
||||||
dc i'illegal' A
|
dc i'ch_other' A
|
||||||
dc i'illegal' B
|
dc i'ch_other' B
|
||||||
dc i'illegal' C
|
dc i'ch_other' C
|
||||||
dc i'letter' D
|
dc i'letter' D
|
||||||
dc i'illegal' E
|
dc i'ch_other' E
|
||||||
dc i'letter' F
|
dc i'letter' F
|
||||||
dc i'ch_special' G
|
dc i'ch_special' G
|
||||||
dc i'ch_special' H
|
dc i'ch_special' H
|
||||||
dc i'illegal' I
|
dc i'ch_other' I
|
||||||
dc i'ch_white' J
|
dc i'ch_white' J
|
||||||
dc i'letter' K
|
dc i'letter' K
|
||||||
dc i'letter' L
|
dc i'letter' L
|
||||||
dc i'letter' M
|
dc i'letter' M
|
||||||
dc i'letter' N
|
dc i'letter' N
|
||||||
dc i'letter' O
|
dc i'letter' O
|
||||||
dc i'illegal' P
|
dc i'ch_other' P
|
||||||
dc i'illegal' Q
|
dc i'ch_other' Q
|
||||||
dc i'illegal' R
|
dc i'ch_other' R
|
||||||
dc i'illegal' S
|
dc i'ch_other' S
|
||||||
dc i'illegal' T
|
dc i'ch_other' T
|
||||||
dc i'illegal' U
|
dc i'ch_other' U
|
||||||
dc i'ch_special' V
|
dc i'ch_special' V
|
||||||
dc i'illegal' W
|
dc i'ch_other' W
|
||||||
dc i'letter' X
|
dc i'letter' X
|
||||||
dc i'letter' Y
|
dc i'letter' Y
|
||||||
dc i'illegal' Z
|
dc i'ch_other' Z
|
||||||
dc i'illegal' [
|
dc i'ch_other' [
|
||||||
dc i'illegal' \
|
dc i'ch_other' \
|
||||||
dc i'illegal' ]
|
dc i'ch_other' ]
|
||||||
dc i'letter' ^
|
dc i'letter' ^
|
||||||
dc i'letter' _
|
dc i'letter' _
|
||||||
dc i'illegal' `
|
dc i'ch_other' `
|
||||||
dc i'illegal' a
|
dc i'ch_other' a
|
||||||
dc i'illegal' b
|
dc i'ch_other' b
|
||||||
dc i'illegal' c
|
dc i'ch_other' c
|
||||||
dc i'illegal' d
|
dc i'ch_other' d
|
||||||
dc i'letter' e
|
dc i'letter' e
|
||||||
dc i'letter' f
|
dc i'letter' f
|
||||||
dc i'letter' g
|
dc i'letter' g
|
||||||
|
@ -263,22 +263,22 @@ charKinds start character set
|
||||||
dc i'letter' m
|
dc i'letter' m
|
||||||
dc i'letter' n
|
dc i'letter' n
|
||||||
dc i'letter' o
|
dc i'letter' o
|
||||||
dc i'illegal' p
|
dc i'ch_other' p
|
||||||
dc i'letter' q
|
dc i'letter' q
|
||||||
dc i'letter' r
|
dc i'letter' r
|
||||||
dc i'letter' s
|
dc i'letter' s
|
||||||
dc i'letter' t
|
dc i'letter' t
|
||||||
dc i'letter' u
|
dc i'letter' u
|
||||||
dc i'illegal' v
|
dc i'ch_other' v
|
||||||
dc i'illegal' w
|
dc i'ch_other' w
|
||||||
dc i'illegal' x
|
dc i'ch_other' x
|
||||||
dc i'illegal' y
|
dc i'ch_other' y
|
||||||
dc i'illegal' z
|
dc i'ch_other' z
|
||||||
dc i'illegal' {
|
dc i'ch_other' {
|
||||||
dc i'illegal' |
|
dc i'ch_other' |
|
||||||
dc i'illegal' }
|
dc i'ch_other' }
|
||||||
dc i'illegal' ~
|
dc i'ch_other' ~
|
||||||
dc i'illegal' rub
|
dc i'ch_other' rub
|
||||||
end
|
end
|
||||||
|
|
||||||
charSym start single character symbols
|
charSym start single character symbols
|
||||||
|
|
Loading…
Reference in New Issue
Block a user