comparison ide/compiler/parser.py @ 7:2db4d2b362e6

Added xml project
author windel
date Sat, 15 Oct 2011 10:03:21 +0200
parents 1784af239df4
children de004f808e56
comparison
equal deleted inserted replaced
6:1784af239df4 7:2db4d2b362e6
25 if self.token.typ == typ or typ == '': 25 if self.token.typ == typ or typ == '':
26 v = self.token.val 26 v = self.token.val
27 self.NextToken() 27 self.NextToken()
28 return v 28 return v
29 else: 29 else:
30 self.Error('Excected: "{0}", got "{1}"'.format(typ, self.token)) 30 self.Error('Excected: "{0}", got "{1}"'.format(typ, self.token.val))
31 31
32 def hasConsumed(self, typ): 32 def hasConsumed(self, typ):
33 if self.token.typ == typ: 33 if self.token.typ == typ:
34 self.Consume(typ) 34 self.Consume(typ)
35 return True 35 return True
600 return EmptyStatement() 600 return EmptyStatement()
601 self.Error('Unknown statement {0}'.format(self.token)) 601 self.Error('Unknown statement {0}'.format(self.token))
602 except CompilerException as e: 602 except CompilerException as e:
603 print(e) 603 print(e)
604 self.errorlist.append( (e.row, e.col, e.msg)) 604 self.errorlist.append( (e.row, e.col, e.msg))
605 # Do error recovery by skipping all tokens until next ; or end
606 while not (self.token.typ == ';' or self.token.typ == 'end'):
607 self.Consume(self.token.typ)
605 return EmptyStatement() 608 return EmptyStatement()
606 609
607 def parseStatementSequence(self): 610 def parseStatementSequence(self):
608 """ Sequence of statements seperated by ';' """ 611 """ Sequence of statements seperated by ';' """
609 statements = [ self.parseStatement() ] 612 statements = [ self.parseStatement() ]