Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Position on line in error messages #18

Open
electric-socket opened this issue Oct 27, 2020 · 0 comments
Open

Add Position on line in error messages #18

electric-socket opened this issue Oct 27, 2020 · 0 comments

Comments

@electric-socket
Copy link

electric-socket commented Oct 27, 2020

Knowing exactly where on a line an error was discovered is extra helpful, and I recommend adding it. I'll even tell how. These changes are given in reverse order, bottom to top so a reference to a line number will remain the same after a change was made.

In scanner.pas, six changes.

  1. Insert the Following procedure of 4 lines starting at line 697:
function ScannerPos: Integer;
begin
      Result := ScannerState.Position;
end; 
  1. After line 186 insert one line:
    inc(ScannerState.Position);

  2. Replace line 179
    if ScannerState.ch = #10 then Inc(ScannerState.Line);
    With the following five lines:

if ScannerState.ch = #10 then   // End of line found         '
  begin 
     Inc(ScannerState.Line);  
     Scannerstate.Position  := 0; 
  end;   
  1. After line 98 insert one line:
    Position := 0;

  2. After line 46 insert one line:
    Position,

  3. After line 29 insert one line:
    function ScannerPos: Integer;

In file XDPW._PAS two changes:

  1. Line 72, replace one line:
    Notice(ScannerFileName + ' (' + IntToStr(ScannerLine) + ') Error: ' + Msg)
    with the following split line:
  Notice(ScannerFileName + ' (' + IntToStr(ScannerLine) + 
              ':' + IntToStr(ScannerPos)  + ') Error: ' + Msg)  
  1. Line 61 replace one line:
    Notice(ScannerFileName + ' (' + IntToStr(ScannerLine) + ') Warning: ' + Msg)
    with the following split line:
  Notice(ScannerFileName + ' (' + IntToStr(ScannerLine) + ' 
             ':' + IntToStr(ScannerPos) +  ') Warning: ' + Msg) 
  1. Optional Change to Common.Pas, change line 14 from:
    VERSION = '0.12';
    to
    VERSION = '0.13';

To confirm the change for anyone using it. I've compiled it and tried it and it's sweet, if you feed it a file with an error it now shows both line number and position on the line where the error was detected. I think it would be useful and I recommend its inclusion.

Paul.

Paul Robinson paul@paul-robinson.us
"The lessons of history teach us - if they teach us anything - that no one learns the lessons that history teaches us."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant