comparison python/c3/parser.py @ 152:b73bc14a3aa3

Light coupling ide and c3 frontend
author Windel Bouwman
date Sat, 02 Mar 2013 09:56:12 +0100
parents 4ae0e02599de
children b28a11c01dbe
comparison
equal deleted inserted replaced
151:afc8c0207984 152:b73bc14a3aa3
1 from . import astnodes, lexer, semantics 1 from . import astnodes, lexer, semantics
2 from ppci.errors import CompilerException, SourceLocation 2 from ppci import CompilerError
3 3
4 # binop precedence for expressions: 4 # binop precedence for expressions:
5 binopPrecs = {'or': 5, 'and': 10, \ 5 binopPrecs = {'or': 5, 'and': 10, \
6 '<': 20, '>': 20, '==': 20, '<=': 20, '>=': 20, '!=': 20, \ 6 '<': 20, '>': 20, '==': 20, '<=': 20, '>=': 20, '!=': 20, \
7 '+': 30, '-': 30, '*': 40, '/': 40 } 7 '+': 30, '-': 30, '*': 40, '/': 40 }
13 self.diag = diag 13 self.diag = diag
14 def parseSource(self, source): 14 def parseSource(self, source):
15 self.initLex(source) 15 self.initLex(source)
16 try: 16 try:
17 self.parsePackage() 17 self.parsePackage()
18 except CompilerException as e: 18 except CompilerError as e:
19 self.diag.diag(e) 19 self.diag.addDiag(e)
20 def Error(self, msg): 20 def Error(self, msg):
21 raise CompilerException(msg, self.token.loc) 21 raise CompilerError(msg, self.token.loc)
22 # Lexer helpers: 22 # Lexer helpers:
23 def Consume(self, typ): 23 def Consume(self, typ):
24 if self.Peak == typ: 24 if self.Peak == typ:
25 return self.NextToken() 25 return self.NextToken()
26 else: 26 else: