codetools: added operator ><

git-svn-id: trunk@34991 -
This commit is contained in:
mattias 2012-01-28 17:04:18 +00:00
parent 50bff70654
commit cb398e865c
23 changed files with 232 additions and 15 deletions

View File

@ -65,6 +65,8 @@ ResourceString
ctsinvalidVariableType = 'invalid variable type %s%s%s';
ctsClassSNotFound = 'Class %s not found';
ctsIdentExpectedButEOFFound = 'unexpected end of file (identifier expected)';
ctsOperatorExpectedButEOFFound = 'unexpected end of file (operator expected)';
ctsOperatorExpectedButAtomFound = 'operator expected, but %s found';
ctsBracketOpenExpectedButAtomFound = 'bracket open expected, but %s found';
ctsBracketCloseExpectedButAtomFound = 'bracket close expected, but %s found';
ctsBracketNotFound = 'bracket %s not found';

View File

@ -286,6 +286,7 @@ type
function AtomIsCharConstant: boolean;
function AtomIsEmptyStringConstant: boolean;
function AtomIsIdentifier(ExceptionOnNotFound: boolean): boolean;
function AtomIsCustomOperator(AllowIdentifier, ExceptionOnNotFound: boolean): boolean;
function LastAtomIs(BackIndex: integer;
const AnAtom: shortstring): boolean; // 0=current, 1=prior current, ...
function LastUpAtomIs(BackIndex: integer;
@ -817,6 +818,29 @@ begin
RaiseIdentExpectedButAtomFound;
end;
function TCustomCodeTool.AtomIsCustomOperator(AllowIdentifier,
ExceptionOnNotFound: boolean): boolean;
procedure RaiseOperatorExpected;
begin
if CurPos.StartPos>SrcLen then
SaveRaiseException(ctsOperatorExpectedButEOFFound,true)
else
SaveRaiseException(ctsOperatorExpectedButAtomFound,true);
end;
begin
if (CurPos.StartPos<=SrcLen) then begin
if WordIsCustomOperator.DoItCaseInsensitive(
Src,CurPos.StartPos,CurPos.EndPos-CurPos.StartPos)
or AllowIdentifier and AtomIsIdentifier(false) then
exit(true);
end;
if not ExceptionOnNotFound then
exit(false);
RaiseOperatorExpected;
end;
function TCustomCodeTool.AtomIsNumber: boolean;
var
p: PChar;

View File

@ -1638,6 +1638,7 @@ begin
Add('DEC' ,{$ifdef FPC}@{$endif}AllwaysTrue);
// FPC operators
Add('**' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('><' ,{$ifdef FPC}@{$endif}AllwaysTrue);
end;
WordIsPredefinedFPCIdentifier:=TKeyWordFunctionList.Create('WordIsPredefinedFPCIdentifier');

View File

@ -689,11 +689,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -690,11 +690,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -691,11 +691,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr "Operator erwartet, aber %s gefunden"
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr "Operator erwartet aber %s gefunden"
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr "Operator erwartet, aber %s gefunden"

View File

@ -689,11 +689,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -682,11 +682,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -690,11 +690,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -689,11 +689,21 @@ msgstr "מחכה לאופרנד אבל נמצא %s"
msgid "operand expected, but %s found"
msgstr "מחכה לאופרנד, אבל נמצא %s"
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr "מחכה לאופרטור, אבל נמצא %s"
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr "מחכה לאופרטור, אבל נמצא %s"
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr "מחכה לאופרטור, אבל נמצא %s"

View File

@ -690,11 +690,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -687,11 +687,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -691,11 +691,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -689,11 +689,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -693,11 +693,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -682,11 +682,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -689,11 +689,21 @@ msgstr "operando esperado, mas %s encontrado"
msgid "operand expected, but %s found"
msgstr "operando esperado, mas %s encontrado"
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr "operador esperado, mas %s encontrado"
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr "operador esperado, mas %s encontrado"
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr "operador esperado, mas %s encontrado"

View File

@ -688,11 +688,21 @@ msgstr "operando esperado, mas %s encontrado"
msgid "operand expected, but %s found"
msgstr "operando esperado, mas %s encontrado"
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr "operador esperado, mas %s encontrado"
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr "operador esperado, mas %s encontrado"
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr "operador esperado, mas %s encontrado"

View File

@ -688,11 +688,21 @@ msgstr "ожидается операнд, но найдено %s"
msgid "operand expected, but %s found"
msgstr "ожидается операнд, но найдено %s"
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr "ожидается оператор, но найдено %s"
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr "ожидается оператор, но найдено %s"
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr "ожидается оператор, но найдено %s"

View File

@ -688,11 +688,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -687,11 +687,21 @@ msgstr "очікується операнд але знайдено %s"
msgid "operand expected, but %s found"
msgstr "очікується операнд, але знайдено %s"
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr "очікується оператор, але знайдено %s"
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr "очікується оператор але знайдено %s"
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr "очікується оператор, але знайдено %s"

View File

@ -692,11 +692,21 @@ msgstr ""
msgid "operand expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutatomfound
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutatomfound"
msgid "operator expected, but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbuteoffound
msgid "unexpected end of file (operator expected)"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound
msgid "operator expected but %s found"
msgstr ""
#: codetoolsstrconsts.ctsoperatorexpectedbutfound2
msgctxt "codetoolsstrconsts.ctsoperatorexpectedbutfound2"
msgid "operator expected, but %s found"
msgstr ""

View File

@ -1162,9 +1162,9 @@ begin
IsOperator:=(not IsFunction) and UpAtomIs('OPERATOR');
// read name
ReadNextAtom;
if (not IsOperator)
or (not WordIsCustomOperator.DoItCaseInsensitive(Src,CurPos.StartPos,CurPos.EndPos-CurPos.StartPos))
then
if IsOperator then
AtomIsCustomOperator(true,true)
else
AtomIsIdentifier(true);
// create node for procedure head
CreateChildNode;
@ -2566,9 +2566,9 @@ begin
IsOperator:=(not IsFunction) and UpAtomIs('OPERATOR');
IsMethod:=False;
ReadNextAtom;// read first atom of head (= name/operator + parameterlist + resulttype;)
if (not IsOperator)
or (not WordIsCustomOperator.DoItCaseInsensitive(Src,CurPos.StartPos,CurPos.EndPos-CurPos.StartPos))
then
if IsOperator then
AtomIsCustomOperator(true,true)
else
AtomIsIdentifier(true);
if ChildCreated then begin
// create node for procedure head
@ -2595,9 +2595,9 @@ begin
// read procedure name of a class method (the name after the . )
IsMethod:=True;
ReadNextAtom;
if (not IsOperator)
or (not WordIsCustomOperator.DoItCaseInsensitive(Src,CurPos.StartPos,CurPos.EndPos-CurPos.StartPos))
then
if IsOperator then
AtomIsCustomOperator(true,true)
else
AtomIsIdentifier(true);
ReadNextAtom;
end;
@ -5315,17 +5315,17 @@ begin
ProcHeadNode.SubDesc:=ProcHeadNode.SubDesc and (not ctnsNeedJITParsing);
if not IsProcType then begin
if (not IsOperator)
or (not WordIsCustomOperator.DoItCaseInsensitive(Src,CurPos.StartPos,CurPos.EndPos-CurPos.StartPos))
then
if IsOperator then
AtomIsCustomOperator(true,true)
else
AtomIsIdentifier(true);
ReadNextAtom;
while (CurPos.Flag=cafPoint) do begin
// read procedure name of a class method (the name after the . )
ReadNextAtom;
if (not IsOperator)
or (not WordIsCustomOperator.DoItCaseInsensitive(Src,CurPos.StartPos,CurPos.EndPos-CurPos.StartPos))
then
if IsOperator then
AtomIsCustomOperator(true,true)
else
AtomIsIdentifier(true);
ReadNextAtom;
end;