ANTLR 4.9 is broken in python 3.13 because
it uses a library in the autogenerated files
that is removed.
This updates to 4.13.2 and also updates the autogen
files, which contain support for python 3.13 as well
as backwards compat.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
The ANTLR autogen files are currently created
without an SPDX identifer. Add the BSD-2-Clause-Patent
ID.
While here, correct the command to do the autogeneration
by using the right filename.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
The CParser4 Python parser files (CLexer.py, CParser.py, CListener.py)
were generated 7 years ago with ANTLR 4.7.1.
Meanwhile, pip-requirements.txt pins antlr4-python3-runtime to version
4.9 in commit 4a7dd50, but the files were patched, not fully
regenerated. This version mismatch produced two failures when running
EccMain.py against non-trivial C code:
1. A runtime warning on every file parsed:
"ANTLR runtime and generated code versions disagree: 4.9!=4.7.1"
2. A crash when parsing complex C constructs that exercise the
struct/union definition rule in CParser.py:
TypeError: '<' not supported between instances of 'tuple' and 'int'
This occurs in antlr4/BufferedTokenStream.py getText() because the
4.9 runtime changed the expected argument types for that method,
and the 4.7.1-generated parser was passing a tuple where an int is
now required.
This change regenerates the CParser4 files with ANTLR 4.9 to resolve
the version mismatch.
Steps used to regenerate the files:
1. Download the ANTLR 4.9 complete tool JAR:
- `https://www.antlr.org/download/antlr-4.9-complete.jar`
2. Generate Python3 parser files from the grammar:
```
java -jar antlr-4.9-complete.jar `
-Dlanguage=Python3 -visitor `
-o BaseTools/Source/Python/Ecc/CParser4_new `
BaseTools/Source/Python/Ecc/CParser4/C.g4
```
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
v2:
The python files under CParser4 are generated by antlr4 and for
python3 usage. They have python3 specific syntax, for example
the data type declaration for the arguments of a function. That
is not compitable with python2. this patch is to remove these syntax.
ECC tool Python3 adaption.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>