コード例 #1
0
class Option1_Node(Node):
    def __init__(self, t, direc, am, subj, dur=1.0):
        Node.__init__(self)
        self.direction = direc
        self.subject = subj
        self.duration = dur
        self.type = t

        # tries to see if am is a valid int value. If not, then assumes it
        # is a function call.
        try:
            self.amount = int(am)
        except ValueError:
            # function name
            self.left_child = Function_Call(am, None)

            # prints the child nodes.

    def print_children(self, indent_level):
        if self.left_child is None:
            print "Type = " + self.type + ", Direction = " + self.direction + ", Subject = " + self.subject + ", Duration = " + str(
                self.duration
            ) + ", Amount = " + str(
                self.amount
            )
        else:
            print "Type = " + self.type + ", Direction = " + self.direction + ", Subject = " + self.subject + ", Duration = " + str(
                self.duration
            ) + ", Amount = ",
            self.left_child.print_node(indent_level + 1)
コード例 #2
0
    def __init__(self, t, direc, am, subj, dur=1.0):
        Node.__init__(self)
        self.direction = direc
        self.subject = subj
        self.duration = dur
        self.type = t

        # tries to see if am is a valid int value. If not, then assumes it
        # is a function call.
        try:
            self.amount = int(am)
        except ValueError:
            # function name
            self.left_child = Function_Call(am, None)