public CommandTreeToken Expect(CommandTreeToken.Kind expected) { if (Current == null) { throw CommandParseException.ExpectedTokenButFoundNull(expected); } var found = Current.TokenKind; if (expected != found) { throw CommandParseException.ExpectedTokenButFoundOther(expected, found); } return(Current); }
public static ParseException ExpectedTokenButFoundOther(CommandTreeToken.Kind expected, CommandTreeToken.Kind found) { return(new ParseException($"Expected to find token of type '{expected}' but found '{found}' instead.")); }
public CommandTreeToken?Consume(CommandTreeToken.Kind type) { Expect(type); return(Consume()); }
public static ParseException ExpectedTokenButFoundNull(CommandTreeToken.Kind expected) { return(new ParseException($"Expected to find any token of type '{expected}' but found null instead.")); }