mirror of
https://github.com/russolsen/rforth
synced 2024-12-27 09:59:00 +01:00
Added two essential words: dup and drop
This commit is contained in:
parent
8ef30fbc11
commit
60a1d68fb0
1 changed files with 8 additions and 6 deletions
|
@ -29,11 +29,13 @@ class RForth
|
||||||
|
|
||||||
def initial_dictionary
|
def initial_dictionary
|
||||||
d = Dictionary.new
|
d = Dictionary.new
|
||||||
d.word(':') { define_word }
|
d.word('dup') { @stack << @stack.last }
|
||||||
d.word('.'){ @s_out.print( @stack.pop ) }
|
d.word('drop') { @stack.pop }
|
||||||
d.word('cr') { @s_out.puts }
|
d.word(':') { define_word }
|
||||||
d.word('+') { @stack << (@stack.pop + @stack.pop) }
|
d.word('.') { @s_out.print( "#{@stack.pop}\n" ) }
|
||||||
d.word('*') { @stack << (@stack.pop * @stack.pop) }
|
d.word('cr') { @s_out.puts }
|
||||||
|
d.word('+') { @stack << (@stack.pop + @stack.pop) }
|
||||||
|
d.word('*') { @stack << (@stack.pop * @stack.pop) }
|
||||||
d.word('-') do
|
d.word('-') do
|
||||||
a = @stack.pop
|
a = @stack.pop
|
||||||
b = @stack.pop
|
b = @stack.pop
|
||||||
|
@ -113,7 +115,7 @@ class RForth
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_space?( ch )
|
def is_space?( ch )
|
||||||
/\W/ =~ ch
|
/\W/ =~ ch.chr
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
|
|
Loading…
Reference in a new issue