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)
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)
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)
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)
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): 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): 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)
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
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 ): printer.add_token( 'import ' ) if self.local: printer.add_token( f'"{self.module_name}"' ) else: printer.add_token( self.module_name )
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)
def to_source(self, printer: CodePrinter): printer.add_token(self.note.to_string(base_octave=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)
def to_source(self, printer: CodePrinter): printer.add_token("<VALUE>")
def to_source ( self, printer : CodePrinter ): printer.add_token( 'T' + str( self.tempo ) )
def to_source(self, printer: CodePrinter): printer.add_token('O' + str(self.octave))
def to_source ( self, printer : CodePrinter ): printer.add_token( "none" )
def to_source(self, printer: CodePrinter): with printer.block('(', ')'): printer.add_token(':' + str(self.voice_name) + ' ') self.body.to_source(printer)
def to_source(self, printer: CodePrinter): printer.add_token("not ") self.node.to_source(printer)
def to_source(self, printer: CodePrinter): printer.add_token('$' + self.name)
def to_source(self, printer: CodePrinter): printer.add_token('S' + str(self.upper) + '/' + str(self.lower))
def to_source(self, printer: CodePrinter): printer.add_token( RestEvent(0, 0, self.value, visible=self.visible).to_string( ('r', 'r')))
def to_source(self, printer: CodePrinter): self.left.to_source(printer) printer.add_token(' ' + self.operator + ' ') self.right.to_source(printer)
def to_source ( self, printer : CodePrinter ): printer.add_token( 'V' + str( self.velocity ) )
def to_source(self, printer: CodePrinter): printer.add_token('true' if self.value else 'false')
def to_source(self, printer: CodePrinter): printer.add_token(str(self.value))
def to_source(self, printer: CodePrinter): printer.add_token('L' + str(self.length))
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()
def to_source(self, printer: CodePrinter): self.left.to_source(printer) printer.add_token(' / ') self.right.to_source(printer)
def to_source ( self, printer : CodePrinter ): printer.add_token( "return " ) if self.expression is not None: self.expression.to_source( printer )