mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 13:29:19 +02:00
+ add support for '[' and ']' parenthesis in addition to '(' and ')' in
rautils.TExprParse. They behave exactly like '(' and ')'. However, you cannot nest '(' with ']' and '[' with ')'. This is introduced in order to help implementing support for BP7 asm constants that are parsed like references, e.g. 'dd Rec.Str[5]' or 'dd 5[7]'. git-svn-id: trunk@38849 -
This commit is contained in:
parent
c840c4d6a8
commit
d1fc31de94
@ -149,6 +149,7 @@ type
|
|||||||
{ '%' : modulo division }
|
{ '%' : modulo division }
|
||||||
{ nnn: longint numbers }
|
{ nnn: longint numbers }
|
||||||
{ ( and ) parenthesis }
|
{ ( and ) parenthesis }
|
||||||
|
{ [ and ] another kind of parenthesis }
|
||||||
{**********************************************************************}
|
{**********************************************************************}
|
||||||
|
|
||||||
TExprParse = class
|
TExprParse = class
|
||||||
@ -377,7 +378,7 @@ Function TExprParse.Priority(_Operator : Char) : aint;
|
|||||||
begin
|
begin
|
||||||
Priority:=0;
|
Priority:=0;
|
||||||
Case _Operator OF
|
Case _Operator OF
|
||||||
'(' :
|
'(','[' :
|
||||||
Priority:=0;
|
Priority:=0;
|
||||||
'|','^','~' : // the lowest priority: OR, XOR, NOT
|
'|','^','~' : // the lowest priority: OR, XOR, NOT
|
||||||
Priority:=0;
|
Priority:=0;
|
||||||
@ -416,7 +417,7 @@ begin
|
|||||||
RPNCalc(Token,false);
|
RPNCalc(Token,false);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Expr[I] in ['+', '-', '*', '/', '(', ')','^','&','|','%','~','<','>'] then
|
if Expr[I] in ['+', '-', '*', '/', '(', ')','[',']','^','&','|','%','~','<','>'] then
|
||||||
begin
|
begin
|
||||||
if Token <> '' then
|
if Token <> '' then
|
||||||
begin { Send last built number to calc. }
|
begin { Send last built number to calc. }
|
||||||
@ -425,6 +426,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
Case Expr[I] OF
|
Case Expr[I] OF
|
||||||
|
'[' : OpPush('[',false);
|
||||||
|
']' : begin
|
||||||
|
While (OpTop>0) and (OpStack[OpTop].ch <> '[') DO
|
||||||
|
Begin
|
||||||
|
OpPop(opr);
|
||||||
|
RPNCalc(opr.ch,opr.is_prefix);
|
||||||
|
end;
|
||||||
|
OpPop(opr); { Pop off and ignore the '[' }
|
||||||
|
end;
|
||||||
'(' : OpPush('(',false);
|
'(' : OpPush('(',false);
|
||||||
')' : begin
|
')' : begin
|
||||||
While (OpTop>0) and (OpStack[OpTop].ch <> '(') DO
|
While (OpTop>0) and (OpStack[OpTop].ch <> '(') DO
|
||||||
|
Loading…
Reference in New Issue
Block a user