def _add_comment(psml, SmCommentOriginal, CounterDb): """On matching the comment state machine goto a terminal that does the following: """ if SmCommentOriginal is None: return comment_skip_iid = dial_db.new_incidence_id() # Disconnect from machines being used elsewhere. SmComment = SmCommentOriginal.clone() SmComment.set_id(comment_skip_iid) if SmComment.last_character_set().contains_only(ord('\n')): code = Lng.COMMAND_LIST([ LineCountAdd(1), AssignConstant(E_R.Column, 1), ]) else: count_info = CountInfo.from_StateMachine( SmComment, CounterDb, CodecTrafoInfo=Setup.buffer_codec) code = [ Lng.COMMAND(Assign(E_R.ReferenceP, E_R.LexemeStartP)), CounterDb.do_CountInfo(count_info), Lng.COMMAND(Assign(E_R.LexemeStartP, E_R.ReferenceP)) ] code.append(Lng.GOTO(DoorID.incidence(E_IncidenceIDs.INDENTATION_HANDLER))) terminal = Terminal(CodeTerminal(code), "INDENTATION COMMENT") terminal.set_incidence_id(comment_skip_iid) psml.append((SmComment, terminal))
def _terminal_goto_to_looper(self, analyzer_list, IncidenceId, Name, required_register_set, Pattern=None): """Generate terminal that jumps to a 'looper'. """ door_id = DoorID.state_machine_entry(analyzer_list[0].state_machine_id, self.terminal_factory.dial_db) goto_op = Op.GotoDoorId(door_id) goto_code = [Lng.COMMAND(goto_op, self.terminal_factory.dial_db)] if Pattern is None: return Terminal(CodeTerminal(goto_code), Name, IncidenceId, RequiredRegisterSet=required_register_set, dial_db=self.terminal_factory.dial_db) else: return self.terminal_factory.do_plain( CodeTerminal(goto_code), Pattern, Name, RequiredRegisterSet=required_register_set)
def test(Op): global missing_set # safeguard against double occurence if Op.id in missing_set: missing_set.remove(Op.id) print "%s" % Op.id print " <%s>" % str(Op).replace("\n", "") print " Registers: ", for register, right in sorted(Op.get_register_access_iterable()): txt = "" if right.write_f: txt += "w" if right.read_f: txt += "r" print "%s(%s), " % (register, txt), print if Op.id in _brancher_set: print " IsBranching: True" print " Cost: ", _cost_db[Op.id] print " C-code: {" for line in Lng.COMMAND(Op, dial_db).splitlines(): print " %s" % line print " }\n"