FunctionBody ::= "{" ( SourceElements )? "}"
(&mut self)
| 419 | |
| 420 | /// FunctionBody ::= "{" ( SourceElements )? "}" |
| 421 | fn function_body(&mut self) -> Option<Rc<Node>> { |
| 422 | // consume '{' |
| 423 | match self.t.next() { |
| 424 | Some(t) => match t { |
| 425 | Token::Punctuator(c) => assert!(c == '{'), |
| 426 | _ => unimplemented!("function should have open curly blacket but got {:?}", t), |
| 427 | }, |
| 428 | None => unimplemented!("function should have open curly blacket but got None"), |
| 429 | } |
| 430 | |
| 431 | let mut body = Vec::new(); |
| 432 | loop { |
| 433 | // loop until hits '}' |
| 434 | if let Some(Token::Punctuator(c)) = self.t.peek() { |
| 435 | if c == &'}' { |
| 436 | // consume '}' |
| 437 | assert!(self.t.next().is_some()); |
| 438 | return Node::new_block_statement(body); |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | body.push(self.source_element()); |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | /// ArgumentList ::= AssignmentExpression ( "," AssignmentExpression )* |
| 447 | /// |
no test coverage detected