]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/FdfParserLite.py
BaseTools: FdfParser and FdfParserLite share reg exp
[mirror_edk2.git] / BaseTools / Source / Python / Common / FdfParserLite.py
index 7d129bfcab5909d77e4bd81918e5beea89580f62..806fdd8aa5bb487cdbb23da1ffc5ecea51927e44 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # parse FDF file\r
 #\r
-#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -21,6 +21,7 @@ import Common.LongFilePathOs as os
 import CommonDataClass.FdfClass\r
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
 from Common.MultipleWorkspace import MultipleWorkspace as mws\r
+from Common.RangeExpression import RangeExpression\r
 \r
 ##define T_CHAR_SPACE                ' '\r
 ##define T_CHAR_NULL                 '\0'\r
@@ -46,6 +47,8 @@ InputMacroDict = {}
 # All Macro values when parsing file, not replace existing Macro\r
 AllMacroList = []\r
 \r
+FileExtensionPattern = re.compile(r'([a-zA-Z][a-zA-Z0-9]*)')\r
+\r
 def GetRealFileLine (File, Line):\r
     \r
     InsertedLines = 0\r
@@ -931,8 +934,7 @@ class FdfParser(object):
         \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
@@ -2842,8 +2844,7 @@ class FdfParser(object):
             \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