BaseTools: use new shared GUID regular expressions
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>
Fri, 16 Mar 2018 23:27:41 +0000 (07:27 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Thu, 29 Mar 2018 08:18:29 +0000 (16:18 +0800)
remove local variables that are GUID matching and replace with shared
expression.

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/Common/Expression.py
BaseTools/Source/Python/Common/FdfParserLite.py
BaseTools/Source/Python/Common/RangeExpression.py
BaseTools/Source/Python/GenFds/FdfParser.py

index 4f0f377f37880a2eb9981ba52c778f4a9d93bc90..287dddfbbc7ce4f21ecb64a27b8ec010883e49f5 100644 (file)
@@ -214,7 +214,6 @@ class ValueExpression(object):
 \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
 \r
     SymbolPattern = re.compile("("\r
                                  "\$\([A-Z][A-Z0-9_]*\)|\$\(\w+\.\w+\)|\w+\.\w+|"\r
@@ -725,7 +724,7 @@ class ValueExpression(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
index 806fdd8aa5bb487cdbb23da1ffc5ecea51927e44..b7b5e21a9e3f4c703b784066ed69ba9f6a835358 100644 (file)
@@ -22,6 +22,7 @@ import CommonDataClass.FdfClass
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
 from Common.MultipleWorkspace import MultipleWorkspace as mws\r
 from Common.RangeExpression import RangeExpression\r
+from Common.GlobalData import *\r
 \r
 ##define T_CHAR_SPACE                ' '\r
 ##define T_CHAR_NULL                 '\0'\r
@@ -934,7 +935,7 @@ class FdfParser(object):
         \r
         if not self.__GetNextToken():\r
             return False\r
-        if RangeExpression.RegGuidPattern.match(self.__Token) != None:\r
+        if gGuidPattern.match(self.__Token) != None:\r
             return True\r
         else:\r
             self.__UndoToken()\r
index 3449711dcc08c6161286f60b63f5a1f18114de14..540f95728072b8b8666e56e0eff757ae11753104 100644 (file)
@@ -211,8 +211,6 @@ class RangeExpression(object):
 \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
@@ -341,18 +339,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 +408,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
@@ -657,7 +655,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
index 08429cd72affc0fe2af6335fdb5965e90603ec9f..9903e9570cf928e0ab5fd743fd86771b900de034 100644 (file)
@@ -1136,7 +1136,7 @@ class FdfParser:
 \r
         if not self.__GetNextToken():\r
             return False\r
-        if RangeExpression.RegGuidPattern.match(self.__Token) != None:\r
+        if gGuidPattern.match(self.__Token) != None:\r
             return True\r
         else:\r
             self.__UndoToken()\r