expect method

void expect(
  1. String expectedChar
)

Read a specific character and throw an exception if it's not found

Parameter is case-insensitive

Implementation

void expect(String expectedChar) {
  if (next().toLowerCase() != expectedChar.toLowerCase()) {
    throw Exception('Expected $expectedChar');
  }
}