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

Method parse_parameter

parser/src/parser/parser.rs:3239–3267  ·  view source on GitHub ↗
(
        &mut self,
        is_lambda: bool,
    )

Source from the content-addressed store, hash-verified

3237 }
3238
3239 fn parse_parameter(
3240 &mut self,
3241 is_lambda: bool,
3242 ) -> Result<(Arg, Option<Expression>), ParsingError> {
3243 let node = self.start_node();
3244 let arg = self.cur_token().to_string(self.source);
3245 self.bump(Kind::Identifier);
3246 // Lambda parameters cannot have annotations
3247 let annotation = if self.at(Kind::Colon) && !is_lambda {
3248 self.bump(Kind::Colon);
3249 Some(self.parse_expression()?)
3250 } else {
3251 None
3252 };
3253 let arg_node = self.finish_node(node);
3254 let default = if self.eat(Kind::Assign) {
3255 Some(self.parse_expression()?)
3256 } else {
3257 None
3258 };
3259 Ok((
3260 Arg {
3261 node: arg_node,
3262 arg,
3263 annotation,
3264 },
3265 default,
3266 ))
3267 }
3268
3269 // the FStringStart token is consumed by the caller
3270 fn parse_fstring(&mut self, node: Node) -> Result<Vec<Expression>, ParsingError> {

Callers 1

parse_parametersMethod · 0.80

Calls 8

start_nodeMethod · 0.80
to_stringMethod · 0.80
cur_tokenMethod · 0.80
bumpMethod · 0.80
atMethod · 0.80
parse_expressionMethod · 0.80
finish_nodeMethod · 0.80
eatMethod · 0.80

Tested by

no test coverage detected