def __str__(self): def typenamify(item): return 'typename ' + str(item) builder = StringBuilder() builder.addN("template<%s >" % strlist(self.variables, form=typenamify)) builder.addPN(strlist(self.parameters, form=str)) return builder.contents
def __str__(self): indvar = str(self.parameters[0]) lb = self.parameters[1].arguments()[0] ub = self.parameters[1].arguments()[1] body = _indent(strlist(self.parameters[2], sep='\n', form=str)) orelse = _indent(strlist(self.parameters[3], sep='\n', form=str)) return '<ForStmt>\n<LoopHeader>\n<Induction>%s</Induction>\n<Start>%s</Start>\n<Stop>%s</Stop>\n</LoopHeader>\n<LoopBody>\n%s\n</LoopBody>\n</ForStmt>\n' % (indvar,lb, ub,body)
def __str__(self): builder = StringBuilder() builder.add_('struct') builder.add_(str(self.variables[0])) builder.addN('{') indentation.indent() strlist(self.parameters, sep = '', form = builder.addP) indentation.dedent() builder.addPSN('}') return builder.contents
def __str__(self): builder = StringBuilder() builder.add_('while') builder.add_('(%s)' % self.parameters[0]) builder.addN(self.begin_block) indentation.indent() strlist(self.parameters[1], sep = '', form = builder.addPSN) indentation.dedent() builder.addPN(self.end_block) return builder.contents
def __str__(self): builder = StringBuilder() builder.add_('for') builder.add_(strlist([self.parameters[0], self.parameters[1], self.parameters[2]], bracket = '()', sep = '; ', form=str)) builder.addN(self.begin_block) indentation.indent() strlist(self.parameters[3], sep = '', form = builder.addPSN) indentation.dedent() builder.addPN(self.end_block) return builder.contents
def __str__(self): builder = StringBuilder() if self.cuda_kind != None: builder.add_(self.cuda_kind) if self.return_type != None: builder.add_(self.return_type) builder.add(self.id) argumentDeclaration = '(' + strlist(self.arguments, sep = ', ', form=str) + ')' builder.add_(argumentDeclaration) builder.addN(self.begin_block) indentation.indent() strlist(self.parameters, sep = '', form=builder.addPSN) indentation.dedent() builder.addPN(self.end_block) return builder.contents
def __str__(self): if len(self.parameters) > 1: return strlist(self.parameters, "()", form=str) else: if not (self.parameters): return '()' else: return str(self.parameters[0])
def __str__(self): if len(self.parameters) > 1: return strlist(self.parameters, "()", form=str) else: if not(self.parameters): return '()' else: return str(self.parameters[0])
def __str__(self): builder = StringBuilder() builder.add_('if') # XXX Are the brackets here necessary? They perhaps could be removed builder.add_(strlist([self.parameters[0]], bracket = '()', sep = ' ', form=str)) builder.addN(self.begin_block) indentation.indent() strlist(self.parameters[1], sep = '', form = builder.addPSN) indentation.dedent() if (len(self.parameters[2]) > 1) or not isinstance(self.parameters[2][0], Null): builder.addP_(self.end_block) builder.add_('else') builder.addN(self.begin_block) indentation.indent() strlist(self.parameters[2], sep = '', form = builder.addPSN) indentation.dedent() builder.addPN(self.end_block) return builder.contents
def __str__(self): def makeSeparator(label): length = (CCommentBlock.width - len(label))/2 starsA = '*' * length separator = '/' + starsA + ' ' + label + ' ' starsBLength = CCommentBlock.width - len(separator) - 1 separator = separator + '*' * starsBLength + '/' return separator builder = StringBuilder() builder.addN(makeSeparator('Begin ' + self.variables[0])) for comment in self.variables[1:]: builder.addPN(comment) #builder.addN('') strlist(self.parameters, sep = '', form=builder.addPSN) #builder.addN('') builder.addPN(makeSeparator('End ' + self.variables[0])) return builder.contents
def print_source(ast, step=4, indentation=0, prefix=''): lead = prefix + ' ' * indentation if isinstance(ast, Procedure): name = ast.variables[0] args = strlist(ast.variables[1:], '()', form=str) body = ast.parameters print "%sdef %s%s:" % (lead, name, args) print_source(body, step, indentation + step, prefix) elif isinstance(ast, list): for s in ast: print_source(s, step, indentation, prefix) else: print "%s%s" % (lead, ast)
def print_source(ast, step=4, indentation=0, prefix=''): lead = prefix + ' '*indentation if isinstance(ast, Procedure): name = ast.variables[0] args = strlist(ast.variables[1:], '()', form=str) body = ast.parameters print "%sdef %s%s:" % (lead, name, args) print_source(body, step, indentation+step, prefix) elif isinstance(ast, list): for s in ast: print_source(s, step, indentation, prefix) else: print "%s%s" % (lead, ast)
def __repr__(self): return 'Zip(%s)' % strlist(self.parameters, sep=', ', form=repr)
def __repr__(self): return "%r<%r >" %(repr(self.id), strlist(self.parameters, sep = ', ', form=repr))
def __str__(self): return 'map' + strlist(self.parameters, '()', form=str)
def __str__(self): test = str(self.test()) body = _indent(strlist(self.body(), sep='\n', form=str)) orelse = _indent(strlist(self.orelse(), sep='\n', form=str)) return 'if %s:\n%s\nelse:\n%s' % (test, body, orelse)
def __str__(self): fn, args = self.parameters[0], self.parameters[1:] op = str(fn) if not isinstance(fn, (str,Name)): op = _paren(op) return op + strlist(args, '()', form=str)
def __repr__(self): v, e = self.variables, self.parameters[0] return "Closure(%s, %r)" % (strlist(v,'[]',form=repr), e)
def __repr__(self): v, e = self.variables, self.parameters[0] return "Closure(%s, %r)" % (strlist(v, '[]', form=repr), e)
def __str__(self): v, e = self.variables, self.parameters[0] return "closure(%s, %s)" % (strlist(v, '[]', form=str), e)
def __str__(self): fn, args = self.parameters[0], self.parameters[1:] op = str(fn) if not isinstance(fn, (str, Name)): op = _paren(op) return op + strlist(args, '()', form=str)
def __str__(self): v, e = self.variables, self.parameters[0] return "lambda " + strlist(v, form=str) + ": " + str(e)
def __repr__(self): fn, args = self.parameters[0], self.parameters[1:] return "Apply(%r, %s)" % (fn, strlist(args, '[]', form=repr))
def ast_to_string(input): return pltools.strlist(input, sep='\n', form=str)
def __str__(self): return 'zip(%s)' % strlist(self.parameters, sep=', ', form=str)
def ast_to_string(ast): return strlist(ast, sep='\n', form=str)
def __str__(self): if not self.parameters: return self.name else: args = strlist(self.parameters, bracket='()', form=str) return "%s%s" % (self.name, args)
def __str__(self): body = _indent(strlist(self.parameters[1], sep='\n', form=str)) return 'while %s:\n%s' % (self.parameters[0], body)
def __str__(self): v, e = self.variables, self.parameters[0] return "closure(%s, %s)" % (strlist(v,'[]',form=str), e)
def __str__(self): id = self.variables[0] args = strlist(self.variables[1:], '()', form=str) body = _indent(strlist(self.parameters, sep='\n', form=str)) return 'def %s%s:\n%s' % (id, args, body)
def __str__(self): return strlist(self.parameters, '', sep=', ', form=str)
def __str__(self): vars = strlist(self.variables, form=str) return "ForAll %s: %s" % (vars, self.monotype())
def __str__(self): return "%s<%s >" %(str(self.id), strlist(self.parameters, sep = ', ', form=str))
def __repr__(self): return self.__class__.__name__ + \ strlist(self.children(), '()', form=repr)
def __repr__(self): return 'PhaseBoundary(%s)' % strlist(self.parameters)