blob: 7bfa135e061ed0db3634d4e227b06564272181eb [file] [log] [blame]
import 'package:meta/meta.dart';
import '../../context/context.dart';
import '../../context/result.dart';
import '../../core/parser.dart';
/// Returns a parser that reports the current input position.
@useResult
Parser position() => PositionParser();
/// A parser that reports the current input position.
class PositionParser extends Parser<int> {
PositionParser();
@override
Result<int> parseOn(Context context) => context.success(context.position);
@override
int fastParseOn(String buffer, int position) => position;
@override
PositionParser copy() => PositionParser();
}