moduleBody()

in lib/parser.js [179:222]


  moduleBody() {
    // moduleBody = "{" { const | type | model | exception | api | function } "}"
    const nodes = [];
    while (this.look.tag) {
      let node;
      let annotation;
      if (this.is(Tag.ANNOTATION)) {
        annotation = this.look;
        this.move();
      }

      if (this.is(Tag.CONST)) {
        node = this.const();
      } else if (this.isWord(Tag.ID, 'typedef')) {
        node = this.typedef();
      } else if (this.isWord(Tag.ID, 'model')) {
        node = this.model();
      } else if (this.isWord(Tag.ID, 'exception')) {
        node = this.exception();
      } else if (this.isWord(Tag.ID, 'enum')) {
        node = this.enum();
      } else if (this.isWord(Tag.ID, 'api')) {
        node = this.api();
      } else if (this.is(Tag.RPC)) {
        node = this.rpc();
      } else if (this.isWord(Tag.ID, 'type')) {
        node = this.type();
      } else if (this.isWord(Tag.ID, 'init')) {
        node = this.init();
      } else if (this.is(Tag.STATIC) || this.isWord(Tag.ID, 'async') || this.isWord(Tag.ID, 'function')) {
        node = this.fun();
      } else {
        this.error('expect "const", "type", "model", "function", "init" or "api"');
      }

      node.annotation = annotation;
      nodes.push(node);
    }

    return {
      type: 'moduleBody',
      nodes: nodes
    };
  }