# HG changeset patch # User Windel Bouwman # Date 1375298458 -7200 # Node ID bd26dc13f27078b3c26f10ed1a9ed3919317d8e3 # Parent 74c6a20302d5fad0465bc6b7a1481036e45bd675 Added logger diff -r 74c6a20302d5 -r bd26dc13f270 python/c3/builder.py --- a/python/c3/builder.py Wed Jul 31 17:57:03 2013 +0200 +++ b/python/c3/builder.py Wed Jul 31 21:20:58 2013 +0200 @@ -1,3 +1,4 @@ +import logging import ppci from . import Parser, TypeChecker, Analyzer, CodeGenerator from . astprinter import AstPrinter @@ -9,6 +10,7 @@ Reports errors to the diagnostics system """ def __init__(self, diag): + self.logger = logging.getLogger('c3') self.diag = diag self.parser = Parser(diag) self.tc = TypeChecker(diag) @@ -34,6 +36,7 @@ pkg = self.parser.parseSource(src) if not pkg: return + logging.getLogger('c3').info('Source parsed') # TODO: merge the two below? #AstPrinter().printAst(pkg) diff -r 74c6a20302d5 -r bd26dc13f270 python/c3/parser.py --- a/python/c3/parser.py Wed Jul 31 17:57:03 2013 +0200 +++ b/python/c3/parser.py Wed Jul 31 21:20:58 2013 +0200 @@ -1,18 +1,21 @@ +import logging from . import astnodes, lexer from ppci import CompilerError class Parser: """ Parses sourcecode into an abstract syntax tree (AST) """ def __init__(self, diag): + self.logger = logging.getLogger('c3') self.diag = diag def parseSource(self, source): - self.initLex(source) - try: - self.parsePackage() - return self.mod - except CompilerError as e: - self.diag.addDiag(e) + self.logger.info('Parsing source') + self.initLex(source) + try: + self.parsePackage() + return self.mod + except CompilerError as e: + self.diag.addDiag(e) def Error(self, msg): raise CompilerError(msg, self.token.loc) diff -r 74c6a20302d5 -r bd26dc13f270 python/dag.py --- a/python/dag.py Wed Jul 31 17:57:03 2013 +0200 +++ b/python/dag.py Wed Jul 31 21:20:58 2013 +0200 @@ -15,6 +15,7 @@ def __init__(self, bb): self.mapping = {} self.buildFromBB(bb) + def buildFromBB(self, bb): for ins in bb.Instructions: if type(ins) is ir.BinaryOperator: @@ -39,6 +40,7 @@ self.mapping[ins.result] = N else: pass + def dumpgv(self, outf): outf.write('subgraph {0} {{\n'.format(id(self))) for node in self.mapping.values(): diff -r 74c6a20302d5 -r bd26dc13f270 python/ide.py --- a/python/ide.py Wed Jul 31 17:57:03 2013 +0200 +++ b/python/ide.py Wed Jul 31 21:20:58 2013 +0200 @@ -14,6 +14,7 @@ import c3 import zcc import outstream +import logging class BuildOutput(QTextEdit): @@ -295,6 +296,7 @@ self.buildOutput.append("Done!") if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) app = QApplication(sys.argv) ide = Ide() ide.show()