#!/usr/bin/env ruby # ---------------------------------------------------------------------- # Project: JCPU, a portable 8-bit RISC CPU written in VHDL # This file: Insertion of code fragments into templates # # Copyright (C) 2007 J. Ahrensfeld # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # For questions and ideas, please contact the author at jens@jayfield.org # # --------------------------------------------------------------------- arg = $* rom_filename = arg[0].to_s tpl_filename = arg[1].to_s subst_pattern = "JASM_ROM_INSERT_HERE" # -------------------------------------------------------- # Open file # -------------------------------------------------------- romfile = File.open(rom_filename, "r") tplfile = File.open(tpl_filename, "r") re = Regexp.new(subst_pattern) while (line = tplfile.gets) puts line line.scan(re).each do |word| romfile.each do |raw_line| puts raw_line end end end