expect method

LatexToken expect(
  1. String type, [
  2. String? message
])

Implementation

LatexToken expect(String type, [String? message]) {
  final token = peek();
  if (token == null) {
    throw Exception(message ?? "期望 $type,但到达文件末尾");
  }
  advance();
  return token;
}