MCPcopy Create free account
hub / github.com/AlenVelocity/MeowScript / parse_anew_expr

Method parse_anew_expr

src/parser.rs:143–173  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

141 }
142
143 pub fn parse_anew_expr(&mut self) -> Option<Statement> {
144 match &self.peek_token {
145 Token::Ident(_) => self.next_token(),
146 _ => {
147 self.peek_error(Token::Ident(String::new()));
148 return None;
149 }
150 }
151
152 let name: Ident = match self.parse_ident() {
153 Some(Expr::Ident(ref mut s)) => s.clone(),
154 _ => return None,
155 };
156
157 if !self.expect_peek(Token::Assign) {
158 return None;
159 }
160
161 self.next_token();
162
163 let lit: Expr = match self.parse_expr(Precedence::Lowest) {
164 Some(e) => e,
165 None => return None,
166 };
167
168 while !self.current_token(Token::Semicolon) {
169 self.next_token();
170 }
171
172 Some(Statement::Anew(name, lit))
173 }
174
175 pub fn parse_break_statement(&mut self) -> Option<Statement> {
176 self.next_token();

Callers 1

parse_statementMethod · 0.80

Calls 7

IdentClass · 0.85
peek_errorMethod · 0.80
parse_identMethod · 0.80
expect_peekMethod · 0.80
parse_exprMethod · 0.80
current_tokenMethod · 0.80
next_tokenMethod · 0.45

Tested by

no test coverage detected