MCPcopy Create free account
hub / github.com/Glyphack/enderpy / expect

Method expect

parser/src/parser/parser.rs:213–221  ·  view source on GitHub ↗

Expect a `Kind` or return error

(&mut self, kind: Kind)

Source from the content-addressed store, hash-verified

211
212 /// Expect a `Kind` or return error
213 pub fn expect(&mut self, kind: Kind) -> Result<(), ParsingError> {
214 if !self.at(kind) {
215 let found = &self.cur_token;
216 let line = &self.get_offset_line_number(found.start);
217 panic!("Expected {:?} but found {:?} line: {line:}", kind, found);
218 }
219 self.bump_any();
220 Ok(())
221 }
222
223 /// Expect any of `Kinds` or return error
224 pub fn expect_any(&mut self, kind: Vec<Kind>) -> Result<(), ParsingError> {

Callers 15

parse_if_statementMethod · 0.80
parse_while_statementMethod · 0.80
parse_for_statementMethod · 0.80
parse_with_statementMethod · 0.80
parse_with_itemsMethod · 0.80
parse_try_statementMethod · 0.80
parse_except_clausesMethod · 0.80
parse_match_statementMethod · 0.80
parse_casesMethod · 0.80

Calls 3

atMethod · 0.80
bump_anyMethod · 0.80

Tested by 15

test_parse_assignmentFunction · 0.64
test_parse_assert_stmtFunction · 0.64
test_pass_stmtFunction · 0.64
test_parse_del_stmtFunction · 0.64
parse_yield_statementFunction · 0.64
test_raise_statementFunction · 0.64
test_parse_bool_opFunction · 0.64
test_parse_unary_opFunction · 0.64
test_named_expressionFunction · 0.64
test_tupleFunction · 0.64
test_yield_expressionFunction · 0.64