Skip to content
Myr

lex includes whitespace now which makes it a lot more useful

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 a2eb77d · Browse files · 1 file+5 added−11 removed
This commit

State

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

Diff stats

1 file+5 added−11 removed

  • other:+5 added−11 removed

1 file+5 added−11 removed

modified:jinja2/lexer.py+5 added-11 removed
272 unmodified lines
273 e = re.escape274275 # lexing rules for tags276 tag_rules = [277 (whitespace_re, None, None),277 (whitespace_re, 'whitespace', None),278 (float_re, 'float', None),279 (integer_re, 'integer', None),280 (name_re, 'name', None),281 (string_re, 'string', None),
91 unmodified lines
373 """374 source = unicode(source)375 def generate():376 for lineno, token, value in self.tokeniter(source, name, filename):377 if token in ('comment_begin', 'comment', 'comment_end'):377 if token in ('comment_begin', 'comment', 'comment_end',378 'whitespace'):379 continue380 elif token == 'linestatement_begin':381 token = 'block_begin'382 elif token == 'linestatement_end':
70 unmodified lines
453454 # tuples support more options455 if isinstance(tokens, tuple):456 for idx, token in enumerate(tokens):456 # hidden group457 if token is None:458 g = m.group(idx)459 if g:460 lineno += g.count('\n')461 continue457 # failure group463 elif token.__class__ is Failure:458 if token.__class__ is Failure:459 raise token(lineno, filename)460 # bygroup is a bit more complex, in that case we461 # yield for the current token the first named462 # group that matched
38 unmodified lines
501 (data, expected_op),502 lineno, name,503 filename)504 # yield items510 if tokens is not None:511 yield lineno, tokens, data505 yield lineno, tokens, data506 lineno += data.count('\n')507508 # fetch new position into new variable so that we can check509 # if there is a internal parsing error which would result
42 unmodified lines