summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaul <paul@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-08-24 10:54:17 +0000
committerpaul <paul@3ad0048d-3df7-0310-abae-a5850022a9f2>2011-08-24 10:54:17 +0000
commit9e3bf7f292327df86302cab6d8d86f971114a3df (patch)
tree980d45cc147d16251c110debe2a5a760b9adc30a
parent8d34dfca39c05c24cfc27dd5ee358fb7ca13b2a7 (diff)
downloadfpc-9e3bf7f292327df86302cab6d8d86f971114a3df.tar.gz
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: http://svn.freepascal.org/svn/fpc/trunk@18826 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--compiler/pbase.pas12
-rw-r--r--compiler/pexpr.pas2
-rw-r--r--compiler/pstatmnt.pas23
-rw-r--r--compiler/ptype.pas2
4 files changed, 18 insertions, 21 deletions
diff --git a/compiler/pbase.pas b/compiler/pbase.pas
index 62c7f3d195..38cf1962ee 100644
--- a/compiler/pbase.pas
+++ b/compiler/pbase.pas
@@ -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:
diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas
index 0dd4efb93b..8e2b55c63d 100644
--- a/compiler/pexpr.pas
+++ b/compiler/pexpr.pas
@@ -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);
diff --git a/compiler/pstatmnt.pas b/compiler/pstatmnt.pas
index a8127da398..ef91eb5756 100644
--- a/compiler/pstatmnt.pas
+++ b/compiler/pstatmnt.pas
@@ -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
diff --git a/compiler/ptype.pas b/compiler/ptype.pas
index 2265b4421d..58a737c044 100644
--- a/compiler/ptype.pas
+++ b/compiler/ptype.pas
@@ -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