mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 09:00:35 +02:00
jcf: further work on operators (r743)
git-svn-id: trunk@17879 -
This commit is contained in:
parent
ba83fff416
commit
52c3090688
@ -2275,6 +2275,12 @@ begin
|
||||
if fcTokenList.FirstSolidTokenType = ttOpenBracket then
|
||||
RecogniseFormalParameters;
|
||||
|
||||
// lazarus can give a name to "result" here
|
||||
if fcTokenList.FirstSolidTokenType <> ttColon then
|
||||
begin
|
||||
RecogniseIdentifier(false, idAny);
|
||||
end;
|
||||
|
||||
Recognise(ttColon);
|
||||
PushNode(nFunctionReturnType);
|
||||
RecogniseType;
|
||||
@ -2296,7 +2302,7 @@ end;
|
||||
|
||||
procedure TBuildParseTree.RecogniseOperatorSymbol;
|
||||
const
|
||||
OperatorTokens: TTokenTypeSet = [ttPlus, ttMinus, ttTimes, ttFloatDiv,
|
||||
OperatorTokens: TTokenTypeSet = [ttPlus, ttMinus, ttTimes, ttFloatDiv, ttExponent,
|
||||
ttEquals, ttGreaterThan, ttLessThan, ttGreaterThanOrEqual, ttLessThanOrEqual,
|
||||
ttAssign];
|
||||
begin
|
||||
|
@ -640,21 +640,21 @@ function TBuildTokenList.TryPunctuation(const pcToken: TSourceToken): boolean;
|
||||
|
||||
function FollowsPunctuation(const chLast, ch: WideChar): boolean;
|
||||
const
|
||||
{ these have meanings on thier own and should not be recognised as part of the punc.
|
||||
{ These have meanings on thier own and should not be recognised as part of the punc.
|
||||
e.g '=(' is not a punctation symbol, but 2 of them ( for e.g. in const a=(3);
|
||||
simlarly ');' is 2 puncs }
|
||||
UnitaryPunctuation: set of AnsiChar = [
|
||||
NativeSingleQuote, '"', '(', ')', '[', ']', '{',
|
||||
'#', '$', '_', ';', '@', '^', ','];
|
||||
|
||||
{ these can't have anything following them:
|
||||
{ These can't have anything following them:
|
||||
for e.g, catch the case if a=-1 then ...
|
||||
where '=-1' should be read as '=' '-1' not '=-' '1'
|
||||
Nothing legitimately comes after '=' AFAIK
|
||||
also a:=a*-1;
|
||||
q:=q--1; // q equals q minus minus-one. It sucks but it compiles so it must be parsed
|
||||
etc }
|
||||
SingleChars: set of AnsiChar = ['=', '+', '-', '*', '/', '\'];
|
||||
SingleChars: set of AnsiChar = ['=', '+', '-', '/', '\'];
|
||||
|
||||
begin
|
||||
Result := False;
|
||||
@ -675,6 +675,11 @@ function TBuildTokenList.TryPunctuation(const pcToken: TSourceToken): boolean;
|
||||
if (chLast = ':') and (ch <> '=') then
|
||||
exit;
|
||||
|
||||
// * can be followed by another *
|
||||
if (chLast = '*') and (ch <> '*') then
|
||||
exit;
|
||||
|
||||
|
||||
// "<<" is the start of two nested generics,
|
||||
// likewise '>>' is not an operator, it is two "end-of-generic" signs in sucession
|
||||
if (chLast = '<') and (ch = '<') then
|
||||
@ -734,7 +739,7 @@ end;
|
||||
|
||||
function TBuildTokenList.BuildTokenList: TSourceTokenList;
|
||||
const
|
||||
UPDATE_INTERVAL = 4096; // big incre,ents here, this is fatser than parsing
|
||||
UPDATE_INTERVAL = 4096; // big increments here, this goes faster than parsing
|
||||
var
|
||||
lcList: TSourceTokenList;
|
||||
lcNew: TSourceToken;
|
||||
|
@ -263,6 +263,7 @@ type
|
||||
ttHat,
|
||||
ttTimes,
|
||||
ttFloatDiv,
|
||||
ttExponent,
|
||||
ttPlus,
|
||||
ttMinus,
|
||||
ttEquals,
|
||||
@ -387,14 +388,14 @@ const
|
||||
|
||||
AddOperators: TTokenTypeSet = [ttPlus, ttMinus, ttOr, ttXor];
|
||||
|
||||
MulOperators: TTokenTypeSet = [ttTimes, ttFloatDiv, ttDiv, ttMod, ttAnd, ttShl, ttShr];
|
||||
MulOperators: TTokenTypeSet = [ttTimes, ttFloatDiv, ttDiv, ttMod, ttAnd, ttShl, ttShr, ttExponent];
|
||||
|
||||
SingleSpaceOperators = [
|
||||
// some unary operators
|
||||
ttNot,
|
||||
// all operators that are always binary
|
||||
ttAnd, ttAs, ttDiv, ttIn, ttIs, ttMod, ttOr, ttShl, ttShr, ttXor,
|
||||
ttTimes, ttFloatDiv, ttEquals, ttGreaterThan, ttLessThan,
|
||||
ttTimes, ttFloatDiv, ttExponent, ttEquals, ttGreaterThan, ttLessThan,
|
||||
ttGreaterThanOrEqual, ttLessThanOrEqual, ttNotEqual];
|
||||
|
||||
StringWords: TTokenTypeSet = [ttString, ttAnsiString, ttWideString];
|
||||
@ -737,6 +738,7 @@ begin
|
||||
AddKeyword('@', wtOperator, ttAtSign);
|
||||
AddKeyword('^', wtOperator, ttHat);
|
||||
AddKeyword('*', wtOperator, ttTimes);
|
||||
AddKeyword('**', wtOperator, ttExponent); // in Lazarus
|
||||
AddKeyword('/', wtOperator, ttFloatDiv);
|
||||
AddKeyword('+', wtOperator, ttPlus);
|
||||
AddKeyword('-', wtOperator, ttMinus);
|
||||
|
@ -1,3 +1,3 @@
|
||||
This directory contains a copy (sometimes modified) of r742 jcf2 svn tree: https://jedicodeformat.svn.sourceforge.net/svnroot/jedicodeformat/trunk/CodeFormat/Jcf2
|
||||
This directory contains a copy (sometimes modified) of r743 jcf2 svn tree: https://jedicodeformat.svn.sourceforge.net/svnroot/jedicodeformat/trunk/CodeFormat/Jcf2
|
||||
|
||||
Only command line utility works currently.
|
Loading…
Reference in New Issue
Block a user