Project

General

Profile

« Previous | Next » 

Revision 1397

Parser.py: Renamed _syntax_err() to syntax_err() to make it a public method

View differences:

Parser.py
12 12
        self._pos = 0
13 13
    
14 14
    def end(self):
15
        if not self._pos == len(self._str): self._syntax_err('End of string')
15
        if not self._pos == len(self._str): self.syntax_err('End of string')
16 16
    
17 17
    def str_(self, str_, required=False):
18 18
        end_pos = self._pos + len(str_)
19 19
        if self._str[self._pos:end_pos] == str_:
20 20
            self._pos = end_pos
21 21
            return True
22
        elif required: self._syntax_err(str_)
22
        elif required: self.syntax_err(str_)
23 23
        else: return False
24 24
    
25 25
    def re(self, pattern, required=False):
......
27 27
        if matcher:
28 28
            self._pos = matcher.end(0)
29 29
            return matcher.group(0)
30
        elif required: self._syntax_err(pattern)
30
        elif required: self.syntax_err(pattern)
31 31
        else: return None
32 32
    
33
    def _syntax_err(self, token):
33
    def syntax_err(self, token):
34 34
        after = self._str[self._pos:]
35 35
        if after == '': after += '<END>'
36 36
        raise SyntaxException(self.__class__.__name__+' syntax error: '+token

Also available in: Unified diff