This commit is contained in:
Basile Burg 2014-07-04 17:00:05 +02:00
parent 24fba590fa
commit f548ea152e
5 changed files with 84 additions and 42 deletions

View File

@ -723,6 +723,7 @@ var
err: PLexError;
tkIndex: NativeInt;
pareCnt, curlCnt, squaCnt: NativeInt;
pareLeft, curlLeft, squaLeft: boolean;
procedure addError(const aMsg: string);
begin
err := new(PLexError);
@ -738,11 +739,12 @@ begin
pareCnt := 0;
curlCnt := 0;
squaCnt := 0;
pareLeft:= False;
curlLeft:= False;
squaLeft:= False;
for tk in aTokenList do
begin
// token index
Inc(tkIndex);
// brackets count
@ -758,12 +760,21 @@ begin
end;
// only for the first occurence
if pareCnt = -1 then
if not pareLeft then if pareCnt = -1 then
begin
addError('a left parenthesis is missing');
if curlCnt = -1 then
pareLeft := true;
end;
if not curlLeft then if curlCnt = -1 then
begin
addError('a left curly bracket is missing');
if squaCnt = -1 then
curlLeft := true;
end;
if not squaLeft then if squaCnt = -1 then
begin
addError('a left square bracket is missing');
squaLeft := true;
end;
// at the end
if (tkIndex = aTokenList.Count-1) then
@ -801,9 +812,9 @@ _preSeq:
if old1.data = tk.data then
addError('keyword is duplicated');
// needs negative numbr to be tokenized correctly: ... = -1; '-' is currently token as an operator.
if (old1.kind = ltkOperator) and (tk.kind = ltkOperator) then
addError('operator rhs cannot be an operator');
if tk.data <> '&' then // ident = &ident
if (old1.kind = ltkOperator) and (tk.kind = ltkOperator) then
addError('operator rhs cannot be an operator');
if (old1.kind = ltkNumber) and (tk.kind = ltkNumber) then
addError('symbol or operator expected after number');

View File

@ -23,9 +23,13 @@ type
protected
procedure UpdateByDelay; override;
private
// http://bugs.freepascal.org/view.php?id=26329
fKeyChanged: boolean;
// http://bugs.freepascal.org/view.php?id=26329
fSyncEdit: TSynPluginSyncroEdit;
tokLst: TLexTokenList;
errLst: TLexErrorList;
procedure memoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure memoMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure memoChange(Sender: TObject);
@ -37,6 +41,7 @@ type
procedure identifierToD2Syn(const aMemo: TCESynMemo);
public
constructor create(aOwner: TComponent); override;
destructor destroy; override;
procedure addEditor;
procedure removeEditor(const aIndex: NativeInt);
procedure focusedEditorChanged;
@ -59,6 +64,10 @@ var
begin
inherited;
fID := 'ID_EDIT';
//
tokLst := TLexTokenList.Create;
errLst := TLexErrorList.Create;
//
fSyncEdit := TSynPluginSyncroEdit.Create(self);
bmp := TBitmap.Create;
try
@ -70,6 +79,13 @@ begin
DockMaster.GetAnchorSite(Self).Name := ID;
end;
destructor TCEEditorWidget.destroy;
begin
tokLst.Free;
errLst.Free;
inherited;
end;
function TCEEditorWidget.getEditorCount: NativeInt;
begin
result := pageControl.PageCount;
@ -197,8 +213,6 @@ const
modstr: array[boolean] of string = ('...', 'MODIFIED');
var
ed: TCESynMemo;
tokLst: TLexTokenList;
errLst: TLexErrorList;
err: TLexError;
begin
ed := getCurrentEditor;
@ -213,24 +227,15 @@ begin
begin
mainForm.docChangeNotify(Self, editorIndex);
mainForm.MessageWidget.List.Clear;
tokLst := TLexTokenList.Create;
errLst := TLexErrorList.Create;
try
lex( ed.Lines.Text, tokLst );
checkSyntaxicErrors( tokLst, errLst);
for err in errLst do
mainForm.MessageWidget.addMessage(format(
'%s (@line:%4.d @char:%.4d)',[err.msg, err.position.y, err.position.x]));
mainForm.MessageWidget.scrollToBack;
finally
tokLst.Free;
errLst.Free;
end;
mainForm.MessageWidget.Clear;
lex( ed.Lines.Text, tokLst );
checkSyntaxicErrors( tokLst, errLst);
for err in errLst do
mainForm.MessageWidget.addMessage(format(
'%s (@line:%4.d @char:%.4d)',[err.msg, err.position.y, err.position.x]));
mainForm.MessageWidget.scrollToBack;
tokLst.Clear;
errLst.Clear;
end;
fKeyChanged := false;

View File

@ -177,8 +177,6 @@ type
procedure actProjSourceExecute(Sender: TObject);
procedure actEdUnIndentExecute(Sender: TObject);
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
procedure FormResize(Sender: TObject);
procedure FormShow(Sender: TObject);
private
fUpdateCount: NativeInt;
fProject: TCEProject;
@ -497,14 +495,6 @@ begin
//
srcLst.Clear;
end;
procedure TCEMainForm.FormShow(Sender: TObject);
begin
end;
procedure TCEMainForm.FormResize(Sender: TObject);
begin
end;
{$ENDREGION}
{$REGION file ******************************************************************}

View File

@ -5,8 +5,8 @@ unit ce_messages;
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
ExtCtrls, ComCtrls, ce_widget, ActnList, Menus, clipbrd, AnchorDocking;
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
ce_widget, ActnList, Menus, clipbrd, AnchorDocking, ce_project, ce_synmemo;
type
@ -19,6 +19,7 @@ type
fActSaveMsg: TAction;
fActCopyMsg: TAction;
fActSelAll: TAction;
fProject: TCEProject;
procedure actClearExecute(Sender: TObject);
procedure actSaveMsgExecute(Sender: TObject);
procedure actCopyMsgExecute(Sender: TObject);
@ -35,6 +36,14 @@ type
function contextName: string; override;
function contextActionCount: integer; override;
function contextAction(index: integer): TAction; override;
//
procedure projNew(const aProject: TCEProject); override;
procedure projClose(const aProject: TCEProject); override;
//
procedure docFocused(const aDoc: TCESynMemo); override;
procedure docClose(const aDoc: TCESynMemo); override;
//
procedure Clear;
end;
PTCEMessageItem = ^TCEMessageItem;
@ -144,6 +153,33 @@ begin
end;
end;
procedure TCEMessagesWidget.projNew(const aProject: TCEProject);
begin
fProject := aProject;
end;
procedure TCEMessagesWidget.projClose(const aProject: TCEProject);
begin
if fProject = aProject then
actClearExecute(nil);
fProject := nil;
end;
procedure TCEMessagesWidget.docFocused(const aDoc: TCESynMemo);
begin
Clear;
end;
procedure TCEMessagesWidget.docClose(const aDoc: TCESynMemo);
begin
Clear;
end;
procedure TCEMessagesWidget.Clear;
begin
actClearExecute(nil);
end;
procedure TCEMessagesWidget.actClearExecute(Sender: TObject);
begin
List.Clear;

View File

@ -35,10 +35,10 @@ type
procedure UpdateByEvent; override;
public
constructor create(aOwner: TComponent); override;
//
procedure projNew(const aProject: TCEProject); override;
procedure projChange(const aProject: TCEProject); override;
procedure projClose(const aProject: TCEProject); override;
property project: TCEProject read fProj;
end;
implementation