mirror of https://github.com/acidanthera/audk.git
BaseTools/GenFds: create and use new variable in FdfParser
replace lots of '}' and "}" with a shared new consistent variable. Cc: Bob Feng <bob.c.feng@intel.com> 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>
This commit is contained in:
parent
ca957eb5cd
commit
ea98a8254a
|
@ -65,8 +65,9 @@ T_CHAR_TAB = '\t'
|
||||||
T_CHAR_DOUBLE_QUOTE = '\"'
|
T_CHAR_DOUBLE_QUOTE = '\"'
|
||||||
T_CHAR_SINGLE_QUOTE = '\''
|
T_CHAR_SINGLE_QUOTE = '\''
|
||||||
T_CHAR_STAR = '*'
|
T_CHAR_STAR = '*'
|
||||||
|
T_CHAR_BRACE_R = '}'
|
||||||
|
|
||||||
SEPARATORS = {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, TAB_COMMA_SPLIT, '{', '}'}
|
SEPARATORS = {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, TAB_COMMA_SPLIT, '{', T_CHAR_BRACE_R}
|
||||||
ALIGNMENTS = {"Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K", "64K", "128K",
|
ALIGNMENTS = {"Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K", "64K", "128K",
|
||||||
"256K", "512K", "1M", "2M", "4M", "8M", "16M"}
|
"256K", "512K", "1M", "2M", "4M", "8M", "16M"}
|
||||||
ALIGNMENT_NOAUTO = ALIGNMENTS - {"Auto"}
|
ALIGNMENT_NOAUTO = ALIGNMENTS - {"Auto"}
|
||||||
|
@ -2021,7 +2022,7 @@ class FdfParser:
|
||||||
DataString += self._Token
|
DataString += self._Token
|
||||||
DataString += TAB_COMMA_SPLIT
|
DataString += TAB_COMMA_SPLIT
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
DataString = DataString.rstrip(TAB_COMMA_SPLIT)
|
DataString = DataString.rstrip(TAB_COMMA_SPLIT)
|
||||||
|
@ -2061,7 +2062,7 @@ class FdfParser:
|
||||||
DataString += self._Token
|
DataString += self._Token
|
||||||
DataString += TAB_COMMA_SPLIT
|
DataString += TAB_COMMA_SPLIT
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
DataString = DataString.rstrip(TAB_COMMA_SPLIT)
|
DataString = DataString.rstrip(TAB_COMMA_SPLIT)
|
||||||
|
@ -2330,10 +2331,10 @@ class FdfParser:
|
||||||
DataString += self._Token
|
DataString += self._Token
|
||||||
DataString += TAB_COMMA_SPLIT
|
DataString += TAB_COMMA_SPLIT
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
DataString = DataString.rstrip(TAB_COMMA_SPLIT)
|
DataString = DataString.rstrip(TAB_COMMA_SPLIT)
|
||||||
|
@ -2348,7 +2349,7 @@ class FdfParser:
|
||||||
|
|
||||||
FvObj.FvExtEntryData.append(self._Token)
|
FvObj.FvExtEntryData.append(self._Token)
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -2384,7 +2385,7 @@ class FdfParser:
|
||||||
if not IsInf and not IsFile:
|
if not IsInf and not IsFile:
|
||||||
break
|
break
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
FvObj.AprioriSectionList.append(AprSectionObj)
|
FvObj.AprioriSectionList.append(AprSectionObj)
|
||||||
|
@ -2659,7 +2660,7 @@ class FdfParser:
|
||||||
FfsFileObj.FileName = self._Token.replace('$(SPACE)', ' ')
|
FfsFileObj.FileName = self._Token.replace('$(SPACE)', ' ')
|
||||||
self._VerifyFile(FfsFileObj.FileName)
|
self._VerifyFile(FfsFileObj.FileName)
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
## _GetRAWData() method
|
## _GetRAWData() method
|
||||||
|
@ -2684,7 +2685,7 @@ class FdfParser:
|
||||||
raise Warning.Expected("Filename value", self.FileName, self.CurrentLineNumber)
|
raise Warning.Expected("Filename value", self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
FileName = self._Token.replace('$(SPACE)', ' ')
|
FileName = self._Token.replace('$(SPACE)', ' ')
|
||||||
if FileName == '}':
|
if FileName == T_CHAR_BRACE_R:
|
||||||
self._UndoToken()
|
self._UndoToken()
|
||||||
raise Warning.Expected("Filename value", self.FileName, self.CurrentLineNumber)
|
raise Warning.Expected("Filename value", self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
|
@ -2693,7 +2694,7 @@ class FdfParser:
|
||||||
FfsFileObj.FileName.append(File.Path)
|
FfsFileObj.FileName.append(File.Path)
|
||||||
FfsFileObj.SubAlignment.append(AlignValue)
|
FfsFileObj.SubAlignment.append(AlignValue)
|
||||||
|
|
||||||
if self._IsToken("}"):
|
if self._IsToken(T_CHAR_BRACE_R):
|
||||||
self._UndoToken()
|
self._UndoToken()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -2865,7 +2866,7 @@ class FdfParser:
|
||||||
if not IsInf and not IsFile:
|
if not IsInf and not IsFile:
|
||||||
break
|
break
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
FvImageSectionObj = FvImageSection()
|
FvImageSectionObj = FvImageSection()
|
||||||
|
@ -2890,10 +2891,10 @@ class FdfParser:
|
||||||
raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
|
||||||
if not self._IsToken("{"):
|
if not self._IsToken("{"):
|
||||||
raise Warning.ExpectedCurlyOpen(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyOpen(self.FileName, self.CurrentLineNumber)
|
||||||
if not self._SkipToToken("}"):
|
if not self._SkipToToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.Expected("Depex expression ending '}'", self.FileName, self.CurrentLineNumber)
|
raise Warning.Expected("Depex expression ending '}'", self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
DepexSectionObj.Expression = self._SkippedChars.rstrip('}')
|
DepexSectionObj.Expression = self._SkippedChars.rstrip(T_CHAR_BRACE_R)
|
||||||
Obj.SectionList.append(DepexSectionObj)
|
Obj.SectionList.append(DepexSectionObj)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -2984,7 +2985,7 @@ class FdfParser:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
Obj.SectionList.append(CompressSectionObj)
|
Obj.SectionList.append(CompressSectionObj)
|
||||||
return True
|
return True
|
||||||
|
@ -3011,7 +3012,7 @@ class FdfParser:
|
||||||
if not IsLeafSection and not IsEncapSection:
|
if not IsLeafSection and not IsEncapSection:
|
||||||
break
|
break
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
Obj.SectionList.append(GuidSectionObj)
|
Obj.SectionList.append(GuidSectionObj)
|
||||||
|
|
||||||
|
@ -3689,7 +3690,7 @@ class FdfParser:
|
||||||
if not IsEncapsulate and not IsLeaf:
|
if not IsEncapsulate and not IsLeaf:
|
||||||
break
|
break
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
|
|
||||||
return NewRule
|
return NewRule
|
||||||
|
@ -3789,7 +3790,7 @@ class FdfParser:
|
||||||
if not IsInf and not IsFile:
|
if not IsInf and not IsFile:
|
||||||
break
|
break
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
FvImageSectionObj.Fv = FvObj
|
FvImageSectionObj.Fv = FvObj
|
||||||
FvImageSectionObj.FvName = None
|
FvImageSectionObj.FvName = None
|
||||||
|
@ -3808,7 +3809,7 @@ class FdfParser:
|
||||||
FvImageSectionObj.FvFileExtension = self._GetFileExtension()
|
FvImageSectionObj.FvFileExtension = self._GetFileExtension()
|
||||||
elif self._GetNextToken():
|
elif self._GetNextToken():
|
||||||
if self._Token not in {
|
if self._Token not in {
|
||||||
"}", "COMPAT16", BINARY_FILE_TYPE_PE32,
|
T_CHAR_BRACE_R, "COMPAT16", BINARY_FILE_TYPE_PE32,
|
||||||
BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE,
|
BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE,
|
||||||
"FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,
|
"FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,
|
||||||
BINARY_FILE_TYPE_UI, "VERSION",
|
BINARY_FILE_TYPE_UI, "VERSION",
|
||||||
|
@ -3894,7 +3895,7 @@ class FdfParser:
|
||||||
EfiSectionObj.FileExtension = self._GetFileExtension()
|
EfiSectionObj.FileExtension = self._GetFileExtension()
|
||||||
elif self._GetNextToken():
|
elif self._GetNextToken():
|
||||||
if self._Token not in {
|
if self._Token not in {
|
||||||
"}", "COMPAT16", BINARY_FILE_TYPE_PE32,
|
T_CHAR_BRACE_R, "COMPAT16", BINARY_FILE_TYPE_PE32,
|
||||||
BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE,
|
BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE,
|
||||||
"FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,
|
"FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX,
|
||||||
BINARY_FILE_TYPE_UI, "VERSION",
|
BINARY_FILE_TYPE_UI, "VERSION",
|
||||||
|
@ -4037,7 +4038,7 @@ class FdfParser:
|
||||||
if not IsEncapsulate and not IsLeaf:
|
if not IsEncapsulate and not IsLeaf:
|
||||||
break
|
break
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
theRule.SectionList.append(CompressSectionObj)
|
theRule.SectionList.append(CompressSectionObj)
|
||||||
|
|
||||||
|
@ -4069,7 +4070,7 @@ class FdfParser:
|
||||||
if not IsEncapsulate and not IsLeaf:
|
if not IsEncapsulate and not IsLeaf:
|
||||||
break
|
break
|
||||||
|
|
||||||
if not self._IsToken("}"):
|
if not self._IsToken(T_CHAR_BRACE_R):
|
||||||
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLineNumber)
|
||||||
theRule.SectionList.append(GuidSectionObj)
|
theRule.SectionList.append(GuidSectionObj)
|
||||||
|
|
||||||
|
@ -4415,7 +4416,7 @@ class FdfParser:
|
||||||
Overrides.NeedCompress = self._Token.upper() == 'TRUE'
|
Overrides.NeedCompress = self._Token.upper() == 'TRUE'
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if self._IsToken("}"):
|
if self._IsToken(T_CHAR_BRACE_R):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
EdkLogger.error("FdfParser", FORMAT_INVALID, File=self.FileName, Line=self.CurrentLineNumber)
|
EdkLogger.error("FdfParser", FORMAT_INVALID, File=self.FileName, Line=self.CurrentLineNumber)
|
||||||
|
|
Loading…
Reference in New Issue