DelphiAST icon indicating copy to clipboard operation
DelphiAST copied to clipboard

TPasSyntaxTreeBuilder.Lexer hides TmwSimplePasPar.Lexer

Open gabr42 opened this issue 8 years ago • 0 comments

TPasSyntaxTreeBuilder's Lexer property hides inherited TmwSimplePasPar.Lexer. Because of that, the only way to add a custom conditional define is to case TPasSyntaxTreeBuilder into TmwSimplePasPar which is, well, ugly (marked <--- HERE in the example below).

builder := TPasSyntaxTreeBuilder.Create;
try
  fileStream := TStringStream.Create;
  try
      fileStream.LoadFromFile(fileName);
      builder.IncludeHandler := TIncludeHandler.Create(Self, fileName);
      builder.InitDefinesDefinedByCompiler;
      TmwSimplePasPar(builder).Lexer.AddDefine('DEBUG');               // <--- HERE
      syntaxTree := builder.Run(strStream);
  finally FreeAndNil(fileStream); end;
finally FreeAndNil(builder); end;

gabr42 avatar Jul 27 '17 12:07 gabr42