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
Beispiel #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)
Beispiel #3
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)
    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)
    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)
Beispiel #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)
 def to_source(self, printer: CodePrinter):
     with printer.block():
         self.body.to_source(printer)
Beispiel #8
0
 def to_source(self, printer: CodePrinter):
     with printer.block('(', ')'):
         if self.expression is not None:
             self.expression.to_source(printer)
Beispiel #9
0
    def to_source(self, printer: CodePrinter):
        with printer.block('(', ')'):
            printer.add_token(':' + str(self.voice_name) + ' ')

            self.body.to_source(printer)