File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
graalpython/com.oracle.graal.python.parser.antlr Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 76
76
"""
77
77
78
78
PTRN_SUPPRESS_WARNINGS = re .compile (r"@SuppressWarnings.*" )
79
+ PTRN_GEN_FROM = r"// Generated from .*(?P<path>graalpython/com\.oracle\.graal\.python.*Python3\.g4) by ANTLR (?P<antlr>.*)"
79
80
80
81
81
82
def replace_suppress_warnings (line ):
@@ -85,13 +86,20 @@ def replace_suppress_warnings(line):
85
86
def replace_rulectx (line ):
86
87
return line .replace ("(RuleContext)_localctx" , "_localctx" )
87
88
89
+
88
90
def replace_localctx (line ):
89
91
return re .sub (r'\(\((([a-zA-Z]*?_?)*[a-zA-Z]*)\)_localctx\)' , '_localctx' , line )
90
92
93
+
94
+ def replace_generate_from (line ):
95
+ return re .sub (PTRN_GEN_FROM , "// Generated from \g<path> by ANTLR \g<antlr>" , line )
96
+
97
+
91
98
TRANSFORMS = [
92
99
replace_suppress_warnings ,
93
100
replace_rulectx ,
94
101
replace_localctx ,
102
+ replace_generate_from ,
95
103
]
96
104
97
105
You can’t perform that action at this time.
0 commit comments