mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-02 19:29:21 +00:00
Save string representation of macros defined on command line.
This is necessary for correct operation of the # and ## preprocessor operators on the tokens from such macros. Integers with a sign character still have the non-standard property of being treated as a single token, so they cannot be used with ##, but in most cases such uses will now give an error.
This commit is contained in:
parent
2a9ec8fc43
commit
da978932bf
27
Scanner.pas
27
Scanner.pas
@ -4316,17 +4316,26 @@ repeat
|
|||||||
new(mp); {form the macro table entry}
|
new(mp); {form the macro table entry}
|
||||||
mp^.name := GetWord;
|
mp^.name := GetWord;
|
||||||
mp^.parameters := -1;
|
mp^.parameters := -1;
|
||||||
mp^.tokens := nil;
|
|
||||||
mp^.readOnly := false;
|
mp^.readOnly := false;
|
||||||
mp^.saved := true;
|
mp^.saved := true;
|
||||||
bp := pointer(ord4(macros) + hash(mp^.name));
|
bp := pointer(ord4(macros) + hash(mp^.name));
|
||||||
mp^.next := bp^;
|
mp^.next := bp^;
|
||||||
bp^ := mp;
|
bp^ := mp;
|
||||||
|
new(mp^.tokens);
|
||||||
|
with mp^.tokens^ do begin
|
||||||
|
next := nil;
|
||||||
|
tokenString := @'';
|
||||||
|
expandEnabled := true;
|
||||||
|
end; {with}
|
||||||
token.kind := intconst; {create the default value}
|
token.kind := intconst; {create the default value}
|
||||||
token.numString := nil;
|
token.numString := @oneStr;
|
||||||
token.class := intConstant;
|
token.class := intConstant;
|
||||||
token.ival := 1;
|
token.ival := 1;
|
||||||
|
oneStr := '1';
|
||||||
|
mp^.tokens^.tokenStart := @oneStr[1];
|
||||||
|
mp^.tokens^.tokenEnd := pointer(ord4(@oneStr[1])+1);
|
||||||
if lch = '=' then begin
|
if lch = '=' then begin
|
||||||
|
mp^.tokens^.tokenStart := cp;
|
||||||
NextCh; {record the value}
|
NextCh; {record the value}
|
||||||
token.numString := nil;
|
token.numString := nil;
|
||||||
if charKinds[ord(lch)] = letter then begin
|
if charKinds[ord(lch)] = letter then begin
|
||||||
@ -4341,6 +4350,7 @@ repeat
|
|||||||
if lch in ['.','0'..'9'] then begin
|
if lch in ['.','0'..'9'] then begin
|
||||||
token.name := GetWord;
|
token.name := GetWord;
|
||||||
DoNumber(true);
|
DoNumber(true);
|
||||||
|
token.numString := @'?';
|
||||||
if negative then
|
if negative then
|
||||||
case token.class of
|
case token.class of
|
||||||
intConstant : token.ival := -token.ival;
|
intConstant : token.ival := -token.ival;
|
||||||
@ -4361,22 +4371,17 @@ repeat
|
|||||||
end {else if}
|
end {else if}
|
||||||
else if lch in ['.','0'..'9'] then begin
|
else if lch in ['.','0'..'9'] then begin
|
||||||
token.name := GetWord;
|
token.name := GetWord;
|
||||||
|
saveNumber := true;
|
||||||
DoNumber(true);
|
DoNumber(true);
|
||||||
|
saveNumber := false;
|
||||||
end {else if}
|
end {else if}
|
||||||
else if lch = '"' then
|
else if lch = '"' then
|
||||||
GetString
|
GetString
|
||||||
else
|
else
|
||||||
FlagErrorAndSkip;
|
FlagErrorAndSkip;
|
||||||
|
mp^.tokens^.tokenEnd := ptr(ord4(cp)-1);
|
||||||
end; {if}
|
end; {if}
|
||||||
new(mp^.tokens); {add the value to the definition}
|
mp^.tokens^.token := token; {add the value to the definition}
|
||||||
with mp^.tokens^ do begin
|
|
||||||
next := nil;
|
|
||||||
tokenString := @'';
|
|
||||||
expandEnabled := true;
|
|
||||||
tokenStart := nil;
|
|
||||||
tokenEnd := nil;
|
|
||||||
end; {with}
|
|
||||||
mp^.tokens^.token := token;
|
|
||||||
end {if}
|
end {if}
|
||||||
else if lch in ['i','I'] then begin
|
else if lch in ['i','I'] then begin
|
||||||
NextCh; {get the pathname}
|
NextCh; {get the pathname}
|
||||||
|
Loading…
Reference in New Issue
Block a user