grammerCondition()

in src/langs/swift/combinator.js [666:699]


  grammerCondition(emitter, gram) {
    if (gram.type === 'elseif') {
      emitter.emit('else if');
    } else {
      emitter.emit(`${gram.type}`);
    }

    if (gram.type !== 'else') {
      emitter.emit(' (');
      let emit = new Emitter(this.config);
      gram.conditionBody.forEach(condition => {
        this.grammer(emitter, condition, false, false);
      });
      emitter.emit(`${emit.output})`);
    }

    if (gram.body.length) {
      emitter.emitln(' {');
      this.levelUp();
      gram.body.forEach(node => {
        this.grammer(emitter, node);
      });
      this.levelDown();
      emitter.emitln('}', this.level);
    } else {
      emitter.emitln(' {}');
    }

    if (gram.elseItem.length && gram.elseItem.length > 0) {
      gram.elseItem.forEach(e => {
        this.grammer(emitter, e);
      });
    }
  }