Browse Source

+ currently compiled file name added on errors

pierre 26 years ago
parent
commit
7ffa0f6ac0
2 changed files with 23 additions and 4 deletions
  1. 12 1
      compiler/parser.pas
  2. 11 3
      compiler/pp.pas

+ 12 - 1
compiler/parser.pas

@@ -42,6 +42,9 @@ unit parser;
     procedure initparser;
     procedure doneparser;
 
+    const
+       parser_current_file : string = '';
+       
   implementation
 
     uses
@@ -161,6 +164,7 @@ unit parser;
          oldaktoptprocessor : tprocessors;
          oldaktasmmode      : tasmmode;
          oldaktmodeswitches : tmodeswitches;
+         prev_name          : pstring;
 {$ifdef USEEXCEPT}
          recoverpos    : jmp_buf;
          oldrecoverpos : pjmp_buf;
@@ -168,6 +172,8 @@ unit parser;
 
       begin
          inc(compile_level);
+         prev_name:=stringdup(parser_current_file);
+         parser_current_file:=filename;
        { save symtable state }
          oldsymtablestack:=symtablestack;
          oldrefsymtable:=refsymtable;
@@ -407,6 +413,8 @@ unit parser;
           end;
 
          dec(compile_level);
+         parser_current_file:=prev_name^;
+         stringdispose(prev_name);
 {$ifdef USEEXCEPT}
          if longjump_used then
            longjmp(recoverpospointer^,1);
@@ -416,7 +424,10 @@ unit parser;
 end.
 {
   $Log$
-  Revision 1.64  1999-01-12 14:25:29  peter
+  Revision 1.65  1999-01-22 12:19:31  pierre
+   + currently compiled file name added on errors
+
+  Revision 1.64  1999/01/12 14:25:29  peter
     + BrowserLog for browser.log generation
     + BrowserCol for browser info in TCollections
     * released all other UseBrowser

+ 11 - 3
compiler/pp.pas

@@ -115,6 +115,8 @@ uses
   catch,
 {$endif}
 {$endif FPC}
+  { added for parser_current_file info }
+  parser,
   globals,compiler
   ;
 
@@ -245,7 +247,10 @@ begin
               Writeln('Error: Out of memory');
             end;
      end;
-     Writeln('Compilation aborted at line ',aktfilepos.line);
+     { we cannot use aktfilepos.file because all memory might have been
+       freed already !
+       But we can use global parser_current_file var }
+     Writeln('Compilation aborted ',parser_current_file,':',aktfilepos.line);
    end;
 end;
 
@@ -260,11 +265,14 @@ begin
 {$endif}
 
 { Call the compiler with empty command, so it will take the parameters }
-  Halt(Compile(''));
+  Halt(compiler.Compile(''));
 end.
 {
   $Log$
-  Revision 1.38  1999-01-19 10:19:03  florian
+  Revision 1.39  1999-01-22 12:19:30  pierre
+   + currently compiled file name added on errors
+
+  Revision 1.38  1999/01/19 10:19:03  florian
     * bug with mul. of dwords fixed, reported by Alexander Stohr
     * some changes to compile with TP
     + small enhancements for the new code generator