* Support for pascal constant expr in compile time expr, is now only allowed in mode Delphi

+ Warning for undefined compile time var in mode macpas
  * Support for some turbo directives in mode macpas
  * Support for Metrowerks style DEFINED xxx
This commit is contained in:
olle 2005-03-20 18:13:34 +00:00
parent e4c09a152b
commit 7cb6368f12
4 changed files with 395 additions and 372 deletions

View File

@ -201,7 +201,7 @@ scan_e_keyword_cant_be_a_macro=02028_E_Keyword redefined as macro has no effect
% You cannot redefine keywords with macros.
scan_f_macro_buffer_overflow=02029_F_Macro buffer overflow while reading or expanding a macro
% Your macro or it's result was too long for the compiler.
scan_w_macro_deep_ten=02030_W_Expanding of macros exceeds a depth of 16.
scan_w_macro_too_deep=02030_W_Expanding of macros exceeds a depth of 16.
% When expanding a macro, macros have been nested to a level of 16.
% The compiler will expand no further, since this may be a sign that
% recursion is used.
@ -300,13 +300,15 @@ scan_e_too_many_push=02063_F_Too many levels of PUSH
% A maximum of 20 levels is allowed. This error occur only in mode MacPas.
scan_e_too_many_pop=02064_E_A POP without a preceding PUSH
% This error occur only in mode MacPas.
scan_e_error_macro_lacks_value=02065_E_Macro "$1" does not have any value
% Thus the conditional compiling expression cannot be evaluated.
scan_e_error_macro_lacks_value=02065_E_Macro or compile time variable "$1" does not have any value
% Thus the conditional compile time expression cannot be evaluated.
scan_e_wrong_switch_toggle_default=02066_E_Wrong switch toggle, use ON/OFF/DEFAULT or +/-/*
% You need to use ON or OFF or DEFAULT or a + or - or * to toggle the switch
scan_e_mode_switch_not_allowed=02067_E_Mode switch "$1" not allowed here
% A mode switch has already been encountered, or, in case of option -Mmacpas,
% a mode switch occur after UNIT.
scan_e_error_macro_undefined=02068_E_Compile time variable "$1" is not defined.
% Thus the conditional compile time expression cannot be evaluated.
% \end{description}
#
# Parser

View File

@ -45,7 +45,7 @@ const
scan_i_user_defined=02027;
scan_e_keyword_cant_be_a_macro=02028;
scan_f_macro_buffer_overflow=02029;
scan_w_macro_deep_ten=02030;
scan_w_macro_too_deep=02030;
scan_w_wrong_styled_switch=02031;
scan_d_handling_switch=02032;
scan_c_endif_found=02033;
@ -83,6 +83,7 @@ const
scan_e_error_macro_lacks_value=02065;
scan_e_wrong_switch_toggle_default=02066;
scan_e_mode_switch_not_allowed=02067;
scan_e_error_macro_undefined=02068;
parser_e_syntax_error=03000;
parser_e_dont_nest_interrupt=03004;
parser_w_proc_directive_ignored=03005;
@ -650,9 +651,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 38069;
MsgTxtSize = 38145;
MsgIdxMax : array[1..20] of longint=(
19,68,214,59,57,46,100,20,35,60,
19,69,214,59,57,46,100,20,35,60,
40,1,1,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

View File

@ -398,7 +398,7 @@ implementation
inc(macrocount);
if macrocount>max_macro_nesting then
begin
Message(scan_w_macro_deep_ten);
Message(scan_w_macro_too_deep);
break;
end;
@ -423,7 +423,12 @@ implementation
break;
end
else
break;
begin
if m_mac in aktmodeswitches then
Message1(scan_e_error_macro_undefined, result)
else
break;
end;
if mac.is_compiler_var then
break;
@ -438,6 +443,7 @@ implementation
srsymtable : tsymtable;
l : longint;
w : integer;
hasKlammer: Boolean;
begin
if current_scanner.preproc_token=_ID then
@ -450,9 +456,13 @@ implementation
begin
preproc_consume(_LKLAMMER);
current_scanner.skipspace;
hasKlammer:= true;
end
else if (m_mac in aktmodeswitches) then
hasKlammer:= false
else
Message(scan_e_error_in_preproc_expr);
if current_scanner.preproc_token =_ID then
begin
hs := current_scanner.preproc_pattern;
@ -470,10 +480,12 @@ implementation
end
else
Message(scan_e_error_in_preproc_expr);
if current_scanner.preproc_token =_RKLAMMER then
preproc_consume(_RKLAMMER)
else
Message(scan_e_error_in_preproc_expr);
if hasKlammer then
if current_scanner.preproc_token =_RKLAMMER then
preproc_consume(_RKLAMMER)
else
Message(scan_e_error_in_preproc_expr);
end
else
if (m_mac in aktmodeswitches) and (current_scanner.preproc_pattern='UNDEFINED') then
@ -630,38 +642,39 @@ implementation
hs:=preproc_substitutedtoken;
{ Default is to return the original symbol }
read_factor:=hs;
if searchsym(current_scanner.preproc_pattern,srsym,srsymtable) then
begin
case srsym.typ of
constsym :
begin
with tconstsym(srsym) do
begin
case consttyp of
constord :
begin
case consttype.def.deftype of
orddef:
begin
if is_integer(consttype.def) or is_boolean(consttype.def) then
read_factor:=tostr(value.valueord)
else
if is_char(consttype.def) then
read_factor:=chr(value.valueord);
end;
enumdef:
read_factor:=tostr(value.valueord)
if (m_delphi in aktmodeswitches) then
if searchsym(current_scanner.preproc_pattern,srsym,srsymtable) then
begin
case srsym.typ of
constsym :
begin
with tconstsym(srsym) do
begin
case consttyp of
constord :
begin
case consttype.def.deftype of
orddef:
begin
if is_integer(consttype.def) or is_boolean(consttype.def) then
read_factor:=tostr(value.valueord)
else
if is_char(consttype.def) then
read_factor:=chr(value.valueord);
end;
enumdef:
read_factor:=tostr(value.valueord)
end;
end;
end;
conststring :
read_factor := upper(pchar(value.valueordptr))
conststring :
read_factor := upper(pchar(value.valueordptr))
end;
end;
end;
end;
enumsym :
read_factor:=tostr(tenumsym(srsym).value);
end;
enumsym :
read_factor:=tostr(tenumsym(srsym).value);
end;
end;
end;
preproc_consume(_ID);
current_scanner.skipspace;
@ -2506,7 +2519,7 @@ implementation
exit;
end
else
Message(scan_w_macro_deep_ten);
Message(scan_w_macro_too_deep);
end;
end;
end;
@ -3291,31 +3304,35 @@ exit_label:
turbo_scannerdirectives:=TDictionary.Create;
mac_scannerdirectives:=TDictionary.Create;
{ Default directives and conditionals for all modes }
AddDirective('I',directive_all, @dir_include);
{ Common directives and conditionals }
AddDirective('DEFINE',directive_turbo, @dir_define);
AddDirective('UNDEF',directive_turbo, @dir_undef);
AddDirective('I',directive_all, @dir_include);
AddDirective('DEFINE',directive_all, @dir_define);
AddDirective('UNDEF',directive_all, @dir_undef);
AddConditional('IF',directive_all, @dir_if);
AddConditional('IFDEF',directive_all, @dir_ifdef);
AddConditional('IFNDEF',directive_all, @dir_ifndef);
AddConditional('ELSE',directive_all, @dir_else);
AddConditional('ELSEIF',directive_all, @dir_elseif);
AddConditional('ENDIF',directive_all, @dir_endif);
{ Directives and conditionals for all modes except mode macpas}
AddDirective('INCLUDE',directive_turbo, @dir_include);
AddDirective('LIBPREFIX',directive_turbo, @dir_libprefix);
AddDirective('LIBSUFFIX',directive_turbo, @dir_libsuffix);
AddDirective('EXTENSION',directive_turbo, @dir_extension);
AddConditional('ELSE',directive_turbo, @dir_else);
AddConditional('ELSEIF',directive_turbo, @dir_elseif);
AddConditional('ENDIF',directive_turbo, @dir_endif);
AddConditional('IFEND',directive_turbo, @dir_endif);
AddConditional('IF',directive_turbo, @dir_if);
AddConditional('IFDEF',directive_turbo, @dir_ifdef);
AddConditional('IFNDEF',directive_turbo, @dir_ifndef);
AddConditional('IFOPT',directive_turbo, @dir_ifopt);
{ Default Mac directives and conditionals: }
{ Directives and conditionals for mode macpas: }
AddDirective('SETC',directive_mac, @dir_setc);
AddDirective('DEFINEC',directive_mac, @dir_define);
AddDirective('UNDEFC',directive_mac, @dir_undef);
AddConditional('IFC',directive_mac, @dir_if);
AddConditional('ELSEC',directive_mac, @dir_else);
AddConditional('ELIFC',directive_mac, @dir_elseif);
AddConditional('ENDC',directive_mac, @dir_endif);
end;
@ -3331,7 +3348,13 @@ exit_label:
end.
{
$Log$
Revision 1.101 2005-02-27 17:15:01 peter
Revision 1.102 2005-03-20 18:13:34 olle
* Support for pascal constant expr in compile time expr, is now only allowed in mode Delphi
+ Warning for undefined compile time var in mode macpas
* Support for some turbo directives in mode macpas
* Support for Metrowerks style DEFINED xxx
Revision 1.101 2005/02/27 17:15:01 peter
Support constants and IN operator in preprocessor patch by Christian Iversen
Revision 1.100 2005/02/14 17:13:07 peter