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

Method parse

parser/src/parser/parser.rs:84–107  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

82 }
83
84 pub fn parse(&mut self) -> Result<Module, ParsingError> {
85 let node = self.start_node();
86 let mut body = vec![];
87 while self.cur_kind() != Kind::Eof {
88 if self.consume_whitespace_and_comments() {
89 continue;
90 }
91 let stmt = if is_at_compound_statement(self.cur_token()) {
92 self.parse_compound_statement()
93 } else {
94 self.parse_simple_statement()
95 };
96 match stmt {
97 Ok(stmt) => body.push(stmt),
98 Err(err) => return Err(err),
99 }
100 }
101
102 let mut node = self.finish_node(node);
103 // Remove the EOF offset
104 node.end.saturating_sub(1);
105
106 Ok(Module::new(node, body))
107 }
108
109 fn start_node(&self) -> Node {
110 let token = self.cur_token();

Callers 15

ast_python.pyFile · 0.80
parse_enderpy_sourceFunction · 0.80
test_parse_assignmentFunction · 0.80
test_parse_assert_stmtFunction · 0.80
test_pass_stmtFunction · 0.80
test_parse_del_stmtFunction · 0.80
parse_yield_statementFunction · 0.80
test_raise_statementFunction · 0.80
test_parse_bool_opFunction · 0.80
test_parse_unary_opFunction · 0.80
test_named_expressionFunction · 0.80

Calls 8

is_at_compound_statementFunction · 0.85
start_nodeMethod · 0.80
cur_kindMethod · 0.80
cur_tokenMethod · 0.80
finish_nodeMethod · 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