Closed Oualitsen closed 1 year ago
The Token
class provides such a helper: https://github.com/petitparser/dart-petitparser/blob/fc676d01b1854c32abc928960f09653ca1b0fe0c/lib/src/core/token.dart#L89
You can either use that static method, or build your own similar helper.
Example usage:
final result = parser.parse(input);
if (result.isFailure) {
final lineAndColumn = Token.lineAndColumnOf(input, result.position);
print('Error ${result.message} at ${lineAndColumn.join(':')}');
...
Thank you very much for your fast response and Good Job by the way Lukas :)
Hello, I have a side project that is a parser for graphql. the main goal of it is to generate classes from a graphql schema. I cannot seem to find a way to get the line and the column of the code that is being parsed. I want to throw some ParseException with a good description and the where (namely the line : column) the issue came from. I have already used JavaCC for parsing a subset of the ECMAScript language as a school project and I remember that JavaCC has that. I wonder if petitParser has that or should we implement something to track the lines and the columns. Thank you, Ramdane.