Mercurial > lcfOS
changeset 254:bd26dc13f270
Added logger
author | Windel Bouwman |
---|---|
date | Wed, 31 Jul 2013 21:20:58 +0200 |
parents | 74c6a20302d5 |
children | 7416c923a02a |
files | python/c3/builder.py python/c3/parser.py python/dag.py python/ide.py |
diffstat | 4 files changed, 16 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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)
--- 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():
--- 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()