51b39f8
/* Copyright (c) 2021 Jerry James
51b39f8
 *
51b39f8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
51b39f8
 * of this software and associated documentation files (the "Software"), to deal
51b39f8
 * in the Software without restriction, including without limitation the rights
51b39f8
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51b39f8
 * copies of the Software, and to permit persons to whom the Software is
51b39f8
 * furnished to do so, subject to the following conditions:
51b39f8
 *
51b39f8
 * The above copyright notice and this permission notice shall be included in
51b39f8
 * all copies or substantial portions of the Software.
51b39f8
 *
51b39f8
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51b39f8
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51b39f8
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
51b39f8
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
51b39f8
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51b39f8
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
51b39f8
 * SOFTWARE.
51b39f8
 */
51b39f8
import java.io.FileWriter;
51b39f8
import java.io.IOException;
51b39f8
import scala.collection.Seq;
51b39f8
51b39f8
public class Generate {
51b39f8
  public static void main(String args[]) {
51b39f8
    Seq<GeneratedFile> files = codegen.genAll();
51b39f8
    for (int i = 0; i < files.length(); i++) {
51b39f8
      GeneratedFile gen = files.apply(i);
51b39f8
      try {
51b39f8
        FileWriter f = new FileWriter(args[0] + "/" + gen.name());
51b39f8
        f.write(gen.code());
51b39f8
        f.close();
51b39f8
      } catch (IOException e) {
51b39f8
        System.err.println("Failed to generate " + gen.name());
51b39f8
        System.err.println(e.toString());
51b39f8
        System.exit(1);
51b39f8
      }
51b39f8
    }
51b39f8
  }
51b39f8
}