From b921e280b0a6e8912a096a7b95e72f73a6adb9c1 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 28 Aug 2017 18:10:30 +0200 Subject: [PATCH] Some last fstring fixes. --- parso/grammar.py | 2 +- parso/python/diff.py | 2 +- parso/python/grammar36.txt | 3 --- parso/python/tokenize.py | 4 +++- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/parso/grammar.py b/parso/grammar.py index 0949280..c54c9ba 100644 --- a/parso/grammar.py +++ b/parso/grammar.py @@ -176,7 +176,7 @@ class Grammar(object): def __repr__(self): - labels = self._pgen_grammar.symbol2number.values() + labels = self._pgen_grammar.number2symbol.values() txt = ' '.join(list(labels)[:3]) + ' ...' return '<%s:%s>' % (self.__class__.__name__, txt) diff --git a/parso/python/diff.py b/parso/python/diff.py index 86b7114..cbf5cd7 100644 --- a/parso/python/diff.py +++ b/parso/python/diff.py @@ -287,7 +287,7 @@ class DiffParser(object): is_first_token = True omitted_first_indent = False indents = [] - tokens = self._tokenizer(lines) + tokens = self._tokenizer(lines, (1, 0)) stack = self._active_parser.pgen_parser.stack for typ, string, start_pos, prefix in tokens: start_pos = start_pos[0] + line_offset, start_pos[1] diff --git a/parso/python/grammar36.txt b/parso/python/grammar36.txt index 70e9b3e..e76147e 100644 --- a/parso/python/grammar36.txt +++ b/parso/python/grammar36.txt @@ -11,9 +11,6 @@ single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE file_input: (NEWLINE | stmt)* ENDMARKER eval_input: testlist NEWLINE* ENDMARKER -# Dave: A modification to parse f-strings. -testlist_comp_with_endmarker: testlist NEWLINE* ENDMARKER - decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE decorators: decorator+ decorated: decorators (classdef | funcdef | async_funcdef) diff --git a/parso/python/tokenize.py b/parso/python/tokenize.py index fa07aeb..8e00cbb 100644 --- a/parso/python/tokenize.py +++ b/parso/python/tokenize.py @@ -255,11 +255,13 @@ def tokenize_lines(lines, version_info, start_pos=(1, 0)): lnum = start_pos[0] - 1 for line in lines: # loop over lines in stream lnum += 1 - pos, max = 0, len(line) + pos = 0 + max = len(line) if first: if line.startswith(BOM_UTF8_STRING): additional_prefix = BOM_UTF8_STRING line = line[1:] + max = len(line) # Fake that the part before was already parsed. line = '^' * start_pos[1] + line