X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FEot%2FCodeFragmentCollector.py;fp=BaseTools%2FSource%2FPython%2FEot%2FCodeFragmentCollector.py;h=b1e77a690ab19e71f75a82fbd999a8d618553d56;hp=8a5e5df17e5aff5e34011e833becff72771e44b2;hb=8189be6fd7d7bdd15323b40d5f2f8d0ff822e2d5;hpb=c60377d7f9ec80ecc7fe76c38b81ffd98b7ef2e4 diff --git a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py index 8a5e5df17e..b1e77a690a 100644 --- a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py +++ b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py @@ -21,13 +21,19 @@ import re import Common.LongFilePathOs as os import sys -import antlr3 -from .CLexer import CLexer -from .CParser import CParser +if sys.version_info.major == 3: + import antlr4 as antlr + from Eot.CParser4.CLexer import CLexer + from Eot.CParser4.CParser import CParser +else: + import antlr3 as antlr + antlr.InputStream = antlr.StringStream + from Eot.CParser3.CLexer import CLexer + from Eot.CParser3.CParser import CParser -from . import FileProfile -from .CodeFragment import PP_Directive -from .ParserWarning import Warning +from Eot import FileProfile +from Eot.CodeFragment import PP_Directive +from Eot.ParserWarning import Warning ##define T_CHAR_SPACE ' ' @@ -354,9 +360,9 @@ class CodeFragmentCollector: FileStringContents = '' for fileLine in self.Profile.FileLinesList: FileStringContents += fileLine - cStream = antlr3.StringStream(FileStringContents) + cStream = antlr.InputStream(FileStringContents) lexer = CLexer(cStream) - tStream = antlr3.CommonTokenStream(lexer) + tStream = antlr.CommonTokenStream(lexer) parser = CParser(tStream) parser.translation_unit()