Prechádzať zdrojové kódy

+ 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 -

nickysn 7 rokov pred
rodič
commit
d1fc31de94
1 zmenil súbory, kde vykonal 12 pridanie a 2 odobranie
  1. 12 2
      compiler/rautils.pas

+ 12 - 2
compiler/rautils.pas

@@ -149,6 +149,7 @@ type
   {  '%' : modulo division                                              }
   {  nnn: longint numbers                                               }
   {  ( and ) parenthesis                                                }
+  {  [ and ] another kind of parenthesis                                }
   {**********************************************************************}
 
   TExprParse = class
@@ -377,7 +378,7 @@ Function TExprParse.Priority(_Operator : Char) : aint;
 begin
   Priority:=0;
   Case _Operator OF
-    '(' :
+    '(','[' :
       Priority:=0;
     '|','^','~' :             // the lowest priority: OR, XOR, NOT
       Priority:=0;
@@ -416,7 +417,7 @@ begin
          RPNCalc(Token,false);
       end
      else
-      if Expr[I] in ['+', '-', '*', '/', '(', ')','^','&','|','%','~','<','>'] then
+      if Expr[I] in ['+', '-', '*', '/', '(', ')','[',']','^','&','|','%','~','<','>'] then
        begin
          if Token <> '' then
           begin        { Send last built number to calc. }
@@ -425,6 +426,15 @@ begin
           end;
 
          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);
           ')' : begin
                   While (OpTop>0) and (OpStack[OpTop].ch <> '(') DO