A comedy of errors: TParser lazarus / 21-General ---------------------------------------------------------------------- Thaddy · 2025-01-04 18:52 I wonder if I even should attempt to file a bug report against TParser, since it is not meant to be used as a true parser anyway. The class is basically only for dfm/lfm parsing. So why the shakespearian title? Well both Delphi and FPC versions of TParser expose the same error and at the same spot. Problem is: - Delphi recovers - Freepascal crashes Sample code that is supposed to parse its own source:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program testrtlparser;{$ifdef fpc}{$mode objfpc}{$H+}{$endif}{$apptype console} uses sysutils, classes; var  fs: TFileStream;  pp: TParser; begin  fs := TFileStream.Create('testrtlparser.pas', fmOpenread);// parse myself  try    pp := TParser.Create(fs);    try    repeat        case pp.token of          toSymbol:            writeln('symbol: ', pp.tokenstring);          toString:            writeln('string: ', pp.tokenstring);          toInteger:            writeln('integer: ', pp.tokenstring);          toFloat:            writeln('float: ', pp.tokenstring);          toWString:            writeln('widestring: ', pp.tokenstring);        else          // writeln(pp.tokenstring);        end;        pp.nextToken;      until pp.token = toEOF;    finally      pp.free;    end;  finally    fs.free;  end;  readln; end.Of course, if I add a try/except I get the same result as Delphi, with the same error in both flavors. Why all the fuzz? Simple, I have TParser derivative code (20+ years old) that parses uses clauses. (It adds skiptoken, basically when it finds "uses" it copies all tokens upto the ';' pushes them into a stringtree and later try to recurse the lot. The real code is quite a lot more lines  ) BTW the first error is that if a $ is encountered it is prematurely interpreted as an integer, the second error is that if the next char is within a..f the rest of the token is ignored. I am not quite sure the clean-rooming of almost two decades ago can explain why the exact same error exists in both flavors.... It is quite easy to fix. ---------------------------------------------------------------------- ASerge · 2025-01-04 22:37 Quote from: Thaddy on January 04, 2025, 07:52:09 pmI wonder if I even should attempt to file a bug report against TParser, since it is not meant to be used as a true parser anyway. The class is basically only for dfm/lfm parsing. It parses the dfm files, which is slightly different from the source code. ---------------------------------------------------------------------- Thaddy · 2025-01-04 22:49 I know that, but dfm/lfm files can also contain $a etc. My old code is a functioning unit parser. I find it funny that the same bug is in both Delphi and Freepascal. It is also easy to fix. (I believe I already done that 20 years ago) I just found that old code. The example above is a reduction of course. Actually, technically it is not a parser, but a tokenizer.