def _assignment(self): word = self.pascal_parser.current_word assignment = self.symbol_table.get(word, None) if not assignment: raise ValueError("Identifier does not exist: '%s'" % word) if self.pascal_parser.get_next_token() != TK_ASSIGNMENT: raise ValueError("Expected Assignment: Got %s" % self.pascal_parser.current_word) self.pascal_parser.get_next_token() result = evaluate_expression(self.pascal_parser, self.symbol_table) handle_int_real_conversion(assignment['data_type'], result[0], assignment=True) assignment['value'] = result[1] OutputBuffer.add("pusha %s" % assignment['address'])
def _write(self): if self.pascal_parser.get_next_token() != TK_LEFT_PAREN: raise ValueError("Expected '(': Got '%s'" % self.pascal_parser.current_word) evaluate_expression(self.pascal_parser, self.symbol_table) OutputBuffer.add("write")