BaseTools: use new RegEx from FdfParserLite
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>
Thu, 29 Mar 2018 21:38:07 +0000 (05:38 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Tue, 3 Apr 2018 09:36:15 +0000 (17:36 +0800)
FdfParser has identical one.  import and share.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@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/GenFds/FdfParser.py

index 346f4eeb0308fa050379d18668fad05eec119309..b3f83c072a9a3aeaaa72108ef9f43ce5a81dc651 100644 (file)
@@ -60,7 +60,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
 from Capsule import EFI_CERT_TYPE_PKCS7_GUID\r
 from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID\r
 from Common.RangeExpression import RangeExpression\r
 from Capsule import EFI_CERT_TYPE_PKCS7_GUID\r
 from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID\r
 from Common.RangeExpression import RangeExpression\r
-from Common.FdfParserLite import FileExtensionPattern\r
+from Common.FdfParserLite import FileExtensionPattern,TokenFindPattern\r
 \r
 ##define T_CHAR_SPACE                ' '\r
 ##define T_CHAR_NULL                 '\0'\r
 \r
 ##define T_CHAR_SPACE                ' '\r
 ##define T_CHAR_NULL                 '\0'\r
@@ -2797,12 +2797,11 @@ class FdfParser:
     def __GetFileOpts(self, FfsFileObj):\r
 \r
         if self.__GetNextToken():\r
     def __GetFileOpts(self, FfsFileObj):\r
 \r
         if self.__GetNextToken():\r
-            Pattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')\r
-            if Pattern.match(self.__Token):\r
+            if TokenFindPattern.match(self.__Token):\r
                 FfsFileObj.KeyStringList.append(self.__Token)\r
                 if self.__IsToken(","):\r
                     while self.__GetNextToken():\r
                 FfsFileObj.KeyStringList.append(self.__Token)\r
                 if self.__IsToken(","):\r
                     while self.__GetNextToken():\r
-                        if not Pattern.match(self.__Token):\r
+                        if not TokenFindPattern.match(self.__Token):\r
                             raise Warning("expected KeyString \"Target_Tag_Arch\"", self.FileName, self.CurrentLineNumber)\r
                         FfsFileObj.KeyStringList.append(self.__Token)\r
 \r
                             raise Warning("expected KeyString \"Target_Tag_Arch\"", self.FileName, self.CurrentLineNumber)\r
                         FfsFileObj.KeyStringList.append(self.__Token)\r
 \r
@@ -3746,12 +3745,11 @@ class FdfParser:
 \r
         KeyStringList = []\r
         if self.__GetNextToken():\r
 \r
         KeyStringList = []\r
         if self.__GetNextToken():\r
-            Pattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')\r
-            if Pattern.match(self.__Token):\r
+            if TokenFindPattern.match(self.__Token):\r
                 KeyStringList.append(self.__Token)\r
                 if self.__IsToken(","):\r
                     while self.__GetNextToken():\r
                 KeyStringList.append(self.__Token)\r
                 if self.__IsToken(","):\r
                     while self.__GetNextToken():\r
-                        if not Pattern.match(self.__Token):\r
+                        if not TokenFindPattern.match(self.__Token):\r
                             raise Warning("expected KeyString \"Target_Tag_Arch\"", self.FileName, self.CurrentLineNumber)\r
                         KeyStringList.append(self.__Token)\r
 \r
                             raise Warning("expected KeyString \"Target_Tag_Arch\"", self.FileName, self.CurrentLineNumber)\r
                         KeyStringList.append(self.__Token)\r
 \r