Esempio n. 1
0
 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
Esempio n. 2
0
 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) 
Esempio n. 3
0
 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
Esempio n. 4
0
 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
Esempio n. 5
0
 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
Esempio n. 6
0
 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
Esempio n. 7
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])
Esempio n. 8
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])
Esempio n. 9
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
Esempio n. 10
0
 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
Esempio n. 11
0
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)
Esempio n. 12
0
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)
Esempio n. 13
0
 def __repr__(self):
     return 'Zip(%s)' % strlist(self.parameters, sep=', ', form=repr)
Esempio n. 14
0
 def __repr__(self):
     return "%r<%r >" %(repr(self.id), strlist(self.parameters, sep = ', ', form=repr))
Esempio n. 15
0
 def __str__(self):
     return 'map' + strlist(self.parameters, '()', form=str)
Esempio n. 16
0
 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)
Esempio n. 17
0
 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)
Esempio n. 18
0
 def __repr__(self):
     v, e = self.variables, self.parameters[0]
     return "Closure(%s, %r)" % (strlist(v,'[]',form=repr), e)
Esempio n. 19
0
 def __repr__(self):
     v, e = self.variables, self.parameters[0]
     return "Closure(%s, %r)" % (strlist(v, '[]', form=repr), e)
Esempio n. 20
0
 def __str__(self):
     v, e = self.variables, self.parameters[0]
     return "closure(%s, %s)" % (strlist(v, '[]', form=str), e)
Esempio n. 21
0
 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)
Esempio n. 22
0
 def __str__(self):
     v, e = self.variables, self.parameters[0]
     return "lambda " + strlist(v, form=str) + ": " + str(e)
Esempio n. 23
0
 def __repr__(self):
     fn, args = self.parameters[0], self.parameters[1:]
     return "Apply(%r, %s)" % (fn, strlist(args, '[]', form=repr))
Esempio n. 24
0
def ast_to_string(input):
    return pltools.strlist(input, sep='\n', form=str)
Esempio n. 25
0
 def __str__(self):
     return 'zip(%s)' % strlist(self.parameters, sep=', ', form=str) 
Esempio n. 26
0
def ast_to_string(ast):
    return strlist(ast, sep='\n', form=str)
Esempio n. 27
0
 def __str__(self):
     return 'map' + strlist(self.parameters, '()', form=str)
Esempio n. 28
0
 def __repr__(self):
     fn, args = self.parameters[0], self.parameters[1:]
     return "Apply(%r, %s)" % (fn, strlist(args, '[]', form=repr))
Esempio n. 29
0
 def __str__(self):
     if not self.parameters:
         return self.name
     else:
         args = strlist(self.parameters, bracket='()', form=str)
         return "%s%s" % (self.name, args)
Esempio n. 30
0
 def __str__(self):
     v, e = self.variables, self.parameters[0]
     return "lambda " + strlist(v, form=str) + ": " + str(e)
Esempio n. 31
0
 def __str__(self):
     body = _indent(strlist(self.parameters[1], sep='\n', form=str))
     return 'while %s:\n%s' % (self.parameters[0], body)
Esempio n. 32
0
 def __str__(self):
     v, e = self.variables, self.parameters[0]
     return "closure(%s, %s)" % (strlist(v,'[]',form=str), e)
Esempio n. 33
0
 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)
Esempio n. 34
0
 def __str__(self):
     return strlist(self.parameters, '', sep=', ', form=str)
Esempio n. 35
0
 def __str__(self):
     vars = strlist(self.variables, form=str)
     return "ForAll %s: %s" % (vars, self.monotype())
Esempio n. 36
0
 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)
Esempio n. 37
0
 def __str__(self):
     return "%s<%s >" %(str(self.id), strlist(self.parameters, sep = ', ', form=str))
Esempio n. 38
0
 def __repr__(self):
     return self.__class__.__name__ + \
            strlist(self.children(), '()', form=repr)
Esempio n. 39
0
def ast_to_string(ast):
    return strlist(ast, sep='\n', form=str)
Esempio n. 40
0
 def __str__(self):
     if not self.parameters:
         return self.name
     else:
         args = strlist(self.parameters, bracket='()', form=str)
         return "%s%s" % (self.name, args)
Esempio n. 41
0
 def __repr__(self):
     return 'PhaseBoundary(%s)' % strlist(self.parameters)
Esempio n. 42
0
 def __str__(self):
     return strlist(self.parameters, '', sep=', ', form=str)
Esempio n. 43
0
 def __repr__(self):
     return self.__class__.__name__ + \
            strlist(self.children(), '()', form=repr)
Esempio n. 44
0
 def __str__(self):
     vars = strlist(self.variables, form=str)
     return "ForAll %s: %s" % (vars, self.monotype())
Esempio n. 45
0
    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)