mirror of
https://github.com/russolsen/rforth
synced 2024-12-26 09:58:27 +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,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
|
||||
|
|
Loading…
Reference in a new issue