require "./thue.cr" abstract struct Thue::Rule @pattern : Regex def initialize(pattern : String) @pattern = Regex.new(pattern) end def matches?(str : String) : Bool str.matches?(@pattern) end abstract def replacement : String end struct Thue::NormalRule < Thue::Rule def initialize(pattern : String, @replacement : String) super(pattern) end def replacement : String @replacement end end struct Thue::InputRule < Thue::Rule def replacement : String gets end end struct Thue::OutputRule < Thue::Rule def initialize(pattern : String, @output : String) super(pattern) end def replacement : String print @output return "" end end