Parse a constant decl. constant-decl ::= * Constant(c) "=" ty? "[" literal {"," literal} "]"
(&mut self)
| 1921 | // |
| 1922 | // constant-decl ::= * Constant(c) "=" ty? "[" literal {"," literal} "]" |
| 1923 | fn parse_constant_decl(&mut self) -> ParseResult<(Constant, ConstantData)> { |
| 1924 | let name = self.match_constant()?; |
| 1925 | self.match_token(Token::Equal, "expected '=' in constant decl")?; |
| 1926 | let data = if let Some(Token::Type(_)) = self.token() { |
| 1927 | let ty = self.match_type("expected type of constant")?; |
| 1928 | self.match_uimm128(ty) |
| 1929 | } else { |
| 1930 | self.match_hexadecimal_constant("expected an immediate hexadecimal operand") |
| 1931 | }?; |
| 1932 | |
| 1933 | // Collect any trailing comments. |
| 1934 | self.token(); |
| 1935 | self.claim_gathered_comments(name); |
| 1936 | |
| 1937 | Ok((name, data)) |
| 1938 | } |
| 1939 | |
| 1940 | // Parse an alias region decl |
| 1941 | // |
no test coverage detected