Files
RubyAlgebra/bin/demo
Slavasil 1fff529e83 implement interpreter and demo + bug fixes
- implement interpreter and demo
- replace StandardError with appropriate subclasses
- implement division
- rewrite Polynomial.simplify()
2026-04-13 19:33:50 +03:00

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