]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/GenFds/FdfParser.py
BaseTools: FdfParser and FdfParserLite share reg exp
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FdfParser.py
index 76d7e6ac1903493c5c73edde44b6b15a3c6f0fd3..08429cd72affc0fe2af6335fdb5965e90603ec9f 100644 (file)
@@ -59,6 +59,8 @@ import Common.LongFilePathOs as os
 from Common.LongFilePathSupport import OpenLongFilePath as open\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
 \r
 ##define T_CHAR_SPACE                ' '\r
 ##define T_CHAR_NULL                 '\0'\r
@@ -135,21 +137,6 @@ class Warning (Exception):
     def __str__(self):\r
         return self.Message\r
 \r
-## The MACRO class that used to record macro value data when parsing include file\r
-#\r
-#\r
-class MacroProfile :\r
-    ## The constructor\r
-    #\r
-    #   @param  self        The object pointer\r
-    #   @param  FileName    The file that to be parsed\r
-    #\r
-    def __init__(self, FileName, Line):\r
-        self.FileName = FileName\r
-        self.DefinedAtLine  = Line\r
-        self.MacroName = None\r
-        self.MacroValue = None\r
-\r
 ## The Include file content class that used to record file data when parsing include file\r
 #\r
 # May raise Exception when opening file.\r
@@ -927,6 +914,8 @@ class FdfParser:
         MacroDict.update(GlobalData.gCommandLineDefines)\r
         if GlobalData.BuildOptionPcd:\r
             for Item in GlobalData.BuildOptionPcd:\r
+                if type(Item) is tuple:\r
+                    continue\r
                 PcdName, TmpValue = Item.split("=")\r
                 TmpValue = BuildOptionValue(TmpValue, {})\r
                 MacroDict[PcdName.strip()] = TmpValue\r
@@ -1147,8 +1136,7 @@ class FdfParser:
 \r
         if not self.__GetNextToken():\r
             return False\r
-        p = re.compile('[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}')\r
-        if p.match(self.__Token) != None:\r
+        if RangeExpression.RegGuidPattern.match(self.__Token) != None:\r
             return True\r
         else:\r
             self.__UndoToken()\r
@@ -3704,8 +3692,7 @@ class FdfParser:
 \r
         Ext = ""\r
         if self.__GetNextToken():\r
-            Pattern = re.compile(r'([a-zA-Z][a-zA-Z0-9]*)')\r
-            if Pattern.match(self.__Token):\r
+            if FileExtensionPattern.match(self.__Token):\r
                 Ext = self.__Token\r
                 return '.' + Ext\r
             else:\r