- implement interpreter and demo - replace StandardError with appropriate subclasses - implement division - rewrite Polynomial.simplify()
31 lines
608 B
Ruby
Executable File
31 lines
608 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
require 'bundler/setup'
|
|
require 'ruby_algebra'
|
|
|
|
print "RubyMaple © RubyMaple Creators, 2026. No rights reserved.\nPress Ctrl+D to quit.\n"
|
|
|
|
interp = RubyAlgebra::Interpreter.new
|
|
loop do
|
|
print '> '
|
|
inp = $stdin.gets
|
|
break if inp.nil?
|
|
|
|
inp = inp.chomp
|
|
next if inp.empty?
|
|
|
|
begin
|
|
command = RubyAlgebra::Parser.parse_command(inp)
|
|
rescue StandardError => e
|
|
puts "Syntax error: #{e.message}"
|
|
next
|
|
end
|
|
begin
|
|
puts "< #{interp.execute(command)}"
|
|
rescue StandardError => e
|
|
puts "Calculation error: #{e.message}"
|
|
end
|
|
end
|
|
puts
|