[edk2-devel] [PATCH v2 1/5] BaseTools:ECC needs to update the contents of CParser4

Yuwei Chen yuwei.chen at intel.com
Fri Jun 5 04:38:39 UTC 2020


Hi, Shenglei

Since the input arguments number of the getText() function changed, the build failed. May be you should check about the getText() function's input.
While how to choose the CParser4 and CParser3, I am not familiar with it, would you like to explain for me?

Thanks,
Yuwei
> -----Original Message-----
> From: devel at edk2.groups.io <devel at edk2.groups.io> On Behalf Of Zhang,
> Shenglei
> Sent: Wednesday, June 3, 2020 4:48 PM
> To: devel at edk2.groups.io
> Cc: Fan, ZhijuX <zhijux.fan at intel.com>; Feng, Bob C
> <bob.c.feng at intel.com>; Gao, Liming <liming.gao at intel.com>
> Subject: [edk2-devel] [PATCH v2 1/5] BaseTools:ECC needs to update the
> contents of CParser4
> 
> From: "Fan, Zhiju" <zhijux.fan at intel.com>
> 
> 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 <bob.c.feng at intel.com>
> Cc: Liming Gao <liming.gao at intel.com>
> Signed-off-by: Zhiju.Fan <zhijux.fan at intel.com>
> ---
>  .../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._declarati
> on_specifiers.stop)))
> +                ModifierText = (None if
> + localctx._declaration_specifiers is None else
> + self._input.getText(localctx._declaration_specifiers.start,localctx._d
> + eclaration_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.st
> + op))
>              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
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#60742): https://edk2.groups.io/g/devel/message/60742
Mute This Topic: https://groups.io/mt/74645922/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list