Skip to content

Commit 8a91d12

Browse files
committed
simplify postprocessing
1 parent a3e03b5 commit 8a91d12

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

graalpython/com.oracle.graal.python.parser.antlr/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ define postprocess_file
5757
python ${POSTPROCESSOR} $(1)
5858
endef
5959

60-
${PARSER_PATH}/%.java: ${SOURCE}
60+
${PARSER_PATH}/%.java: ${SOURCE} ${POSTPROCESSOR}
6161
$(QUIETLY) ${JAVA_HOME}/bin/java -cp ${ANTLR_JAR} org.antlr.v4.Tool -visitor -package ${PARSER_PKG} -o ${PARSER_PATH} ${SOURCE}
6262
$(QUIETLY) $(call postprocess_file,$@)
6363

graalpython/com.oracle.graal.python.parser.antlr/postprocess.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"""
4949

5050
PTRN_SUPPRESS_WARNINGS = re.compile(r"@SuppressWarnings.*")
51-
PTRN_GENBY = re.compile(r"Generated from (?P<path>.*)/(?P<grammar>.*.g4)")
5251

5352

5453
def replace_suppress_warnings(line):
@@ -59,23 +58,17 @@ def replace_rulectx(line):
5958
return line.replace("(RuleContext)_localctx", "_localctx")
6059

6160

62-
def replace_genby(line):
63-
return PTRN_GENBY.sub("Generated from \g<grammar>", line)
64-
65-
6661
TRANSFORMS = [
6762
replace_suppress_warnings,
6863
replace_rulectx,
69-
replace_genby,
7064
]
7165

7266

7367
def postprocess(file):
7468
lines = []
7569
for line in file:
7670
for transform in TRANSFORMS:
77-
if hasattr(transform, '__call__'):
78-
line = transform(line)
71+
line = transform(line)
7972
lines.append(line)
8073
return ''.join(lines)
8174

0 commit comments

Comments
 (0)