grammerThrows()

in src/langs/swift/combinator.js [758:782]


  grammerThrows(emitter, gram) {
    if (gram.exception === null) {
      emitter.emit('throw ');
      this.grammerValue(emitter, gram.params[0]);
    } else {
      if (gram.params.length > 0) {
        emitter.emit(`throw ${this.emitType(gram.exception)}(`);
        if (gram.params.length === 1) {
          this.grammerValue(emitter, gram.params[0]);
        } else {
          let tmp = [];
          gram.params.forEach(p => {
            let emit = new Emitter();
            this.grammerValue(emit, p);
            tmp.push(emit.output);
          });
          emitter.emit(tmp.join(', '));
        }
        emitter.emit(')');
      } else {
        let msg = gram.message ? `"${gram.message}"` : '';
        emitter.emit(`throw ${this.emitType(gram.exception)}(${msg})`);
      }
    }
  }