Преглед на файлове

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 -
paul преди 14 години
родител
ревизия
8309809a0d
променени са 4 файла, в които са добавени 18 реда и са изтрити 21 реда
  1. 7 5
      compiler/pbase.pas
  2. 1 1
      compiler/pexpr.pas
  3. 9 14
      compiler/pstatmnt.pas
  4. 1 1
      compiler/ptype.pas

+ 7 - 5
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:

+ 1 - 1
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);

+ 9 - 14
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

+ 1 - 1
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