How to directly retrieve the line and column number of a parsed object in Scala FastParse?

103 Views Asked by At

According to the docs, you can retrieve the index using Index. However, this one only returns a single integer. Do I have to manually compute for the line number and column (e.g by using Util.lineNumberLookup) or use IndexedParserInput.prettyIndex on the resulting index?

1

There are 1 best solutions below

0
On

It looks like the answer is yes, but I can't even figure out how to do it manually. You basically have to have the whole string (or some stand-in, like the locations of all the newlines) available to every parser. The thing I'm trying now is making my parser a class and passing in the input as a val, so that I have access to it throughout.