Created
January 16, 2010 00:38
-
-
Save dydx/278549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# unnecessary.rb - Josh Sandlin - 3:13PM - 1/15/2010 | |
# An interpreter of the Unnecessary language | |
# raised when the source file is present | |
class CriticalError < Exception; end | |
# core of the interpreter | |
class Unnecessary | |
attr_accessor :source_file | |
def initialize( source_file ) | |
@source_file = source_file | |
end | |
def parse | |
raise CriticalError, "The file exists!" unless !File.exists? @source_file | |
end | |
def execute | |
begin | |
parse | |
puts "Program executed successfully!" | |
rescue CriticalError => msg | |
puts "CRITICAL ERROR: #{msg}" | |
end | |
end | |
end | |
interpreter = Unnecessary.new( ARGV.shift ) | |
interpreter.execute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment