stringLexer top-level property

Parser<StringParser> stringLexer
final

A String is signified by single quotes (') on either end

Implementation

final Parser<StringParser> stringLexer =
    (char("'") & (escLexer | char("'").neg()).star() & char("'")).map((value) {
  final middleValue = value[1]
      .map((e) => e is Token
          ? e.value.contains('u') as bool
              ? utf8.decode(
                  [int.parse(e.value.split('u').last as String, radix: 16)])
              : e.value.replaceAll(r'\\', r'\')
          : e == r'\'
              ? ''
              : e)
      .join('');
  return StringParser('${value[0]}$middleValue${value[2]}');
});