]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Eot/CodeFragmentCollector.py
BaseTools: Eot tool Python3 adaption
[mirror_edk2.git] / BaseTools / Source / Python / Eot / CodeFragmentCollector.py
index 8a5e5df17e5aff5e34011e833becff72771e44b2..b1e77a690ab19e71f75a82fbd999a8d618553d56 100644 (file)
@@ -21,13 +21,19 @@ import re
 import Common.LongFilePathOs as os\r
 import sys\r
 \r
-import antlr3\r
-from .CLexer import CLexer\r
-from .CParser import CParser\r
+if sys.version_info.major == 3:\r
+    import antlr4 as antlr\r
+    from Eot.CParser4.CLexer import CLexer\r
+    from Eot.CParser4.CParser import CParser\r
+else:\r
+    import antlr3 as antlr\r
+    antlr.InputStream = antlr.StringStream\r
+    from Eot.CParser3.CLexer import CLexer\r
+    from Eot.CParser3.CParser import CParser\r
 \r
-from . import FileProfile\r
-from .CodeFragment import PP_Directive\r
-from .ParserWarning import Warning\r
+from Eot import FileProfile\r
+from Eot.CodeFragment import PP_Directive\r
+from Eot.ParserWarning import Warning\r
 \r
 \r
 ##define T_CHAR_SPACE                ' '\r
@@ -354,9 +360,9 @@ class CodeFragmentCollector:
         FileStringContents = ''\r
         for fileLine in self.Profile.FileLinesList:\r
             FileStringContents += fileLine\r
-        cStream = antlr3.StringStream(FileStringContents)\r
+        cStream = antlr.InputStream(FileStringContents)\r
         lexer = CLexer(cStream)\r
-        tStream = antlr3.CommonTokenStream(lexer)\r
+        tStream = antlr.CommonTokenStream(lexer)\r
         parser = CParser(tStream)\r
         parser.translation_unit()\r
 \r