compiler: use try_consume_unitsym for except variable parse. this is needed to reduce maintenance cost for later unit identifier search changes

git-svn-id: trunk@18826 -
This commit is contained in:
paul 2011-08-24 10:54:17 +00:00
parent 4c403baa85
commit 8309809a0d
4 changed files with 18 additions and 21 deletions

View File

@ -88,7 +88,7 @@ interface
function consume_sym(var srsym:tsym;var srsymtable:TSymtable):boolean;
function consume_sym_orgid(var srsym:tsym;var srsymtable:TSymtable;var s : string):boolean;
function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume : ttoken):boolean;
function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume:ttoken;consume_id:boolean):boolean;
function try_consume_hintdirective(var symopt:tsymoptions; var deprecatedmsg:pshortstring):boolean;
@ -191,7 +191,7 @@ implementation
end;
searchsym(pattern,srsym,srsymtable);
{ handle unit specification like System.Writeln }
try_consume_unitsym(srsym,srsymtable,t);
try_consume_unitsym(srsym,srsymtable,t,true);
{ if nothing found give error and return errorsym }
if assigned(srsym) then
check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg)
@ -224,7 +224,7 @@ implementation
end;
searchsym(pattern,srsym,srsymtable);
{ handle unit specification like System.Writeln }
try_consume_unitsym(srsym,srsymtable,t);
try_consume_unitsym(srsym,srsymtable,t,true);
{ if nothing found give error and return errorsym }
if assigned(srsym) then
check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg)
@ -240,10 +240,11 @@ implementation
end;
function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume : ttoken):boolean;
function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume:ttoken;consume_id:boolean):boolean;
var
hmodule: tmodule;
begin
// TODO: dot units
result:=false;
tokentoconsume:=_ID;
if assigned(srsym) and
@ -260,7 +261,8 @@ implementation
internalerror(201001120);
if hmodule.unit_index=current_filepos.moduleindex then
begin
consume(_ID);
if consume_id then
consume(_ID);
consume(_POINT);
case token of
_ID:

View File

@ -1364,7 +1364,7 @@ implementation
searchsym(pattern,srsym,srsymtable);
{ handle unit specification like System.Writeln }
unit_found:=try_consume_unitsym(srsym,srsymtable,t);
unit_found:=try_consume_unitsym(srsym,srsymtable,t,true);
storedpattern:=pattern;
orgstoredpattern:=orgpattern;
consume(t);

View File

@ -799,6 +799,8 @@ implementation
objname,objrealname : TIDString;
srsym : tsym;
srsymtable : TSymtable;
t:ttoken;
unit_found:boolean;
oldcurrent_exceptblock: integer;
begin
include(current_procinfo.flags,pi_uses_exceptions);
@ -886,23 +888,16 @@ implementation
begin
{ check if type is valid, must be done here because
with "e: Exception" the e is not necessary }
if srsym=nil then
begin
identifier_not_found(objrealname);
srsym:=generrorsym;
end;
{ support unit.identifier }
if srsym.typ=unitsym then
unit_found:=try_consume_unitsym(srsym,srsymtable,t,false);
if srsym=nil then
begin
consume(_POINT);
searchsym_in_module(tunitsym(srsym).module,pattern,srsym,srsymtable);
if srsym=nil then
begin
identifier_not_found(orgpattern);
srsym:=generrorsym;
end;
consume(_ID);
identifier_not_found(orgpattern);
srsym:=generrorsym;
end;
if unit_found then
consume(t);
{ check if type is valid, must be done here because
with "e: Exception" the e is not necessary }
if (srsym.typ=typesym) and

View File

@ -518,7 +518,7 @@ implementation
{ Use the special searchsym_type that search only types }
searchsym_type(s,srsym,srsymtable);
{ handle unit specification like System.Writeln }
is_unit_specific:=try_consume_unitsym(srsym,srsymtable,t);
is_unit_specific:=try_consume_unitsym(srsym,srsymtable,t,true);
consume(t);
{ Types are first defined with an error def before assigning
the real type so check if it's an errordef. if so then