Prof9 / TextPet

A plugin-based binary script extraction and insertion tool for Mega Man Battle Network modding and translation.
MIT License
26 stars 4 forks source link

Provide accurate error line number #8

Open Steve-xmh opened 1 year ago

Steve-xmh commented 1 year ago

First of all, this tool has huge contribution to our Chinese Translation Patch. We are highly appreciated to your work!

But we have some trouble in checking grammar error on modifying tpl scripts. TextPet only reports the error message but not providing accurate line number, which always confuse us when repacking ROMs. It would be very helpful if we can know which line has the grammar error.

Prof9 commented 1 year ago

This is a bit difficult to do because TextPet uses a Regex-based tokenizer for TPL. However, .NET's Regex facilities do not record line/column numbers for matches. Therefore the easiest way to determine the line number would be to manually compute the line number for each match, by counting the number of newlines before the match. This is not great for performance, hence why it is currently not done.

https://learn.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.match