diff --git a/rforth.py b/rforth.py index ebab4ee..0d8bfed 100755 --- a/rforth.py +++ b/rforth.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 import argparse stack = [] -heap = [0] * 10 +heap = [0] * 20 next_heap = 0 compiling = False words = {} @@ -64,6 +64,8 @@ def parse_input(input_string, say_ok=True): fetch() elif string == "heap": dump_heap() + elif string == "alloc": + alloc() else: if string == ";": stop_compiling() @@ -76,6 +78,12 @@ def parse_input(input_string, say_ok=True): def dump_heap(): print(heap) +def alloc(): + global next_heap + heap[next_heap] = 0 + stack.insert(0, next_heap) + next_heap += 1 + def store(): k = stack.pop(0) v = stack.pop(0)