コード例 #1
0
    def to_source(self, printer: CodePrinter):
        self.left.to_source(printer)

        printer.add_token(
            f" { self.operator if self.operator is not None else '' }= ")

        self.right.to_source(printer)
コード例 #2
0
    def to_source(self, printer: CodePrinter):
        with printer.block('@[', ']'):
            for i in range(len(self.values)):
                if i > 0:
                    printer.add_token('; ')

                self.values[i].to_source(printer)
コード例 #3
0
    def to_source(self, printer: CodePrinter):
        for i in range(len(self.statements)):
            if i > 0:
                printer.add_token(';')

            printer.begin_line()

            self.statements[i].to_source(printer)
コード例 #4
0
    def to_source(self, printer: CodePrinter):
        printer.add_token('for ')

        with printer.block('(', ')'):
            printer.add_token(
                ", ".join(["$" + name for name in self.variables]) + " in ")

            self.it.to_source(printer)

        self.body.to_source(printer)
コード例 #5
0
    def to_source(self, printer: CodePrinter):
        from .string_literal_node import StringLiteralNode

        self.expression.to_source(printer)

        if self.as_attr and isinstance(self.name, StringLiteralNode):
            printer.add_token('::' + self.name.value)
        else:
            with printer.block('::[', ']'):
                self.name.to_source(printer)
コード例 #6
0
    def to_source(self, printer: CodePrinter):
        with printer.block('@{', '}'):
            for i in range(len(self.values)):
                if i > 0:
                    printer.add_token('; ')

                key, node = self.values[i]

                printer.add_token(str(key) + ' = ')

                node.to_source(printer)
コード例 #7
0
    def to_source(self, printer: CodePrinter):
        for i, op in enumerate(self.to_source):
            if i > 0:
                printer.add_token(", ")

            op.to_source(printer)

        printer.add_token(
            f" { self.operator if self.operator is not None else '' }= ")

        self.right.to_source(printer)
コード例 #8
0
    def to_source ( self, printer : CodePrinter ):
        from .variable_expression_node import VariableExpressionNode

        if isinstance( self.expression, VariableExpressionNode ):
            printer.add_token( self.expression.name )
        else:
            self.expression.to_source( printer )
        
        with printer.block( '(', ')' ):
            for i in range( len( self.parameters ) ):
                if i > 0:
                    printer.add_token( '; ' )
                
                self.parameters[ i ].to_source( printer )

            not_first = bool( self.parameters )

            for key, node in self.named_parameters.items():
                if not_first:
                    printer.add_token( '; ' )

                printer.add_token( key + ' = ' )
                
                node.to_source( printer )

                not_first = True
コード例 #9
0
 def to_source(self, printer: CodePrinter):
     if self.is_expression:
         printer.add_token('@py')
         with printer.block():
             printer.add_token(self.code)
     else:
         printer.add_token('@python ')
         printer.add_token(self.code)
コード例 #10
0
    def to_source ( self, printer : CodePrinter ):
        printer.add_token( 'import ' )

        if self.local:
            printer.add_token( f'"{self.module_name}"' )
        else:
            printer.add_token( self.module_name )
コード例 #11
0
    def to_source(self, printer: CodePrinter):
        from ..expressions.group_node import GroupNode
        from ..expressions.block_node import BlockNode

        printer.add_token('if ')

        self.condition.to_source(printer)

        if not isinstance(self.condition, GroupNode) and not isinstance(
                self.body, BlockNode):
            printer.add_token(" then ")
        else:
            printer.add_token(" ")

        self.body.to_source(printer)

        if self.else_body is not None:
            printer.add_token(" else ")

            self.else_body.to_source(printer)
コード例 #12
0
 def to_source(self, printer: CodePrinter):
     printer.add_token(self.note.to_string(base_octave=0))
コード例 #13
0
    def to_source(self, printer: CodePrinter):
        for i in range(len(self.expressions)):
            if i > 0: printer.add_token(' ')

            self.expressions[i].to_source(printer)
コード例 #14
0
 def to_source(self, printer: CodePrinter):
     printer.add_token("<VALUE>")
コード例 #15
0
 def to_source ( self, printer : CodePrinter ):
     printer.add_token( 'T' + str( self.tempo ) )
コード例 #16
0
 def to_source(self, printer: CodePrinter):
     printer.add_token('O' + str(self.octave))
コード例 #17
0
 def to_source ( self, printer : CodePrinter ):
     printer.add_token( "none" )
コード例 #18
0
    def to_source(self, printer: CodePrinter):
        with printer.block('(', ')'):
            printer.add_token(':' + str(self.voice_name) + ' ')

            self.body.to_source(printer)
コード例 #19
0
    def to_source(self, printer: CodePrinter):
        printer.add_token("not ")

        self.node.to_source(printer)
コード例 #20
0
 def to_source(self, printer: CodePrinter):
     printer.add_token('$' + self.name)
コード例 #21
0
 def to_source(self, printer: CodePrinter):
     printer.add_token('S' + str(self.upper) + '/' + str(self.lower))
コード例 #22
0
 def to_source(self, printer: CodePrinter):
     printer.add_token(
         RestEvent(0, 0, self.value, visible=self.visible).to_string(
             ('r', 'r')))
コード例 #23
0
    def to_source(self, printer: CodePrinter):
        self.left.to_source(printer)

        printer.add_token(' ' + self.operator + ' ')

        self.right.to_source(printer)
コード例 #24
0
 def to_source ( self, printer : CodePrinter ):
     printer.add_token( 'V' + str( self.velocity ) )
コード例 #25
0
 def to_source(self, printer: CodePrinter):
     printer.add_token('true' if self.value else 'false')
コード例 #26
0
 def to_source(self, printer: CodePrinter):
     printer.add_token(str(self.value))
コード例 #27
0
 def to_source(self, printer: CodePrinter):
     printer.add_token('L' + str(self.length))
コード例 #28
0
    def to_source(self, printer: CodePrinter):
        printer.add_token('fun ')

        if self.name is not None:
            printer.add_token(self.name + ' ')

        printer.begin_block('(', ')')

        for i in range(len(self.arguments)):
            if i > 0:
                printer.add_token(', ')

            name, mod, expr = self.arguments[i]

            if mod is not None:
                printer.add_token(mod + ' ')

            printer.add_token('$' + name)

            if expr is not None:
                printer.add_token(' = ')

                expr.to_source(printer)

        printer.end_block()

        printer.begin_block()

        self.body.to_source(printer)

        printer.end_block()
コード例 #29
0
    def to_source(self, printer: CodePrinter):
        self.left.to_source(printer)

        printer.add_token(' / ')

        self.right.to_source(printer)
コード例 #30
0
    def to_source ( self, printer : CodePrinter ):
        printer.add_token( "return " )

        if self.expression is not None:
            self.expression.to_source( printer )