mirror of
https://github.com/diemheych/PrimeFORTH
synced 2024-11-16 19:48:00 +01:00
Update FORTH.py
Corrected initial release
This commit is contained in:
parent
a924115cd7
commit
b16ef35061
1 changed files with 8 additions and 3 deletions
9
FORTH.py
9
FORTH.py
|
@ -32,7 +32,10 @@ def main() :
|
||||||
while True :
|
while True :
|
||||||
pcode = compile() # compile/run from user
|
pcode = compile() # compile/run from user
|
||||||
if pcode == None : print(""); return
|
if pcode == None : print(""); return
|
||||||
|
try:
|
||||||
execute(pcode)
|
execute(pcode)
|
||||||
|
except IndexError:
|
||||||
|
print("Stack empty")
|
||||||
|
|
||||||
#============================== Lexical Parsing
|
#============================== Lexical Parsing
|
||||||
|
|
||||||
|
@ -118,6 +121,8 @@ def rKey (cod,p) :
|
||||||
if k != -1 : break
|
if k != -1 : break
|
||||||
|
|
||||||
ds.append(int(k))
|
ds.append(int(k))
|
||||||
|
|
||||||
|
def rInt (cod,p) : ds.append(int(ds.pop()))
|
||||||
def rTicks (cod,p) : ds.append(int(hpprime.eval("ticks")))
|
def rTicks (cod,p) : ds.append(int(hpprime.eval("ticks")))
|
||||||
def rLine (cod,p) : y2=ds.pop(); x2=ds.pop(); y1=ds.pop(); x1=ds.pop(); hpprime.line(0,x1,y1,x2, y2, colour)
|
def rLine (cod,p) : y2=ds.pop(); x2=ds.pop(); y1=ds.pop(); x1=ds.pop(); hpprime.line(0,x1,y1,x2, y2, colour)
|
||||||
def rRect (cod,p) : h=ds.pop(); w=ds.pop(); y=ds.pop(); x=ds.pop(); hpprime.rect(0,x,y,w, h, colour)
|
def rRect (cod,p) : h=ds.pop(); w=ds.pop(); y=ds.pop(); x=ds.pop(); hpprime.rect(0,x,y,w, h, colour)
|
||||||
|
@ -223,7 +228,7 @@ def rImmediate(cod,p) :
|
||||||
imDict[list(rDict.keys())[-1]] = 1
|
imDict[list(rDict.keys())[-1]] = 1
|
||||||
|
|
||||||
def rWords(cod,p) :
|
def rWords(cod,p) :
|
||||||
for k in sorted(list(rDict.keys())): print(k,end=' ')
|
for k in sorted(list(rDict.keys())+list(cDict.keys())): print(k,end=' ')
|
||||||
|
|
||||||
def rCreate (pcode,p) :
|
def rCreate (pcode,p) :
|
||||||
global heapNext, lastCreate
|
global heapNext, lastCreate
|
||||||
|
@ -266,6 +271,7 @@ rDict = {
|
||||||
'getpix4' : rGetpix4,
|
'getpix4' : rGetpix4,
|
||||||
'key' : rKey,
|
'key' : rKey,
|
||||||
'lastkey' : rLastkey,
|
'lastkey' : rLastkey,
|
||||||
|
'int' : rInt,
|
||||||
'ticks' : rTicks,
|
'ticks' : rTicks,
|
||||||
'line' : rLine,
|
'line' : rLine,
|
||||||
'rect' : rRect,
|
'rect' : rRect,
|
||||||
|
@ -295,7 +301,6 @@ rDict = {
|
||||||
'1+' : rOneplus,
|
'1+' : rOneplus,
|
||||||
'>r' : rgtR,
|
'>r' : rgtR,
|
||||||
'r>' : rRgt,
|
'r>' : rRgt,
|
||||||
'j' : rJ,
|
|
||||||
'type' : rType,
|
'type' : rType,
|
||||||
'word' : rWord,
|
'word' : rWord,
|
||||||
'ddump' : rDdump,
|
'ddump' : rDdump,
|
||||||
|
|
Loading…
Reference in a new issue