2021-11-18 15:44:09 +01:00
|
|
|
require 'bigdecimal/math'
|
|
|
|
|
2021-11-10 16:20:47 +01:00
|
|
|
require_relative './language/general'
|
2021-11-18 15:44:09 +01:00
|
|
|
require_relative './language/mode'
|
2021-11-10 16:20:47 +01:00
|
|
|
require_relative './language/operations'
|
2021-11-18 12:00:02 +01:00
|
|
|
require_relative './language/program'
|
2021-11-10 16:20:47 +01:00
|
|
|
require_relative './language/stack'
|
2021-11-24 13:33:44 +01:00
|
|
|
require_relative './language/string'
|
2021-11-24 16:09:57 +01:00
|
|
|
require_relative './language/test'
|
2021-11-18 15:44:09 +01:00
|
|
|
require_relative './language/time-date'
|
2021-11-10 16:20:47 +01:00
|
|
|
|
2021-11-23 13:10:03 +01:00
|
|
|
module Rpl
|
2021-11-10 16:20:47 +01:00
|
|
|
module Core
|
|
|
|
module_function
|
|
|
|
|
2021-11-18 15:44:09 +01:00
|
|
|
include BigMath
|
|
|
|
|
|
|
|
def precision
|
2021-11-23 12:59:45 +01:00
|
|
|
@precision or 12
|
2021-11-18 15:44:09 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def precision=( value )
|
|
|
|
@precision = value
|
|
|
|
end
|
|
|
|
|
2021-11-10 16:20:47 +01:00
|
|
|
def stack_extract( stack, needs )
|
|
|
|
raise 'Not enough elements' if stack.size < needs.size
|
|
|
|
|
|
|
|
args = []
|
|
|
|
needs.each do |need|
|
|
|
|
elt = stack.pop
|
|
|
|
|
|
|
|
raise "Type Error, needed #{need} got #{elt[:type]}" if need != :any && !need.include?( elt[:type] )
|
|
|
|
|
|
|
|
args << elt
|
|
|
|
end
|
|
|
|
|
2021-11-24 13:33:44 +01:00
|
|
|
[stack, args]
|
2021-11-10 16:20:47 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def __todo( stack )
|
|
|
|
puts '__NOT IMPLEMENTED__'
|
|
|
|
stack
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|