From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web10.9648.1591174092723471280 for ; Wed, 03 Jun 2020 01:48:14 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: shenglei.zhang@intel.com) IronPort-SDR: JTlVZc/Lg6Y9u//S9wsn4N9HP7nRvjng2NIKnUB+C8fG59fjWS8Pl48yCdUXizDw7s9Oi0zaop Lgw+oVS5fFmQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2020 01:48:14 -0700 IronPort-SDR: AIjpAcx9RBhUhBF6b8NPJPSn3IBVkMXjNFkpFYl7MsaYbA2YX/x2KuvDxkRi41e5wmyW9zTrCo j45iAbKJ7Opg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,467,1583222400"; d="scan'208";a="470975800" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by fmsmga006.fm.intel.com with ESMTP; 03 Jun 2020 01:48:12 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: "Fan, Zhiju" , Bob Feng , Liming Gao Subject: [PATCH v2 1/5] BaseTools:ECC needs to update the contents of CParser4 Date: Wed, 3 Jun 2020 16:48:03 +0800 Message-Id: <20200603084807.24484-2-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20200603084807.24484-1-shenglei.zhang@intel.com> References: <20200603084807.24484-1-shenglei.zhang@intel.com> From: "Fan, Zhiju" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2676 Because Ecc relies on the antlr extension package, When the antlr version is updated, we need to change the code in it. Currently, if you use the latest version antlr4.8, Ecc will fail We will update the version to support the use of antlr4.8 and all previous versions will have errors.This can be resolved by installing the antlr4.8 version. Installation method: pip install antlr4-python3-runtime==4.8 This patch is going to fixed this issue Cc: Bob Feng Cc: Liming Gao Signed-off-by: Zhiju.Fan --- .../Source/Python/Ecc/CParser4/CLexer.py | 6 +-- .../Source/Python/Ecc/CParser4/CListener.py | 4 +- .../Source/Python/Ecc/CParser4/CParser.py | 38 ++++++++++--------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/CParser4/CLexer.py b/BaseTools/Source/Python/Ecc/CParser4/CLexer.py index a2cc5bf56e66..40e2afbf1a1f 100644 --- a/BaseTools/Source/Python/Ecc/CParser4/CLexer.py +++ b/BaseTools/Source/Python/Ecc/CParser4/CLexer.py @@ -1,4 +1,4 @@ -# Generated from C.g4 by ANTLR 4.7.1 +# Generated from C.g4 by ANTLR 4.8 from antlr4 import * from io import StringIO from typing.io import TextIO @@ -12,7 +12,7 @@ import sys # This file is generated by running: # java org.antlr.Tool C.g # -# Copyright (c) 2009 - 2010, Intel Corporation All rights reserved. +# Copyright (c) 2009 - 2020, Intel Corporation All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -584,7 +584,7 @@ class CLexer(Lexer): # @param output= sys.stdout Type: TextIO def __init__(self,input=None,output= sys.stdout): super().__init__(input, output) - self.checkVersion("4.7.1") + self.checkVersion("4.8") self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) self._actions = None self._predicates = None diff --git a/BaseTools/Source/Python/Ecc/CParser4/CListener.py b/BaseTools/Source/Python/Ecc/CParser4/CListener.py index bb4351d9249a..ba7e70892680 100644 --- a/BaseTools/Source/Python/Ecc/CParser4/CListener.py +++ b/BaseTools/Source/Python/Ecc/CParser4/CListener.py @@ -1,4 +1,4 @@ -# Generated from C.g4 by ANTLR 4.7.1 +# Generated from C.g4 by ANTLR 4.8 from antlr4 import * if __name__ is not None and "." in __name__: from .CParser import CParser @@ -12,7 +12,7 @@ else: # This file is generated by running: # java org.antlr.Tool C.g # -# Copyright (c) 2009 - 2010, Intel Corporation All rights reserved. +# Copyright (c) 2009 - 2020, Intel Corporation All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/BaseTools/Source/Python/Ecc/CParser4/CParser.py b/BaseTools/Source/Python/Ecc/CParser4/CParser.py index 31d23d55aa57..30d70a74e669 100644 --- a/BaseTools/Source/Python/Ecc/CParser4/CParser.py +++ b/BaseTools/Source/Python/Ecc/CParser4/CParser.py @@ -1,10 +1,12 @@ -# Generated from C.g4 by ANTLR 4.7.1 +# Generated from C.g4 by ANTLR 4.8 # encoding: utf-8 from antlr4 import * from io import StringIO -from typing.io import TextIO import sys - +if sys.version_info[1] > 5: + from typing import TextIO +else: + from typing.io import TextIO ## @file # The file defines the parser for C source files. @@ -13,7 +15,7 @@ import sys # This file is generated by running: # java org.antlr.Tool C.g # -# Copyright (c) 2009 - 2010, Intel Corporation All rights reserved. +# Copyright (c) 2009 - 2020, Intel Corporation All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -739,7 +741,7 @@ class CParser ( Parser ): # @param output= sys.stdout Type: TextIO def __init__(self,input,output= sys.stdout): super().__init__(input, output) - self.checkVersion("4.7.1") + self.checkVersion("4.8") self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache) self._predicates = None @@ -1062,10 +1064,10 @@ class CParser ( Parser ): if localctx.d != None: - ModifierText = (None if localctx._declaration_specifiers is None else self._input.getText((localctx._declaration_specifiers.start,localctx._declaration_specifiers.stop))) + ModifierText = (None if localctx._declaration_specifiers is None else self._input.getText(localctx._declaration_specifiers.start,localctx._declaration_specifiers.stop)) else: ModifierText = '' - DeclText = (None if localctx._declarator is None else self._input.getText((localctx._declarator.start,localctx._declarator.stop))) + DeclText = (None if localctx._declarator is None else self._input.getText(localctx._declarator.start,localctx._declarator.stop)) DeclLine = (None if localctx._declarator is None else localctx._declarator.start).line DeclOffset = (None if localctx._declarator is None else localctx._declarator.start).column if localctx.a != None: @@ -1245,9 +1247,9 @@ class CParser ( Parser ): localctx.d = self.match(CParser.T__1) if localctx.b is not None: - self.StoreTypedefDefinition(localctx.a.line, localctx.a.column, (0 if localctx.d is None else localctx.d.line), localctx.d.column, (None if localctx.b is None else self._input.getText((localctx.b.start,localctx.b.stop))), (None if localctx.c is None else self._input.getText((localctx.c.start,localctx.c.stop)))) + self.StoreTypedefDefinition(localctx.a.line, localctx.a.column, (0 if localctx.d is None else localctx.d.line), localctx.d.column, (None if localctx.b is None else self._input.getText(localctx.b.start,localctx.b.stop)), (None if localctx.c is None else self._input.getText(localctx.c.start,localctx.c.stop))) else: - self.StoreTypedefDefinition(localctx.a.line, localctx.a.column, (0 if localctx.d is None else localctx.d.line), localctx.d.column, '', (None if localctx.c is None else self._input.getText((localctx.c.start,localctx.c.stop)))) + self.StoreTypedefDefinition(localctx.a.line, localctx.a.column, (0 if localctx.d is None else localctx.d.line), localctx.d.column, '', (None if localctx.c is None else self._input.getText(localctx.c.start,localctx.c.stop))) pass elif token in [CParser.T__5, CParser.T__6, CParser.T__7, CParser.T__8, CParser.T__9, CParser.T__10, CParser.T__11, CParser.T__12, CParser.T__13, CParser.T__14, CParser.T__15, CParser.T__16, CParser.T__17, CParser.T__18, CParser.T__20, CParser.T__21, CParser.T__23, CParser.T__24, CParser.T__25, CParser.T__26, CParser.T__27, CParser.T__28, CParser.T__29, CParser.T__30, CParser.T__31, CParser.T__32, CParser.T__33, CParser.T__34, CParser.T__35, CParser.T__36, CParser.IDENTIFIER]: @@ -1266,7 +1268,7 @@ class CParser ( Parser ): localctx.e = self.match(CParser.T__1) if localctx.t is not None: - self.StoreVariableDeclaration((None if localctx.s is None else localctx.s.start).line, (None if localctx.s is None else localctx.s.start).column, (None if localctx.t is None else localctx.t.start).line, (None if localctx.t is None else localctx.t.start).column, (None if localctx.s is None else self._input.getText((localctx.s.start,localctx.s.stop))), (None if localctx.t is None else self._input.getText((localctx.t.start,localctx.t.stop)))) + self.StoreVariableDeclaration((None if localctx.s is None else localctx.s.start).line, (None if localctx.s is None else localctx.s.start).column, (None if localctx.t is None else localctx.t.start).line, (None if localctx.t is None else localctx.t.start).column, (None if localctx.s is None else self._input.getText(localctx.s.start,localctx.s.stop)), (None if localctx.t is None else self._input.getText(localctx.t.start,localctx.t.stop))) pass else: @@ -1568,7 +1570,7 @@ class CParser ( Parser ): localctx.s = self.struct_or_union_specifier() if localctx.s.stop is not None: - self.StoreStructUnionDefinition((None if localctx.s is None else localctx.s.start).line, (None if localctx.s is None else localctx.s.start).column, (None if localctx.s is None else localctx.s.stop).line, (None if localctx.s is None else localctx.s.stop).column, (None if localctx.s is None else self._input.getText((localctx.s.start,localctx.s.stop)))) + self.StoreStructUnionDefinition((None if localctx.s is None else localctx.s.start).line, (None if localctx.s is None else localctx.s.start).column, (None if localctx.s is None else localctx.s.stop).line, (None if localctx.s is None else localctx.s.stop).column, (None if localctx.s is None else self._input.getText(localctx.s.start,localctx.s.stop))) pass @@ -1578,7 +1580,7 @@ class CParser ( Parser ): localctx.e = self.enum_specifier() if localctx.e.stop is not None: - self.StoreEnumerationDefinition((None if localctx.e is None else localctx.e.start).line, (None if localctx.e is None else localctx.e.start).column, (None if localctx.e is None else localctx.e.stop).line, (None if localctx.e is None else localctx.e.stop).column, (None if localctx.e is None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StoreEnumerationDefinition((None if localctx.e is None else localctx.e.start).line, (None if localctx.e is None else localctx.e.start).column, (None if localctx.e is None else localctx.e.stop).line, (None if localctx.e is None else localctx.e.stop).column, (None if localctx.e is None else self._input.getText(localctx.e.start,localctx.e.stop))) pass @@ -4022,7 +4024,7 @@ class CParser ( Parser ): self.enterOuterAlt(localctx, 1) self.state = 569 localctx.p = self.primary_expression() - self.FuncCallText += (None if localctx.p is None else self._input.getText((localctx.p.start,localctx.p.stop))) + self.FuncCallText += (None if localctx.p is None else self._input.getText(localctx.p.start,localctx.p.stop)) self.state = 600 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,73,self._ctx) @@ -4055,7 +4057,7 @@ class CParser ( Parser ): localctx.c = self.argument_expression_list() self.state = 580 localctx.b = self.match(CParser.T__38) - self.StoreFunctionCalling((None if localctx.p is None else localctx.p.start).line, (None if localctx.p is None else localctx.p.start).column, (0 if localctx.b is None else localctx.b.line), localctx.b.column, self.FuncCallText, (None if localctx.c is None else self._input.getText((localctx.c.start,localctx.c.stop)))) + self.StoreFunctionCalling((None if localctx.p is None else localctx.p.start).line, (None if localctx.p is None else localctx.p.start).column, (0 if localctx.b is None else localctx.b.line), localctx.b.column, self.FuncCallText, (None if localctx.c is None else self._input.getText(localctx.c.start,localctx.c.stop))) pass elif la_ == 4: @@ -4770,7 +4772,7 @@ class CParser ( Parser ): self.match(CParser.T__22) self.state = 674 self.conditional_expression() - self.StorePredicateExpression((None if localctx.e is None else localctx.e.start).line, (None if localctx.e is None else localctx.e.start).column, (None if localctx.e is None else localctx.e.stop).line, (None if localctx.e is None else localctx.e.stop).column, (None if localctx.e is None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StorePredicateExpression((None if localctx.e is None else localctx.e.start).line, (None if localctx.e is None else localctx.e.start).column, (None if localctx.e is None else localctx.e.stop).line, (None if localctx.e is None else localctx.e.stop).column, (None if localctx.e is None else self._input.getText(localctx.e.start,localctx.e.stop))) except RecognitionException as re: @@ -6053,7 +6055,7 @@ class CParser ( Parser ): localctx.e = self.expression() self.state = 845 self.match(CParser.T__38) - self.StorePredicateExpression((None if localctx.e is None else localctx.e.start).line, (None if localctx.e is None else localctx.e.start).column, (None if localctx.e is None else localctx.e.stop).line, (None if localctx.e is None else localctx.e.stop).column, (None if localctx.e is None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StorePredicateExpression((None if localctx.e is None else localctx.e.start).line, (None if localctx.e is None else localctx.e.start).column, (None if localctx.e is None else localctx.e.stop).line, (None if localctx.e is None else localctx.e.stop).column, (None if localctx.e is None else self._input.getText(localctx.e.start,localctx.e.stop))) self.state = 847 self.statement() self.state = 850 @@ -6144,7 +6146,7 @@ class CParser ( Parser ): self.match(CParser.T__38) self.state = 864 self.statement() - self.StorePredicateExpression((None if localctx.e is None else localctx.e.start).line, (None if localctx.e is None else localctx.e.start).column, (None if localctx.e is None else localctx.e.stop).line, (None if localctx.e is None else localctx.e.stop).column, (None if localctx.e is None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StorePredicateExpression((None if localctx.e is None else localctx.e.start).line, (None if localctx.e is None else localctx.e.start).column, (None if localctx.e is None else localctx.e.stop).line, (None if localctx.e is None else localctx.e.stop).column, (None if localctx.e is None else self._input.getText(localctx.e.start,localctx.e.stop))) pass elif token in [CParser.T__87]: self.enterOuterAlt(localctx, 2) @@ -6162,7 +6164,7 @@ class CParser ( Parser ): self.match(CParser.T__38) self.state = 873 self.match(CParser.T__1) - self.StorePredicateExpression((None if localctx.e is None else localctx.e.start).line, (None if localctx.e is None else localctx.e.start).column, (None if localctx.e is None else localctx.e.stop).line, (None if localctx.e is None else localctx.e.stop).column, (None if localctx.e is None else self._input.getText((localctx.e.start,localctx.e.stop)))) + self.StorePredicateExpression((None if localctx.e is None else localctx.e.start).line, (None if localctx.e is None else localctx.e.start).column, (None if localctx.e is None else localctx.e.stop).line, (None if localctx.e is None else localctx.e.stop).column, (None if localctx.e is None else self._input.getText(localctx.e.start,localctx.e.stop))) pass else: raise NoViableAltException(self) -- 2.18.0.windows.1