mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-03-05 14:29:47 +00:00
Allow ORCA/C-specific keywords to be disabled via a new pragma.
This allows those tokens (asm, comp, extended, pascal, and segment) to be used as identifiers, consistent with the C standards. A new pragma (#pragma extensions) is introduced to control this. It might also be used for other things in the future.
This commit is contained in:
parent
b2edeb4ad1
commit
a1d57c4db3
@ -18,7 +18,7 @@ uses CCommon, MM, Scanner, Symbol, CGI;
|
||||
{$segment 'SCANNER'}
|
||||
|
||||
const
|
||||
symFileVersion = 24; {version number of .sym file format}
|
||||
symFileVersion = 25; {version number of .sym file format}
|
||||
|
||||
var
|
||||
inhibitHeader: boolean; {should .sym includes be blocked?}
|
||||
@ -891,6 +891,8 @@ procedure EndInclude {chPtr: ptr};
|
||||
p_unix: WriteByte(ord(unix_1));
|
||||
|
||||
p_fenv_access: WriteByte(ord(fenvAccess));
|
||||
|
||||
p_extensions: WriteByte(ord(extendedKeywords));
|
||||
|
||||
end; {case}
|
||||
end; {if}
|
||||
@ -1559,6 +1561,8 @@ var
|
||||
p_unix: unix_1 := boolean(ReadByte);
|
||||
|
||||
p_fenv_access: fenvAccess := boolean(ReadByte);
|
||||
|
||||
p_extensions: extendedKeywords := boolean(ReadByte);
|
||||
|
||||
otherwise: begin
|
||||
PurgeSymbols;
|
||||
|
28
Scanner.pas
28
Scanner.pas
@ -39,7 +39,8 @@ type
|
||||
p_nda,p_debug,p_lint,p_memorymodel,p_expand,
|
||||
p_optimize,p_stacksize,p_toolparms,p_databank,p_rtl,
|
||||
p_noroot,p_path,p_ignore,p_segment,p_nba,
|
||||
p_xcmd,p_unix,p_line,p_fenv_access,p_endofenum);
|
||||
p_xcmd,p_unix,p_line,p_fenv_access,p_extensions,
|
||||
p_endofenum);
|
||||
|
||||
{preprocessor types}
|
||||
{------------------}
|
||||
@ -91,6 +92,8 @@ var
|
||||
c99Scope: boolean; {follow C99 rules for block scopes?}
|
||||
looseTypeChecks: boolean; {loosen some standard type checks?}
|
||||
|
||||
extendedKeywords: boolean; {recognize ORCA/C-specific keywords?}
|
||||
|
||||
{---------------------------------------------------------------}
|
||||
|
||||
procedure DoDefaultsDotH;
|
||||
@ -3269,6 +3272,16 @@ if ch in ['a','d','e','i','l','p','u','w'] then begin
|
||||
if token.kind <> eolsy then
|
||||
Error(11);
|
||||
end {else if}
|
||||
else if token.name^ = 'extensions' then begin
|
||||
{ extensions bits: }
|
||||
{ 1 - extended ORCA/C keywords }
|
||||
FlagPragmas(p_extensions);
|
||||
NumericDirective;
|
||||
val := long(expressionValue).lsw;
|
||||
extendedKeywords := odd(val);
|
||||
if token.kind <> eolsy then
|
||||
Error(11);
|
||||
end {else if}
|
||||
else if token.name^ = 'unix' then begin
|
||||
{ unix bits: }
|
||||
{ 1 - int is 32 bits }
|
||||
@ -4174,6 +4187,7 @@ allowSlashSlashComments := true; {allow // comments (C99)}
|
||||
allowMixedDeclarations := true; {allow mixed declarations & stmts (C99)}
|
||||
c99Scope := true; {follow C99 rules for block scopes}
|
||||
looseTypeChecks := true; {loosen some standard type checks}
|
||||
extendedKeywords := true; {allow extended ORCA/C keywords}
|
||||
foundFunction := false; {no functions found so far}
|
||||
fileList := nil; {no included files}
|
||||
gettingFileName := false; {not in GetFileName}
|
||||
@ -4529,11 +4543,13 @@ if expandMacros then {handle macro expansions}
|
||||
if workString[1] in ['_','a'..'g','i','l','p','r'..'w'] then
|
||||
for rword := wordHash[ord(workString[1])-ord('_')] to
|
||||
pred(wordHash[ord(succ(workString[1]))-ord('_')]) do
|
||||
if reservedWords[rword] = workString then begin
|
||||
token.kind := rword;
|
||||
token.class := reservedWord;
|
||||
goto 1;
|
||||
end; {if}
|
||||
if reservedWords[rword] = workString then
|
||||
if extendedKeywords or not (rword in
|
||||
[asmsy,compsy,extendedsy,pascalsy,segmentsy]) then begin
|
||||
token.kind := rword;
|
||||
token.class := reservedWord;
|
||||
goto 1;
|
||||
end; {if}
|
||||
token.symbolPtr := nil; {see if it's a typedef name}
|
||||
if FindSymbol(token,allSpaces,false,false) <> nil then begin
|
||||
if token.symbolPtr^.class = typedefsy then
|
||||
|
19
cc.notes
19
cc.notes
@ -50,6 +50,9 @@ Updated by Stephen Heumann and Kelvin Sherlock, 2017-2022
|
||||
16. New option to include a custom file before processing the
|
||||
source file. See "Custom Pre-Include File."
|
||||
|
||||
17. New pragma for controlling ORCA/C extensions. See "#pragma
|
||||
extensions."
|
||||
|
||||
2.1.1 B3 1. Bugs squashed. See bug notes, below.
|
||||
|
||||
2.1.0 1. Bugs squashed. See bug notes, below.
|
||||
@ -129,6 +132,8 @@ Identifiers may now contain universal character names, a type of escape sequence
|
||||
|
||||
Several new reserved words (keywords) added in the C99 or C11 standards are now supported. For information on what these are and how they are used, see "New Language Features," below.
|
||||
|
||||
The recognition of ORCA/C-specific reserved words can now be disabled, allowing them to be used as identifiers. See "#pragma extensions," below.
|
||||
|
||||
Certain alternate reserved symbols known as digraphs are now supported. See "New Language Features," below.
|
||||
|
||||
p. 237
|
||||
@ -175,7 +180,7 @@ p. 254
|
||||
|
||||
The #error directive may be followed by any sequence of preprocessing tokens, not just a string constant.
|
||||
|
||||
ORCA/C now supports several standard pragmas of the form "#pragma STDC ...". See "New Language Features," below.
|
||||
ORCA/C now supports several standard pragmas of the form "#pragma STDC ...", as well as a new ORCA/C-specific pragma, #pragma extensions. See "New Language Features" and "#pragma extensions," below.
|
||||
|
||||
p. 256
|
||||
|
||||
@ -636,6 +641,18 @@ ORCA/C can now detect several elements of C syntax that were allowed in C89 but
|
||||
If #pragma lint bit 7 (a value of 128) is set, ORCA/C detects some situations where a function with a non-void return type may return an unpredictable value, either by executing a return statement with no value or by executing to the end of the function with no return statement. (The former case is also detected by #pragma lint bit 6.) It also detects some situations where a _Noreturn function could return. Note that these checks only detect some cases of these problems, not all of them. Also, they may report a potential problem in some situations where the code at the end of a function is not actually reachable.
|
||||
|
||||
|
||||
#pragma extensions
|
||||
------------------
|
||||
|
||||
ORCA/C supports certain extensions that are not part of the standard C language. A new pragma has been introduced to control whether some of these extensions are enabled. The format is:
|
||||
|
||||
#pragma extensions parm
|
||||
|
||||
The parameter must be an integer constant, which is treated as a set of flags. Currently, one flag bit is defined:
|
||||
|
||||
If bit 0 (a value of 1) is set, then asm, comp, extended, pascal, and segment are treated as reserved words (keywords), with the meanings specified in the ORCA/C manual. If bit 0 is clear, then those tokens are instead treated as identifiers, as required by the C standards. Bit 0 is set by default. Note that toolbox headers use these keywords, so bit 0 must be set when they are included.
|
||||
|
||||
|
||||
File Names in Error Messages
|
||||
----------------------------
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user