lexeme property

  1. @override
String lexeme
override

Return the lexeme that represents this token.

For StringTokens the lexeme includes the quotes, explicit escapes, etc.

Implementation

@override
String get lexeme {
  String errorMsg = assertionMessage.problemMessage;

  // Attempt to include the location which is calling the parser
  // in an effort to debug https://github.com/dart-lang/sdk/issues/37528
  RegExp pattern = RegExp('^#[0-9]* *Parser');
  List<String> traceLines = StackTrace.current.toString().split('\n');
  for (int index = traceLines.length - 2; index >= 0; --index) {
    String line = traceLines[index];
    if (line.startsWith(pattern)) {
      errorMsg = '$errorMsg - ${traceLines[index + 1]}';
      break;
    }
  }

  throw errorMsg;
}