mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-06 06:47:53 +02:00
fcl-js: parse power token
This commit is contained in:
parent
85494cdb1d
commit
f1bc31b057
@ -1821,7 +1821,7 @@ begin
|
||||
Result:=TJSPrimaryExpressionThis(CreateElement(TJSPrimaryExpressionThis));
|
||||
GetNextToken;
|
||||
end;
|
||||
tjsidentifier:
|
||||
tjsIdentifier:
|
||||
begin
|
||||
R:=TJSPrimaryExpressionIdent(CreateElement(TJSPrimaryExpressionIdent));
|
||||
Result:=R;
|
||||
|
@ -698,6 +698,11 @@ begin
|
||||
Inc(TokenStr);
|
||||
Result := tjsMulEq;
|
||||
end
|
||||
else if (TokenStr[0]='*') then
|
||||
begin
|
||||
Inc(TokenStr);
|
||||
Result := tjsPower;
|
||||
end
|
||||
else
|
||||
Result := tjsMul;
|
||||
end;
|
||||
|
@ -28,7 +28,7 @@ type
|
||||
tjsANDAND, tjsANDEQ,
|
||||
tjsBraceOpen,tjsBraceClose,tjsSQuaredBraceOpen,tjsSQuaredBraceClose,tjsCurlyBraceOpen,tjsCurlyBraceClose,
|
||||
tjsCOMMA,tjsCOLON, tjsDOT,tjsSEMICOLON, tjsASSIGN,tjsGT,tjsLT, tjsConditional,
|
||||
tjsPLUS,tjsMINUS,tjsMUL,tjsDIV,tjsAnd,tjsOR, tjsInv, tjsMod, tjsXOR, tjsNot,
|
||||
tjsPLUS,tjsMINUS,tjsMUL,tjsDIV,tjsPower, tjsAnd,tjsOR, tjsInv, tjsMod, tjsXOR, tjsNot,
|
||||
tjsEQ,
|
||||
tjsGE,
|
||||
tjsLE, tjsLSHIFT, tjsLSHIFTEQ,
|
||||
@ -66,7 +66,7 @@ const
|
||||
'&&','&=',
|
||||
'(',')','[',']','{','}',
|
||||
',',':','.',';','=','>','<','?',
|
||||
'+','-','*','/','&','|','~','%','^','!',
|
||||
'+','-','*','/','**','&','|','~','%','^','!',
|
||||
'==',
|
||||
'>=',
|
||||
'<=', '<<', '<<=',
|
||||
|
@ -707,6 +707,12 @@ Type
|
||||
Class function OperatorToken : tjsToken; override;
|
||||
end;
|
||||
|
||||
{ TJSPowerExpression - e.g. A ** B }
|
||||
|
||||
TJSPowerExpression = Class(TJSBinaryExpression)
|
||||
Class function OperatorToken : tjsToken; override;
|
||||
end;
|
||||
|
||||
{ TJSCommaExpression - e.g. A , B }
|
||||
|
||||
TJSCommaExpression = Class(TJSBinaryExpression)
|
||||
@ -2720,6 +2726,13 @@ begin
|
||||
Result:=tjsMod;
|
||||
end;
|
||||
|
||||
{ TJSPowerExpression }
|
||||
|
||||
class function TJSPowerExpression.OperatorToken: tjsToken;
|
||||
begin
|
||||
Result:=tjsPower;
|
||||
end;
|
||||
|
||||
{ TJSMultiplicativeExpressionDiv }
|
||||
|
||||
Class function TJSMultiplicativeExpressionDiv.OperatorToken: tjsToken;
|
||||
|
@ -67,6 +67,7 @@ type
|
||||
procedure TestCurlyBraceClose;
|
||||
procedure TestCurlyBraceOpen;
|
||||
procedure TestDiv;
|
||||
procedure TestPower;
|
||||
procedure TestDiveq;
|
||||
procedure TestXor;
|
||||
procedure TestXoreq;
|
||||
@ -183,7 +184,8 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
Function TTestJSScanner.CreateScanner(AInput : TJSScannerString; aVersion : TECMAVersion = ecma5) : TJSScanner;
|
||||
function TTestJSScanner.CreateScanner(AInput: TJSScannerString;
|
||||
aVersion: TECMAVersion): TJSScanner;
|
||||
|
||||
begin
|
||||
FStream:=TStringStream.Create(AInput);
|
||||
@ -365,6 +367,11 @@ begin
|
||||
CheckToken(tjsDiv,'/');
|
||||
end;
|
||||
|
||||
procedure TTestJSScanner.TestPower;
|
||||
begin
|
||||
CheckToken(tjsPower,'**');
|
||||
end;
|
||||
|
||||
procedure TTestJSScanner.TestEq;
|
||||
|
||||
begin
|
||||
@ -796,7 +803,8 @@ begin
|
||||
CheckToken(tjsYield,'yield',ecma2021);
|
||||
end;
|
||||
|
||||
procedure TTestJSScanner.CheckTokens(ASource : TJSScannerString; ATokens : Array of TJSToken; aVersion: TECMAVersion = ecma5);
|
||||
procedure TTestJSScanner.CheckTokens(ASource: TJSScannerString;
|
||||
ATokens: array of TJSToken; aVersion: TECMAVersion);
|
||||
|
||||
Var
|
||||
I : Integer;
|
||||
|
Loading…
Reference in New Issue
Block a user