Some last fstring fixes.

This commit is contained in:
Dave Halter
2017-08-28 18:10:30 +02:00
parent cba82773d4
commit b921e280b0
4 changed files with 5 additions and 6 deletions

View File

@@ -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)

View File

@@ -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]

View File

@@ -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)

View File

@@ -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