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

Class BASICParser

PyBasic/basicparser.py:102–1766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101"""
102class BASICParser:
103
104 def __init__(self):
105 # Symbol table to hold variable names mapped
106 # to values
107 self.__symbol_table = {}
108
109 # Stack on which to store operands
110 # when evaluating expressions
111 self.__operand_stack = []
112
113 # List to hold contents of DATA statement
114 self.__data_values = []
115
116 # These values will be
117 # initialised on a per
118 # statement basis
119 self.__tokenlist = []
120 self.__tokenindex = None
121
122 # used to determine when to initalize extant loop variables
123 self.last_flowsignal = None
124
125 # Set to keep track of print column across multiple print statements
126 self.__prnt_column = 0
127
128 #file handle list
129 self.__file_handles = {}
130
131 self.__pwm = None
132 if implementation.name.upper() == 'MICROPYTHON':
133 if sndPin:
134 try:
135 self.__pwm = PWM(sndPin,freq=0)
136 except:
137 try:
138 self.__pwm = PWM(sndPin)
139 except:
140 pass
141 if 'duty_u16' in dir(self.__pwm):
142 self.__pwm.duty_u16(0)
143 elif 'duty' in dir(self.__pwm):
144 self.__pwm.duty(0)
145
146
147 def parse(self, tokenlist, line_number, cstmt_number, infile, tmpfile, datastmts):
148 """Must be initialised with the list of
149 BTokens to be processed. These tokens
150 represent a BASIC statement without
151 its corresponding line number.
152
153 :param tokenlist: The tokenized program statement
154 :param line_number: The line number of the statement
155 :param cstmt_number: Which statement in a multistatment line
156
157 :return: The FlowSignal to indicate to the program
158 how to branch if necessary, None otherwise
159

Callers 1

executeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected