procedure TForm1.btnSYntaxCheckClick(Sender: TObject);
var
i : integer;
lNumber : integer;
aMsg : string;
begin
mmoMsg.Lines.Clear;
FErrorList.Clear;
if CheckSyntax(TMSFMXMemo1.Lines.Text) then
exit;
lNumber := PaxCompiler1.ErrorLineNumber[0];
SelectLine(lNumber);
for I:=0 to PaxCompiler1.ErrorCount - 1 do
begin
lNumber := PaxCompiler1.ErrorLineNumber[i];
FErrorList.Add(lNumber);
aMsg := 'msg: '+PaxCompiler1.ErrorMessage[i] +
' ln: '+inttostr(lNumber);
mmoMsg.Lines.Add(aMsg);
end;
end;
function TForm1.CheckSyntax(ACode: string): Boolean;
begin
Result := false;
PaxCompiler1.Reset;
PaxCompiler1.RegisterLanguage(PaxPascalLanguage1);
PaxCompiler1.AddModule('1', 'Pascal');
PaxCompiler1.AddCode('1', ACode);
if PaxCompiler1.Compile(PaxInterpreter1) then
exit(True);
end;
procedure TForm1.SelectLine(lNumber: Integer);
var
lineText, temp : string;
posStart, i : integer;
begin
TMSFMXMemo1.ClearSelection;
TMSFMXMemo1.SetCursor(0,lNumber);
TMSFMXMemo1.ActiveLine := lNumber;
end;
Download the source code for the syntax highlighting syntax checker demo for Delphi XE8 Firemonkey.