Show More
@@ -29,7 +29,7 b' class parser(object):' | |||||
29 | t = self.current |
|
29 | t = self.current | |
30 | self.current = next(self._iter, None) |
|
30 | self.current = next(self._iter, None) | |
31 | return t |
|
31 | return t | |
32 |
def _match(self, m |
|
32 | def _match(self, m): | |
33 | 'make sure the tokenizer matches an end condition' |
|
33 | 'make sure the tokenizer matches an end condition' | |
34 | if self.current[0] != m: |
|
34 | if self.current[0] != m: | |
35 | raise error.ParseError(_("unexpected token: %s") % self.current[0], |
|
35 | raise error.ParseError(_("unexpected token: %s") % self.current[0], | |
@@ -45,12 +45,12 b' class parser(object):' | |||||
45 | expr = (prefix[0], value) |
|
45 | expr = (prefix[0], value) | |
46 | else: |
|
46 | else: | |
47 | if len(prefix) > 2 and prefix[2] == self.current[0]: |
|
47 | if len(prefix) > 2 and prefix[2] == self.current[0]: | |
48 |
self._match(prefix[2] |
|
48 | self._match(prefix[2]) | |
49 | expr = (prefix[0], None) |
|
49 | expr = (prefix[0], None) | |
50 | else: |
|
50 | else: | |
51 | expr = (prefix[0], self._parse(prefix[1])) |
|
51 | expr = (prefix[0], self._parse(prefix[1])) | |
52 | if len(prefix) > 2: |
|
52 | if len(prefix) > 2: | |
53 |
self._match(prefix[2] |
|
53 | self._match(prefix[2]) | |
54 | # gather tokens until we meet a lower binding strength |
|
54 | # gather tokens until we meet a lower binding strength | |
55 | while bind < self._elements[self.current[0]][0]: |
|
55 | while bind < self._elements[self.current[0]][0]: | |
56 | token, value, pos = self._advance() |
|
56 | token, value, pos = self._advance() | |
@@ -63,12 +63,12 b' class parser(object):' | |||||
63 | if not infix: |
|
63 | if not infix: | |
64 | raise error.ParseError(_("not an infix: %s") % token, pos) |
|
64 | raise error.ParseError(_("not an infix: %s") % token, pos) | |
65 | if len(infix) == 3 and infix[2] == self.current[0]: |
|
65 | if len(infix) == 3 and infix[2] == self.current[0]: | |
66 |
self._match(infix[2] |
|
66 | self._match(infix[2]) | |
67 | expr = (infix[0], expr, (None)) |
|
67 | expr = (infix[0], expr, (None)) | |
68 | else: |
|
68 | else: | |
69 | expr = (infix[0], expr, self._parse(infix[1])) |
|
69 | expr = (infix[0], expr, self._parse(infix[1])) | |
70 | if len(infix) == 3: |
|
70 | if len(infix) == 3: | |
71 |
self._match(infix[2] |
|
71 | self._match(infix[2]) | |
72 | return expr |
|
72 | return expr | |
73 | def parse(self, tokeniter): |
|
73 | def parse(self, tokeniter): | |
74 | 'generate a parse tree from tokens' |
|
74 | 'generate a parse tree from tokens' |
General Comments 0
You need to be logged in to leave comments.
Login now