Skip to content
Myr

this fixes #1.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 79af8af · Browse files · 2 files+17 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−1 removed

  • other:+17 added−1 removed

2 files+17 added−1 removed

modified:jinja/datastructure.py+16 added
527 unmodified lines
528class TokenStream(object):529 """530 A token stream wraps a generator and supports pushing tokens back.531 It also provides some functions to expect tokens and similar stuff.532533 Important note: Do never push more than one token back to the534 stream. Although the stream object won't stop you535 from doing so, the behavior is undefined. Multiple536 pushed tokens are only used internally!537 """538539 def __init__(self, generator, filename):540 self._next = generator.next
40 unmodified lines
581 """Got n tokens ahead."""582 for x in xrange(n):583 self.next()584585 def shift(self, token):586 """587 Push one token into the stream.588 """589 old_current = self.current590 self.next()591 self.push(self.current)592 self.push(old_current)593 self.push(token)594 self.next()595596 def next(self):597 """Go one token ahead."""598 if self._pushed:599 self.current = self._pushed.pop()
93 unmodified lines
modified:jinja/parser.py+1 added-1 removed
1135 unmodified lines
1136 self.stream.expect('block_end')1137 else:1138 extends = None1139 if leading_whitespace:1140 self.stream.push(leading_whitespace)1140 self.stream.shift(leading_whitespace)11411142 body = self.subparse(None)1143 def walk(nodelist, stack):1144 for node in nodelist:
28 unmodified lines