Added two essential words: dup and drop

This commit is contained in:
fogus 2010-09-09 09:06:08 -04:00
parent 8ef30fbc11
commit 60a1d68fb0

View file

@ -29,8 +29,10 @@ class RForth
def initial_dictionary
d = Dictionary.new
d.word('dup') { @stack << @stack.last }
d.word('drop') { @stack.pop }
d.word(':') { define_word }
d.word('.'){ @s_out.print( @stack.pop ) }
d.word('.') { @s_out.print( "#{@stack.pop}\n" ) }
d.word('cr') { @s_out.puts }
d.word('+') { @stack << (@stack.pop + @stack.pop) }
d.word('*') { @stack << (@stack.pop * @stack.pop) }
@ -113,7 +115,7 @@ class RForth
end
def is_space?( ch )
/\W/ =~ ch
/\W/ =~ ch.chr
end
def run