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

Method parse_starred_list

parser/src/parser/parser.rs:1964–1980  ·  view source on GitHub ↗

https://docs.python.org/3/reference/expressions.html#expression-lists termination_kind is used to know when to stop parsing the list for example to parse a tuple the termination_kind is Kind::RightParen caller is responsible to consume the first & last occurrence of the termination_kind

(
        &mut self,
        termination_kind: Kind,
    )

Source from the content-addressed store, hash-verified

1962 // caller is responsible to consume the first & last occurrence of the
1963 // termination_kind
1964 fn parse_starred_list(
1965 &mut self,
1966 termination_kind: Kind,
1967 ) -> Result<Vec<Expression>, ParsingError> {
1968 let mut expressions = vec![];
1969 while !self.at(Kind::Eof) && !self.at(termination_kind) {
1970 if self.eat(Kind::Comment) || self.consume_whitespace_and_newline() {
1971 continue;
1972 }
1973 let expr = self.parse_starred_item()?;
1974 if !self.at(Kind::Eof) && !self.at(termination_kind) {
1975 self.expect(Kind::Comma)?;
1976 }
1977 expressions.push(expr);
1978 }
1979 Ok(expressions)
1980 }
1981
1982 // https://docs.python.org/3/reference/expressions.html#expression-lists
1983 fn parse_starred_item(&mut self) -> Result<Expression, ParsingError> {

Callers 3

parse_for_statementMethod · 0.80
parse_listMethod · 0.80
parse_setMethod · 0.80

Calls 5

atMethod · 0.80
eatMethod · 0.80
parse_starred_itemMethod · 0.80
expectMethod · 0.80

Tested by

no test coverage detected