BaseTools/Ecc/EOT: Add Python 3 support on ECC and EOT tools.
1. Add Python 3 support on ECC and EOT tools 2. Add C grammar file of ANTLR4 and fix some bugs Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
@ -22,7 +22,7 @@ import re
|
||||
import Common.LongFilePathOs as os
|
||||
import sys
|
||||
|
||||
import antlr3
|
||||
import antlr4
|
||||
from Ecc.CLexer import CLexer
|
||||
from Ecc.CParser import CParser
|
||||
|
||||
@ -499,13 +499,14 @@ class CodeFragmentCollector:
|
||||
def ParseFile(self):
|
||||
self.PreprocessFile()
|
||||
# restore from ListOfList to ListOfString
|
||||
# print(self.Profile.FileLinesList)
|
||||
self.Profile.FileLinesList = ["".join(list) for list in self.Profile.FileLinesList]
|
||||
FileStringContents = ''
|
||||
for fileLine in self.Profile.FileLinesList:
|
||||
FileStringContents += fileLine
|
||||
cStream = antlr3.StringStream(FileStringContents)
|
||||
cStream = antlr4.InputStream(FileStringContents)
|
||||
lexer = CLexer(cStream)
|
||||
tStream = antlr3.CommonTokenStream(lexer)
|
||||
tStream = antlr4.CommonTokenStream(lexer)
|
||||
parser = CParser(tStream)
|
||||
parser.translation_unit()
|
||||
|
||||
@ -516,9 +517,9 @@ class CodeFragmentCollector:
|
||||
FileStringContents = ''
|
||||
for fileLine in self.Profile.FileLinesList:
|
||||
FileStringContents += fileLine
|
||||
cStream = antlr3.StringStream(FileStringContents)
|
||||
cStream = antlr4.InputStream(FileStringContents)
|
||||
lexer = CLexer(cStream)
|
||||
tStream = antlr3.CommonTokenStream(lexer)
|
||||
tStream = antlr4.CommonTokenStream(lexer)
|
||||
parser = CParser(tStream)
|
||||
parser.translation_unit()
|
||||
|
||||
|
Reference in New Issue
Block a user