Mercurial > lcfOS
diff python/c3/parser.py @ 288:a747a45dcd78
Various styling work
author | Windel Bouwman |
---|---|
date | Thu, 21 Nov 2013 14:26:13 +0100 |
parents | 05184b95fa16 |
children | bd2593de3ff8 |
line wrap: on
line diff
--- a/python/c3/parser.py Thu Nov 21 11:57:27 2013 +0100 +++ b/python/c3/parser.py Thu Nov 21 14:26:13 2013 +0100 @@ -2,6 +2,7 @@ from . import astnodes, lexer from ppci import CompilerError + class Parser: """ Parses sourcecode into an abstract syntax tree (AST) """ def __init__(self, diag): @@ -48,12 +49,12 @@ return t def initLex(self, source): - self.tokens = lexer.tokenize(source) # Lexical stage + self.tokens = lexer.tokenize(source) # Lexical stage self.token = self.tokens.__next__() def addDeclaration(self, decl): self.currentPart.declarations.append(decl) - + def parseImport(self): self.Consume('import') name = self.Consume('ID').val @@ -151,7 +152,7 @@ while self.hasConsumed(','): parseConst() self.Consume(';') - + # Procedures def parseFunctionDef(self): loc = self.Consume('function').loc @@ -395,5 +396,3 @@ d = self.parseDesignator() return astnodes.VariableUse(d, d.loc) self.Error('Expected NUM, ID or (expr), got {0}'.format(self.Peak)) - -