Skip to content

Commit 308e0fc

Browse files
committed
Use consistent variable names in get_entry_or_junk
Prior to this change, variables were using _index and _pos suffixes (or no suffix) to all refer to stream indexes. This change switches all of them to use _index, which will make future refactors clearer.
1 parent bc5b0e5 commit 308e0fc

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

fluent.syntax/fluent/syntax/parser.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,26 @@ def parse_entry(self, source: str) -> ast.EntryType:
111111
return self.get_entry_or_junk(ps)
112112

113113
def get_entry_or_junk(self, ps: FluentParserStream) -> ast.EntryType:
114-
entry_start_pos = ps.index
114+
entry_start_index = ps.index
115115

116116
try:
117117
entry = self.get_entry(ps)
118118
ps.expect_line_end()
119119
return entry
120120
except ParseError as err:
121121
error_index = ps.index
122-
ps.skip_to_next_entry_start(entry_start_pos)
123-
next_entry_start = ps.index
124-
if next_entry_start < error_index:
122+
123+
ps.skip_to_next_entry_start(entry_start_index)
124+
next_entry_start_index = ps.index
125+
if next_entry_start_index < error_index:
125126
# The position of the error must be inside of the Junk's span.
126-
error_index = next_entry_start
127+
error_index = next_entry_start_index
127128

128129
# Create a Junk instance
129-
slice = ps.string[entry_start_pos:next_entry_start]
130+
slice = ps.string[entry_start_index:next_entry_start_index]
130131
junk = ast.Junk(slice)
131132
if self.with_spans:
132-
junk.add_span(entry_start_pos, next_entry_start)
133+
junk.add_span(entry_start_index, next_entry_start_index)
133134
annot = ast.Annotation(
134135
err.code, list(err.args) if err.args else None, err.message
135136
)

0 commit comments

Comments
 (0)