Recognize the new keywords from C99 and C11 as such.

Specifically, the following will now be tokenized as keywords:

_Alignas
_Alignof
_Atomic
_Bool
_Complex
_Generic
_Imaginary
_Noreturn
_Static_assert
_Thread_local
restrict

('inline' was also added as a standard keyword in C99, but ORCA/C already treated it as such.)

The parser currently has no support for any of these keywords, so for now errors will still be generated if they are used, but this is a first step toward adding support for them.
This commit is contained in:
Stephen Heumann 2020-01-03 22:47:53 -06:00
parent 9030052616
commit 0184e3db7b
6 changed files with 104 additions and 62 deletions

View File

@ -158,14 +158,16 @@ type
intconst,uintconst,longconst,ulongconst,doubleconst, intconst,uintconst,longconst,ulongconst,doubleconst,
stringconst, stringconst,
{reserved words} {reserved words}
_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy,
_Genericsy,_Imaginarysy,_Noreturnsy,_Static_assertsy,_Thread_localsy,
autosy,asmsy,breaksy,casesy,charsy, autosy,asmsy,breaksy,casesy,charsy,
continuesy,constsy,compsy,defaultsy,dosy, continuesy,constsy,compsy,defaultsy,dosy,
doublesy,elsesy,enumsy,externsy,extendedsy, doublesy,elsesy,enumsy,externsy,extendedsy,
floatsy,forsy,gotosy,ifsy,intsy, floatsy,forsy,gotosy,ifsy,intsy,
inlinesy,longsy,pascalsy,registersy,returnsy, inlinesy,longsy,pascalsy,registersy,restrictsy,
shortsy,sizeofsy,staticsy,structsy,switchsy, returnsy,shortsy,sizeofsy,staticsy,structsy,
segmentsy,signedsy,typedefsy,unionsy,unsignedsy, switchsy,segmentsy,signedsy,typedefsy,unionsy,
voidsy,volatilesy,whilesy, unsignedsy,voidsy,volatilesy,whilesy,
{reserved symbols} {reserved symbols}
excch,percentch,carotch,andch,asteriskch, excch,percentch,carotch,andch,asteriskch,
minusch,plusch,eqch,tildech,barch, minusch,plusch,eqch,tildech,barch,

View File

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

View File

@ -723,14 +723,16 @@ case token.kind of
write('"'); write('"');
end; end;
_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy,
_Genericsy,_Imaginarysy,_Noreturnsy,_Static_assertsy,_Thread_localsy,
autosy,asmsy,breaksy,casesy,charsy, autosy,asmsy,breaksy,casesy,charsy,
continuesy,constsy,compsy,defaultsy,dosy, continuesy,constsy,compsy,defaultsy,dosy,
doublesy,elsesy,enumsy,externsy,extendedsy, doublesy,elsesy,enumsy,externsy,extendedsy,
floatsy,forsy,gotosy,ifsy,intsy, floatsy,forsy,gotosy,ifsy,intsy,
inlinesy,longsy,pascalsy,registersy,returnsy, inlinesy,longsy,pascalsy,registersy,restrictsy,
shortsy,sizeofsy,staticsy,structsy,switchsy, returnsy,shortsy,sizeofsy,staticsy,structsy,
segmentsy,signedsy,typedefsy,unionsy,unsignedsy, switchsy,segmentsy,signedsy,typedefsy,unionsy,
voidsy,volatilesy,whilesy: unsignedsy,voidsy,volatilesy,whilesy:
write(reservedWords[token.kind]); write(reservedWords[token.kind]);
tildech,questionch,lparench,rparench,lbrackch,rbrackch,lbracech, tildech,questionch,lparench,rparench,lbrackch,rbrackch,lbracech,
@ -3641,9 +3643,9 @@ if expandMacros then {handle macro expansions}
end; end;
end; {if} end; {if}
{see if it's a reserved word} {see if it's a reserved word}
if workString[1] in ['a'..'g','i','l','p','r'..'w'] then if workString[1] in ['_','a'..'g','i','l','p','r'..'w'] then
for rword := wordHash[ord(workString[1])-ord('a')] to for rword := wordHash[ord(workString[1])-ord('_')] to
pred(wordHash[ord(succ(workString[1]))-ord('a')]) do pred(wordHash[ord(succ(workString[1]))-ord('_')]) do
if reservedWords[rword] = workString then begin if reservedWords[rword] = workString then begin
token.kind := rword; token.kind := rword;
token.class := reservedWord; token.class := reservedWord;

130
Table.asm
View File

@ -286,14 +286,16 @@ charSym start single character symbols
enum (intconst,uintconst,longconst,ulongconst,doubleconst) enum (intconst,uintconst,longconst,ulongconst,doubleconst)
enum stringconst enum stringconst
! reserved words ! reserved words
enum (_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy)
enum (_Genericsy,_Imaginarysy,_Noreturnsy,_Static_assertsy,_Thread_localsy)
enum (autosy,asmsy,breaksy,casesy,charsy) enum (autosy,asmsy,breaksy,casesy,charsy)
enum (continuesy,constsy,compsy,defaultsy,dosy) enum (continuesy,constsy,compsy,defaultsy,dosy)
enum (doublesy,elsesy,enumsy,externsy,extendedsy) enum (doublesy,elsesy,enumsy,externsy,extendedsy)
enum (floatsy,forsy,gotosy,ifsy,intsy) enum (floatsy,forsy,gotosy,ifsy,intsy)
enum (inlinesy,longsy,pascalsy,registersy,returnsy) enum (inlinesy,longsy,pascalsy,registersy,restrictsy)
enum (shortsy,sizeofsy,staticsy,structsy,switchsy) enum (returnsy,shortsy,sizeofsy,staticsy,structsy)
enum (segmentsy,signedsy,typedefsy,unionsy,unsignedsy) enum (switchsy,segmentsy,signedsy,typedefsy,unionsy)
enum (voidsy,volatilesy,whilesy) enum (unsignedsy,voidsy,volatilesy,whilesy)
! reserved symbols ! reserved symbols
enum (excch,percentch,carotch,andch,asteriskch) enum (excch,percentch,carotch,andch,asteriskch)
enum (minusch,plusch,eqch,tildech,barch) enum (minusch,plusch,eqch,tildech,barch)
@ -355,6 +357,16 @@ icp start in comming priority for expression
dc i1'200' ulongconst dc i1'200' ulongconst
dc i1'200' doubleconst dc i1'200' doubleconst
dc i1'200' stringconst dc i1'200' stringconst
dc i1'200' _Alignassy
dc i1'200' _Alignofsy
dc i1'200' _Atomicsy
dc i1'200' _Boolsy
dc i1'200' _Complexsy
dc i1'200' _Genericsy
dc i1'200' _Imaginarysy
dc i1'200' _Noreturnsy
dc i1'200' _Static_assertsy
dc i1'200' _Thread_localsy
dc i1'200' autosy dc i1'200' autosy
dc i1'200' asmsy dc i1'200' asmsy
dc i1'200' breaksy dc i1'200' breaksy
@ -379,6 +391,7 @@ icp start in comming priority for expression
dc i1'200' longsy dc i1'200' longsy
dc i1'200' pascalsy dc i1'200' pascalsy
dc i1'200' registersy dc i1'200' registersy
dc i1'200' restrictsy
dc i1'200' returnsy dc i1'200' returnsy
dc i1'200' shortsy dc i1'200' shortsy
dc i1'16' sizeofsy dc i1'16' sizeofsy
@ -509,6 +522,16 @@ isp start in stack priority for expression
dc i1'0' ulongconst dc i1'0' ulongconst
dc i1'0' doubleconst dc i1'0' doubleconst
dc i1'0' stringconst dc i1'0' stringconst
dc i1'0' _Alignassy
dc i1'0' _Alignofsy
dc i1'0' _Atomicsy
dc i1'0' _Boolsy
dc i1'0' _Complexsy
dc i1'0' _Genericsy
dc i1'0' _Imaginarysy
dc i1'0' _Noreturnsy
dc i1'0' _Static_assertsy
dc i1'0' _Thread_localsy
dc i1'0' autosy dc i1'0' autosy
dc i1'0' asmsy dc i1'0' asmsy
dc i1'0' breaksy dc i1'0' breaksy
@ -533,6 +556,7 @@ isp start in stack priority for expression
dc i1'0' longsy dc i1'0' longsy
dc i1'0' pascalsy dc i1'0' pascalsy
dc i1'0' registersy dc i1'0' registersy
dc i1'0' restrictsy
dc i1'0' returnsy dc i1'0' returnsy
dc i1'0' shortsy dc i1'0' shortsy
dc i1'16' sizeofsy dc i1'16' sizeofsy
@ -798,44 +822,55 @@ nopcodes start
end end
reservedWords start reserved word names reservedWords start reserved word names
str8 auto str14 _Alignas
str8 asm str14 _Alignof
str8 break str14 _Atomic
str8 case str14 _Bool
str8 char str14 _Complex
str8 continue str14 _Generic
str8 const str14 _Imaginary
str8 comp str14 _Noreturn
str8 default str14 _Static_assert
str8 do str14 _Thread_local
str8 double str14 auto
str8 else str14 asm
str8 enum str14 break
str8 extern str14 case
str8 extended str14 char
str8 float str14 continue
str8 for str14 const
str8 goto str14 comp
str8 if str14 default
str8 int str14 do
str8 inline str14 double
str8 long str14 else
str8 pascal str14 enum
str8 register str14 extern
str8 return str14 extended
str8 short str14 float
str8 sizeof str14 for
str8 static str14 goto
str8 struct str14 if
str8 switch str14 int
str8 segment str14 inline
str8 signed str14 long
str8 typedef str14 pascal
str8 union str14 register
str8 unsigned str14 restrict
str8 void str14 return
str8 volatile str14 short
str8 while str14 sizeof
str14 static
str14 struct
str14 switch
str14 segment
str14 signed
str14 typedef
str14 union
str14 unsigned
str14 void
str14 volatile
str14 while
end end
ropcodes start ropcodes start
@ -860,15 +895,18 @@ wordHash start reserved word hash table
enum (intconst,uintconst,longconst,ulongconst,doubleconst) enum (intconst,uintconst,longconst,ulongconst,doubleconst)
enum stringconst enum stringconst
! reserved words ! reserved words
enum (_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy)
enum (_Genericsy,_Imaginarysy,_Noreturnsy,_Static_assertsy,_Thread_localsy)
enum (autosy,asmsy,breaksy,casesy,charsy) enum (autosy,asmsy,breaksy,casesy,charsy)
enum (continuesy,constsy,compsy,defaultsy,dosy) enum (continuesy,constsy,compsy,defaultsy,dosy)
enum (doublesy,elsesy,enumsy,externsy,extendedsy) enum (doublesy,elsesy,enumsy,externsy,extendedsy)
enum (floatsy,forsy,gotosy,ifsy,intsy) enum (floatsy,forsy,gotosy,ifsy,intsy)
enum (inlinesy,longsy,pascalsy,registersy,returnsy) enum (inlinesy,longsy,pascalsy,registersy,restrictsy)
enum (shortsy,sizeofsy,staticsy,structsy,switchsy) enum (returnsy,shortsy,sizeofsy,staticsy,structsy)
enum (segmentsy,signedsy,typedefsy,unionsy,unsignedsy) enum (switchsy,segmentsy,signedsy,typedefsy,unionsy)
enum (voidsy,volatilesy,whilesy,succwhilesy) enum (unsignedsy,voidsy,volatilesy,whilesy,succwhilesy)
dc i'_Alignassy,autosy'
dc i'autosy,breaksy,casesy,defaultsy,elsesy,floatsy' dc i'autosy,breaksy,casesy,defaultsy,elsesy,floatsy'
dc i'gotosy,ifsy,ifsy,longsy,longsy,longsy' dc i'gotosy,ifsy,ifsy,longsy,longsy,longsy'
dc i'pascalsy,pascalsy,pascalsy,pascalsy,registersy,registersy' dc i'pascalsy,pascalsy,pascalsy,pascalsy,registersy,registersy'

View File

@ -17,8 +17,8 @@
MEND MEND
MACRO MACRO
&LAB STR8 &STR &LAB STR14 &STR
&LAB DC I1'L:A&SYSCNT' &LAB DC I1'L:A&SYSCNT'
A&SYSCNT DC C'&STR' A&SYSCNT DC C'&STR'
DS 8-L:A&SYSCNT DS 14-L:A&SYSCNT
MEND MEND

View File

@ -20,8 +20,8 @@ var
{----------------} {----------------}
charKinds: array[minChar..maxChar] of charEnum; {character kinds} charKinds: array[minChar..maxChar] of charEnum; {character kinds}
charSym: array[minChar..maxChar] of tokenEnum; {symbols for single char symbols} charSym: array[minChar..maxChar] of tokenEnum; {symbols for single char symbols}
reservedWords: array[autosy..whilesy] of string[8]; {reserved word strings} reservedWords: array[_Alignassy..whilesy] of string[14]; {reserved word strings}
wordHash: array[0..23] of tokenEnum; {for hashing reserved words} wordHash: array[0..25] of tokenEnum; {for hashing reserved words}
{from ASM.PAS} {from ASM.PAS}
{------------} {------------}