From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 065E621180F4F for ; Thu, 25 Oct 2018 06:57:23 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2018 06:57:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,424,1534834800"; d="scan'208";a="103223204" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 25 Oct 2018 06:57:23 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 25 Oct 2018 06:57:22 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 25 Oct 2018 06:57:22 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.102]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.214]) with mapi id 14.03.0415.000; Thu, 25 Oct 2018 21:57:19 +0800 From: "Feng, Bob C" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Zhu, Yonghong" , "Gao, Liming" Thread-Topic: [Patch v3 6/6] BaseTools/GenFds: create and use new variable in FdfParser Thread-Index: AQHUavYBchZUYmLDvk2VB2qTpEgvVKUv+6Nw Date: Thu, 25 Oct 2018 13:57:18 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D15FFE955A@SHSMSX101.ccr.corp.intel.com> References: <67768109f88780500595107275e7167b2b14aeea.1540315635.git.jaben.carsey@intel.com> In-Reply-To: <67768109f88780500595107275e7167b2b14aeea.1540315635.git.jaben.carsey@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGVjNWJiNDEtMTFjMy00ZWRjLThmNGItOTliOWU1YTY5M2YyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiUExxVHo5cUJ0RmwxREVCdUxPRHBGd1ZKcmlXOStCOTNUTlZ3a3d1R0M5TWg0ajRWQVRoanFcLytuV3MyTFpEUmQifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch v3 6/6] BaseTools/GenFds: create and use new variable in FdfParser X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2018 13:57:24 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Carsey, Jaben=20 Sent: Wednesday, October 24, 2018 1:29 AM To: edk2-devel@lists.01.org Cc: Feng, Bob C ; Zhu, Yonghong ; Gao, Liming Subject: [Patch v3 6/6] BaseTools/GenFds: create and use new variable in Fd= fParser replace lots of '}' and "}" with a shared new consistent variable. Cc: Bob Feng Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/GenFds/FdfParser.py | 45 ++++++++++---------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index d954c0b40b3b..bf6e0bd2286c 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -65,8 +65,9 @@ T_CHAR_TAB =3D '\t' T_CHAR_DOUBLE_QUOTE =3D '\"' T_CHAR_SINGLE_QUOTE =3D '\'' T_CHAR_STAR =3D '*' +T_CHAR_BRACE_R =3D '}' =20 -SEPARATORS =3D {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, TAB_COMMA_SPLIT, '{', '}= '} +SEPARATORS =3D {TAB_EQUAL_SPLIT, TAB_VALUE_SPLIT, TAB_COMMA_SPLIT, '{',=20 +T_CHAR_BRACE_R} ALIGNMENTS =3D {"Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "= 32K", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M"= , "16M"} ALIGNMENT_NOAUTO =3D ALIGNMENTS - {"Auto"} @@ -2021,7 +2022,7 @@ = class FdfParser: DataString +=3D self._Token DataString +=3D TAB_COMMA_SPLIT =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLi= neNumber) =20 DataString =3D DataString.rstrip(TAB_COMMA_SPLIT) @@ -2061,7 +2062,7 @@ class FdfParser: DataString +=3D self._Token DataString +=3D TAB_COMMA_SPLIT =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) =20 DataString =3D DataString.rstrip(TAB_COMMA_SPLIT) @@ -2330,10 +2331,10 @@ class FdfParser: DataString +=3D self._Token DataString +=3D TAB_COMMA_SPLIT =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) =20 DataString =3D DataString.rstrip(TAB_COMMA_SPLIT) @@ -2348,7 +2349,7 @@ class FdfParser: =20 FvObj.FvExtEntryData.append(self._Token) =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) =20 return True @@ -2384,7 +2385,7 @@ class FdfParser: if not IsInf and not IsFile: break =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLi= neNumber) =20 FvObj.AprioriSectionList.append(AprSectionObj) @@ -2659,7 +2660,7 @@ class FdfParser: FfsFileObj.FileName =3D self._Token.replace('$(SPACE)', ' ') self._VerifyFile(FfsFileObj.FileName) =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.CurrentLi= neNumber) =20 ## _GetRAWData() method @@ -2684,7 +2685,7 @@ class FdfParser: raise Warning.Expected("Filename value", self.FileName, se= lf.CurrentLineNumber) =20 FileName =3D self._Token.replace('$(SPACE)', ' ') - if FileName =3D=3D '}': + if FileName =3D=3D T_CHAR_BRACE_R: self._UndoToken() raise Warning.Expected("Filename value", self.FileName, se= lf.CurrentLineNumber) =20 @@ -2693,7 +2694,7 @@ class FdfParser: FfsFileObj.FileName.append(File.Path) FfsFileObj.SubAlignment.append(AlignValue) =20 - if self._IsToken("}"): + if self._IsToken(T_CHAR_BRACE_R): self._UndoToken() break =20 @@ -2865,7 +2866,7 @@ class FdfParser: if not IsInf and not IsFile: break =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.C= urrentLineNumber) =20 FvImageSectionObj =3D FvImageSection() @@ -2890,10 +2891,10 @@= class FdfParser: raise Warning.ExpectedEquals(self.FileName, self.CurrentLi= neNumber) if not self._IsToken("{"): raise Warning.ExpectedCurlyOpen(self.FileName, self.Curren= tLineNumber) - if not self._SkipToToken("}"): + if not self._SkipToToken(T_CHAR_BRACE_R): raise Warning.Expected("Depex expression ending '}'", self= .FileName, self.CurrentLineNumber) =20 - DepexSectionObj.Expression =3D self._SkippedChars.rstrip('}') + DepexSectionObj.Expression =3D=20 + self._SkippedChars.rstrip(T_CHAR_BRACE_R) Obj.SectionList.append(DepexSectionObj) =20 else: @@ -2984,7 +2985,7 @@ class FdfParser: break =20 =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) Obj.SectionList.append(CompressSectionObj) return True @@ -3011,7 +3012,7 @@ class FdfParser: if not IsLeafSection and not IsEncapSection: break =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) Obj.SectionList.append(GuidSectionObj) =20 @@ -3689,7 +3690,7 @@ class FdfParser: if not IsEncapsulate and not IsLeaf: break =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) =20 return NewRule @@ -3789,7 +3790,7 @@ class FdfParser: if not IsInf and not IsFile: break =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.C= urrentLineNumber) FvImageSectionObj.Fv =3D FvObj FvImageSectionObj.FvName =3D None @@ -3808,7 +3809,7 @@ cl= ass FdfParser: FvImageSectionObj.FvFileExtension =3D self._GetFileExt= ension() elif self._GetNextToken(): if self._Token not in { - "}", "COMPAT16", BINARY_FILE_TYPE_PE32, + T_CHAR_BRACE_R, "COMPAT16",=20 + BINARY_FILE_TYPE_PE32, BINARY_FILE_TYPE_PIC, BINARY_FILE_TYPE_TE, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX, BINARY_FILE_TYPE_UI, "VERSION", @@ -3894,7 +38= 95,7 @@ class FdfParser: EfiSectionObj.FileExtension =3D self._GetFileExtension() elif self._GetNextToken(): 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, "FV_IMAGE", "RAW", BINARY_FILE_TYPE_DXE_DEPEX, BINARY_FILE_TYPE_UI, "VERSION", @@ -4037,7 +4038,7 @@ = class FdfParser: if not IsEncapsulate and not IsLeaf: break =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) theRule.SectionList.append(CompressSectionObj) =20 @@ -4069,7 +4070,7 @@ class FdfParser: if not IsEncapsulate and not IsLeaf: break =20 - if not self._IsToken("}"): + if not self._IsToken(T_CHAR_BRACE_R): raise Warning.ExpectedCurlyClose(self.FileName, self.Curre= ntLineNumber) theRule.SectionList.append(GuidSectionObj) =20 @@ -4415,7 +4416,7 @@ class FdfParser: Overrides.NeedCompress =3D self._Token.upper() =3D=3D = 'TRUE' continue =20 - if self._IsToken("}"): + if self._IsToken(T_CHAR_BRACE_R): break else: EdkLogger.error("FdfParser", FORMAT_INVALID, File=3Dse= lf.FileName, Line=3Dself.CurrentLineNumber) -- 2.16.2.windows.1