SourceElements ::= ( SourceElement )+ Program ::= ( SourceElements )?
(&mut self)
| 540 | /// |
| 541 | /// Program ::= ( SourceElements )? <EOF> |
| 542 | pub fn parse_ast(&mut self) -> Program { |
| 543 | let mut program = Program::new(); |
| 544 | |
| 545 | // interface Program <: Node { |
| 546 | // type: "Program"; |
| 547 | // body: [ Directive | Statement ]; |
| 548 | // } |
| 549 | let mut body = Vec::new(); |
| 550 | |
| 551 | loop { |
| 552 | let node = self.source_element(); |
| 553 | |
| 554 | match node { |
| 555 | Some(n) => body.push(n), |
| 556 | None => { |
| 557 | program.set_body(body); |
| 558 | return program; |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | #[cfg(test)] |