@@ -63,14 +63,18 @@ def expand_acl(self, acl_file_path: Path) -> List[str]:
63
63
result .append (line )
64
64
return result
65
65
66
- def expand (self , source : str ) -> str :
66
+ def expand (self , source : str , origname ) -> str :
67
67
self .included = set ()
68
68
result = [] # type: List[str]
69
+ linenum = 0
69
70
for line in source .splitlines ():
71
+ linenum += 1
70
72
m = self .atcoder_include .match (line )
71
73
if m :
72
74
acl_path = self .find_acl (m .group (1 ))
73
75
result .extend (self .expand_acl (acl_path ))
76
+ if origname :
77
+ result .append ('#line ' + str (linenum + 1 ) + ' "' + origname + '"' )
74
78
continue
75
79
76
80
result .append (line )
@@ -88,6 +92,8 @@ def expand(self, source: str) -> str:
88
92
parser .add_argument ('-c' , '--console' ,
89
93
action = 'store_true' , help = 'Print to Console' )
90
94
parser .add_argument ('--lib' , help = 'Path to Atcoder Library' )
95
+ parser .add_argument ('--origname' , help = 'report line numbers from the original ' +
96
+ 'source file in GCC/Clang error messages' )
91
97
opts = parser .parse_args ()
92
98
93
99
lib_paths = []
@@ -99,7 +105,7 @@ def expand(self, source: str) -> str:
99
105
lib_paths .append (Path .cwd ())
100
106
expander = Expander (lib_paths )
101
107
source = open (opts .source ).read ()
102
- output = expander .expand (source )
108
+ output = expander .expand (source , opts . origname )
103
109
104
110
if opts .console :
105
111
print (output )
0 commit comments