Exemple #1
0
    def __generateCode(self, stmts, int_vars):
        """To generate the tiled loop code"""

        # generate the declaration code for the newly declared integer variables
        code = ""
        for i, iv in enumerate(int_vars):
            if i % 8 == 0:
                code += "\n  int "
            code += iv
            if i % 8 == 7 or i == len(int_vars) - 1:
                code += ";"
            else:
                code += ","
        if int_vars:
            code += "\n\n"

        # generate the tiled code
        for s in stmts:
            code += pprinter.PrettyPrinter().pprint(s)

        # append and prepend newlines (if necessary)
        if code[0] != "\n":
            code = "\n" + code
        if code[-1] != "\n":
            code = code + "\n"

        # return the generated code
        return code
Exemple #2
0
    def __generate(self, stmts, int_vars):
        '''To generate the tiled loop code'''

        # generate the declaration code for the new integer variables
        code = ''
        for i, iv in enumerate(int_vars):
            if i % 10 == 0:
                code += '\n  int '
            code += str(iv)
            if i % 10 == 9 or i == len(int_vars) - 1:
                code += ';'
            else:
                code += ','
        if int_vars:
            code += '\n\n'

        # generate the tiled code
        p = pprinter.PrettyPrinter()
        for s in stmts:
            code += p.pprint(s)

        # append and prepend newlines (if necessary)
        if code[0] != '\n':
            code = '\n' + code
        if code[-1] != '\n':
            code = code + '\n'

        # return the generated code
        return code
Exemple #3
0
 def __repr__(self):
     '''Return a string representation for this AST object'''
     return pprinter.PrettyPrinter().pprint(self)
Exemple #4
0
                        nargs='*')
    parser.add_argument("-r",
                        "--raw",
                        help="Affichage de la représentation interne des "
                        "résultats de l'extraction sur la sortie standard",
                        action="store_true")
    parser.add_argument("-o",
                        "--output",
                        help="Sortie à utiliser pour les "
                        "résultats de l'extraction (stdout par défaut")
    parser.add_argument("-of",
                        "--output-format",
                        help="Format des données écrites en sortie",
                        choices=["dict", "xml"],
                        default="dict")
    args = parser.parse_args()

    if args.filename:
        pubs_filens = args.filename
    else:
        pubs_filens = [input("Chemin du fichier contenant les publications: ")]

    pub_types = [ConferencePub, JournalPub, RevuePub]
    classifier = Classifier(pub_types)
    extractor = Extractor(classifier)

    pubs_gen = chain(*map(lambda f: PubsCorpus(f).get_pubs(), pubs_filens))

    pp = pprinter.PrettyPrinter(args, extractor.pubs_data(pubs_gen))
    pp.print()