示例#1
0
 def __init__(self, parent=None, ast=None):
     if not ast:
         ast = ogAST.Terminator(defName='')
         ast.pos_y = 0
         ast.width = 35
         ast.height = 35
     super(ProcedureStop, self).__init__(parent, ast)
示例#2
0
 def __init__(self, parent=None, ast=None):
     if not ast:
         ast = ogAST.Terminator(defName='')
         ast.pos_y = 0
         ast.width = 35
         ast.height = 35
     super(Join, self).__init__(parent,
                                text=ast.inputString,
                                x=ast.pos_x,
                                y=ast.pos_y,
                                hyperlink=ast.hyperlink)
     self.set_shape(ast.width, ast.height)
     self.setPen(QPen(Qt.blue))
     self.terminal_symbol = True
     self.parser = ogParser
示例#3
0
def find_labels(trans):
    '''
        Yield a list of transition actions whenever a label is found
        Used to transform labels into floating labels so that the gotos
        in a backend can be contained within a single scope.
    '''
    if not trans:
        return
    # Terminators can have a label - add it to the transition actions
    # (to trigger a goto at code generation)
    if trans.terminator and trans.terminator.label:
        trans.actions.append(trans.terminator.label)
        trans.terminator.label = None
    # Then for each action, check if there are labels and yield
    # a new transition with the remaining actions (following the label)
    for idx, action in enumerate(trans.actions):
        if isinstance(action, ogAST.Label):
            new_trans = ogAST.Transition()
            # Create a floating label
            flab = ogAST.Floating_label(label=action)
            new_trans.actions = \
                    trans.actions[slice(idx + 1, len(trans.actions))]
            new_trans.terminator = trans.terminator
            new_trans.terminators = trans.terminators
            flab.transition = new_trans
            # Transform the label into a JOIN in the original transition
            trans.actions[idx:] = []
            trans.terminator = ogAST.Terminator()
            trans.terminator.inputString = action.inputString
            trans.terminator.kind = 'join'
            # Recursively find labels in the new transition
            for flabel in find_labels(flab.transition):
                yield flabel
            # Then yield the new transition
            yield flab
        elif isinstance(action, ogAST.Decision):
            for answer in action.answers:
                for new_fl in find_labels(answer.transition):
                    # Append the remaining actions of the transition
                    if not new_fl.transition.terminator:
                        new_fl.transition.actions.extend(trans.actions[slice(
                            idx + 1, len(trans.actions))])
                        new_fl.transition.terminator = trans.terminator
                    yield new_fl