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

Method parse_attr

parser/src/parser/parser.rs:936–955  ·  view source on GitHub ↗

This parse attr does not allow anything other than names in contrast to attribute parsing in primary expression

(&mut self)

Source from the content-addressed store, hash-verified

934 // This parse attr does not allow anything other than names
935 // in contrast to attribute parsing in primary expression
936 fn parse_attr(&mut self) -> Result<Expression, ParsingError> {
937 let node = self.start_node();
938 let id = self.cur_token.to_string(self.source);
939 let mut expr = Ok(Expression::Name(Box::new(Name {
940 node: self.finish_node(node),
941 id,
942 parenthesized: false,
943 })));
944 self.expect(Kind::Identifier);
945 while self.eat(Kind::Dot) {
946 let attr_val = self.cur_token().to_string(self.source);
947 self.expect(Kind::Identifier)?;
948 expr = Ok(Expression::Attribute(Box::new(Attribute {
949 node: self.finish_node(node),
950 value: expr?,
951 attr: attr_val,
952 })));
953 }
954 expr
955 }
956
957 // TODO: This has precedence over sequence pattern but I'm not sure
958 // what is the right way to use it.

Callers 2

parse_closed_patternMethod · 0.80

Calls 8

NameClass · 0.85
AttributeClass · 0.85
start_nodeMethod · 0.80
to_stringMethod · 0.80
finish_nodeMethod · 0.80
expectMethod · 0.80
eatMethod · 0.80
cur_tokenMethod · 0.80

Tested by

no test coverage detected