mirror of https://github.com/acidanthera/audk.git
BaseTools: use single RegExp for token matching
same pattern was compiled 3 places in the file. just compile once 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>
This commit is contained in:
parent
5b91bf82c6
commit
4f9e71e1f7
|
@ -49,6 +49,7 @@ InputMacroDict = {}
|
||||||
AllMacroList = []
|
AllMacroList = []
|
||||||
|
|
||||||
FileExtensionPattern = re.compile(r'([a-zA-Z][a-zA-Z0-9]*)')
|
FileExtensionPattern = re.compile(r'([a-zA-Z][a-zA-Z0-9]*)')
|
||||||
|
TokenFindPattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
|
||||||
|
|
||||||
def GetRealFileLine (File, Line):
|
def GetRealFileLine (File, Line):
|
||||||
|
|
||||||
|
@ -2094,8 +2095,7 @@ class FdfParser(object):
|
||||||
|
|
||||||
|
|
||||||
if self.__GetNextToken():
|
if self.__GetNextToken():
|
||||||
p = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
|
if TokenFindPattern.match(self.__Token):
|
||||||
if p.match(self.__Token):
|
|
||||||
FfsInfObj.KeyStringList.append(self.__Token)
|
FfsInfObj.KeyStringList.append(self.__Token)
|
||||||
if not self.__IsToken(","):
|
if not self.__IsToken(","):
|
||||||
return
|
return
|
||||||
|
@ -2104,7 +2104,7 @@ class FdfParser(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
while self.__GetNextToken():
|
while self.__GetNextToken():
|
||||||
if not p.match(self.__Token):
|
if not TokenFindPattern.match(self.__Token):
|
||||||
raise Warning("expected KeyString \"Target_Tag_Arch\" At Line ", self.FileName, self.CurrentLineNumber)
|
raise Warning("expected KeyString \"Target_Tag_Arch\" At Line ", self.FileName, self.CurrentLineNumber)
|
||||||
FfsInfObj.KeyStringList.append(self.__Token)
|
FfsInfObj.KeyStringList.append(self.__Token)
|
||||||
|
|
||||||
|
@ -2252,12 +2252,11 @@ class FdfParser(object):
|
||||||
def __GetFileOpts(self, FfsFileObj):
|
def __GetFileOpts(self, FfsFileObj):
|
||||||
|
|
||||||
if self.__GetNextToken():
|
if self.__GetNextToken():
|
||||||
Pattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
|
if TokenFindPattern.match(self.__Token):
|
||||||
if Pattern.match(self.__Token):
|
|
||||||
FfsFileObj.KeyStringList.append(self.__Token)
|
FfsFileObj.KeyStringList.append(self.__Token)
|
||||||
if self.__IsToken(","):
|
if self.__IsToken(","):
|
||||||
while self.__GetNextToken():
|
while self.__GetNextToken():
|
||||||
if not Pattern.match(self.__Token):
|
if not TokenFindPattern.match(self.__Token):
|
||||||
raise Warning("expected KeyString \"Target_Tag_Arch\" At Line ", self.FileName, self.CurrentLineNumber)
|
raise Warning("expected KeyString \"Target_Tag_Arch\" At Line ", self.FileName, self.CurrentLineNumber)
|
||||||
FfsFileObj.KeyStringList.append(self.__Token)
|
FfsFileObj.KeyStringList.append(self.__Token)
|
||||||
|
|
||||||
|
@ -2902,12 +2901,11 @@ class FdfParser(object):
|
||||||
|
|
||||||
KeyStringList = []
|
KeyStringList = []
|
||||||
if self.__GetNextToken():
|
if self.__GetNextToken():
|
||||||
Pattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
|
if TokenFindPattern.match(self.__Token):
|
||||||
if Pattern.match(self.__Token):
|
|
||||||
KeyStringList.append(self.__Token)
|
KeyStringList.append(self.__Token)
|
||||||
if self.__IsToken(","):
|
if self.__IsToken(","):
|
||||||
while self.__GetNextToken():
|
while self.__GetNextToken():
|
||||||
if not Pattern.match(self.__Token):
|
if not TokenFindPattern.match(self.__Token):
|
||||||
raise Warning("expected KeyString \"Target_Tag_Arch\" At Line ", self.FileName, self.CurrentLineNumber)
|
raise Warning("expected KeyString \"Target_Tag_Arch\" At Line ", self.FileName, self.CurrentLineNumber)
|
||||||
KeyStringList.append(self.__Token)
|
KeyStringList.append(self.__Token)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue