expectToken method

ExpressionToken expectToken(
  1. String kind,
  2. String what
)

current, which must be of kind, and moves past it; what is how the refusal names what was expected.

Implementation

ExpressionToken expectToken(String kind, String what) {
  if (current.kind != kind) {
    fail(
      'expected $what, found "${current.text.isEmpty ? 'the end of the '
                'file' : current.text}".',
    );
  }
  final token = current;
  position++;
  return token;
}