This parse attr does not allow anything other than names in contrast to attribute parsing in primary expression
(&mut self)
| 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. |
no test coverage detected