MCPcopy Create free account
hub / github.com/d0iasm/saba / function_body

Method function_body

core/src/renderer/js/ast.rs:421–444  ·  view source on GitHub ↗

FunctionBody ::= "{" ( SourceElements )? "}"

(&mut self)

Source from the content-addressed store, hash-verified

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 ///

Callers 1

function_declarationMethod · 0.80

Calls 2

source_elementMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected