]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/RangeExpression.py
BaseTools: remove local hex number regular expression
[mirror_edk2.git] / BaseTools / Source / Python / Common / RangeExpression.py
index 3449711dcc08c6161286f60b63f5a1f18114de14..5fcc8a432a565a2bc88947175fc03769f45ff60c 100644 (file)
@@ -210,9 +210,6 @@ class RangeExpression(object):
     NonLetterOpLst = ['+', '-', '&', '|', '^', '!', '=', '>', '<']\r
 \r
     PcdPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$')\r
-    HexPattern = re.compile(r'0[xX][0-9a-fA-F]+')\r
-    RegGuidPattern = re.compile(r'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}')\r
-    ExRegGuidPattern = re.compile(r'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')\r
     \r
     RangePattern = re.compile(r'[0-9]+ - [0-9]+')\r
 \r
@@ -221,7 +218,7 @@ class RangeExpression(object):
         # convert interval to object index. ex. 1 - 10 to a GUID\r
         expr = expr.strip()\r
         NumberDict = {}\r
-        for HexNumber in self.HexPattern.findall(expr):\r
+        for HexNumber in gHexPattern.findall(expr):\r
             Number = str(int(HexNumber, 16))\r
             NumberDict[HexNumber] = Number\r
         for HexNum in NumberDict:\r
@@ -341,18 +338,18 @@ class RangeExpression(object):
     def Eval(self, Operator, Oprand1, Oprand2 = None):\r
         \r
         if Operator in ["!", "NOT", "not"]:\r
-            if not self.RegGuidPattern.match(Oprand1.strip()):\r
+            if not gGuidPattern.match(Oprand1.strip()):\r
                 raise BadExpression(ERR_STRING_EXPR % Operator)\r
             return self.NegtiveRange(Oprand1)\r
         else:\r
             if Operator in ["==", ">=", "<=", ">", "<", '^']:\r
                 return self.EvalRange(Operator, Oprand1)\r
             elif Operator == 'and' :\r
-                if not self.ExRegGuidPattern.match(Oprand1.strip()) or not self.ExRegGuidPattern.match(Oprand2.strip()):\r
+                if not gGuidPatternEnd.match(Oprand1.strip()) or not gGuidPatternEnd.match(Oprand2.strip()):\r
                     raise BadExpression(ERR_STRING_EXPR % Operator)\r
                 return self.Rangeintersection(Oprand1, Oprand2)    \r
             elif Operator == 'or':\r
-                if not self.ExRegGuidPattern.match(Oprand1.strip()) or not self.ExRegGuidPattern.match(Oprand2.strip()):\r
+                if not gGuidPatternEnd.match(Oprand1.strip()) or not gGuidPatternEnd.match(Oprand2.strip()):\r
                     raise BadExpression(ERR_STRING_EXPR % Operator)\r
                 return self.Rangecollections(Oprand1, Oprand2)\r
             else:\r
@@ -410,7 +407,7 @@ class RangeExpression(object):
         # check if the expression does not need to evaluate\r
         if RealValue and Depth == 0:\r
             self._Token = self._Expr\r
-            if self.ExRegGuidPattern.match(self._Expr):\r
+            if gGuidPatternEnd.match(self._Expr):\r
                 return [self.operanddict[self._Expr] ]\r
 \r
             self._Idx = 0\r
@@ -626,7 +623,7 @@ class RangeExpression(object):
             self._LiteralToken.endswith('}'):\r
             return True\r
 \r
-        if self.HexPattern.match(self._LiteralToken):\r
+        if gHexPattern.match(self._LiteralToken):\r
             Token = self._LiteralToken[2:]\r
             Token = Token.lstrip('0')\r
             if not Token:\r
@@ -657,7 +654,7 @@ class RangeExpression(object):
         self._Token = ''\r
         if Expr:\r
             Ch = Expr[0]\r
-            Match = self.RegGuidPattern.match(Expr)\r
+            Match = gGuidPattern.match(Expr)\r
             if Match and not Expr[Match.end():Match.end() + 1].isalnum() \\r
                 and Expr[Match.end():Match.end() + 1] != '_':\r
                 self._Idx += Match.end()\r