瀏覽代碼

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

+ 1 - 1
compiler/pexpr.pas

@@ -1364,7 +1364,7 @@ implementation
                  searchsym(pattern,srsym,srsymtable);
                  searchsym(pattern,srsym,srsymtable);
 
 
                { handle unit specification like System.Writeln }
                { 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;
                storedpattern:=pattern;
                orgstoredpattern:=orgpattern;
                orgstoredpattern:=orgpattern;
                consume(t);
                consume(t);

+ 9 - 14
compiler/pstatmnt.pas

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

+ 1 - 1
compiler/ptype.pas

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