MCPcopy Create free account
hub / github.com/RetiredWizard/PyDOS / main

Function main

PyBasic/interpreter.py:46–245  ·  view source on GitHub ↗
(passedIn="")

Source from the content-addressed store, hash-verified

44 gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())
45
46def main(passedIn=""):
47
48 banner = (
49"""
50 PPPP Y Y BBBB AAA SSSS I CCC
51 P P Y Y B B A A S I C
52 P P Y Y B B A A S I C
53 PPPP Y BBBB AAAAA SSSS I C
54u u P Y B B A A S I C
55u u P Y B B A A S I C
56uuuu P Y BBBB A A SSSS I CCC
57 microPyBasic
58""")
59
60 print(banner)
61
62 lexer = Lexer()
63 program = Program()
64
65 fOpened = False
66 #initialize and open temporary file
67 tmpfile = open('_pybTmp.tmp','w+')
68 infile = tmpfile
69
70 if passedIn != "":
71 infile = program.load(passedIn,tmpfile)
72 program.execute(infile,tmpfile)
73
74 # Continuously accept user input and act on it until
75 # the user enters 'EXIT'
76 while True:
77
78 # kfw stmt = input_keyboard(': ')
79 stmt = input(': ')
80
81 try:
82 #if True:
83 tokenlist = lexer.tokenize(stmt)
84
85 # Execute commands directly, otherwise
86 # add program statements to the stored
87 # BASIC program
88
89 if len(tokenlist) > 0:
90
91 # remove blank tokens
92 i = 0
93 iend = len(tokenlist)
94 for _ in range(iend):
95 if i>0 and tokenlist[i].lexeme.strip() == "" and tokenlist[i].category != Token.STRING:
96 tokenlist.pop(i)
97 else:
98 i+=1
99
100 # Exit the interpreter
101 if tokenlist[0].category == Token.EXIT:
102 if fOpened:
103 infile.close()

Callers

nothing calls this directly

Calls 13

loadMethod · 0.95
executeMethod · 0.95
tokenizeMethod · 0.95
add_stmtMethod · 0.95
delete_statementMethod · 0.95
listMethod · 0.95
saveMethod · 0.95
deleteMethod · 0.95
LexerClass · 0.90
ProgramClass · 0.90
inputFunction · 0.90
print_lexemeMethod · 0.80

Tested by

no test coverage detected