#!/usr/bin/ruby stack = [] register = {} charmap = {} mark = 0 for line in ARGF for token in line.split(/[\/\s]+/) case token when /^\(\*$/ then mark = stack.size when /^\*\)$/ then while stack.size > mark do stack.pop end when /^alias$/ then ia = stack.pop.to_i ib = stack.pop.to_i $stderr.puts "code #{ib} undefined" unless charmap[ib] charmap[ia] = charmap[ib] when /^code|\+-\+-$/ then register[:code] = stack.pop.to_i when /^char$/ then register[:code] = stack.pop[0] when /^bound|\+\+$/ then register[:bound] = [stack.pop, stack.pop].reverse when /^(break|\*)$/ then stack.push(-64, 0) when /^(end|\*\*)$/ then stack.push(-64, -64) register[:font] = stack stack = [] $stderr.puts "code #{register[:code]} redefined" if charmap[register[:code]] charmap[register[:code]] = register register = {} else stack.push token end end end for charcode in 0..255 chardef = charmap[charcode] chardef = {:font => [-64, -64], :bound => [-8, 8]} if chardef.nil? printf("%5d %c:", charcode, ((33..126) === charcode ? charcode : 32)) stack = chardef[:bound].dup stack += chardef[:font] while true 8.times { break if stack.empty? x = stack.shift y = stack.shift printf('%3d %3d:', x, y) } break if stack.empty? printf("\n :") end printf("\n") end