Skip to content

Commit e06d711

Browse files
committed
Fix IterGen issue
1 parent a7b657f commit e06d711

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

syncode/parsers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def create_parser(
2222
cache_filename = parser_cache_dir + f'{grammar}_{parser}_{grammar.hash()}_parser.pkl'
2323
os.makedirs(os.path.dirname(parser_cache_dir), exist_ok=True)
2424

25-
if grammar.name == 'python':
25+
if grammar.name == 'python' and not use_symbol_pos_map:
2626
indenter = PythonIndenter()
2727

2828
base_parser = create_base_parser(grammar, parser, indenter, cache_filename)

syncode/parsers/incremental_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ def get_acceptable_next_terminals(self, partial_code) -> ParseResult:
136136
Returns the set of acceptable terminals at the current partial code position.
137137
"""
138138
# Stores the sequence of tokens that the parser has seen in the order
139-
interactive = self.interactive
140139
lexer_tokens, lexing_incomplete = self._lex_code(partial_code)
141-
self.next_ac_terminals = self._accepts(interactive)
140+
self.next_ac_terminals = self._accepts(self.interactive)
142141

143142
# Restore the previous state of the parser
144143
self._restore_recent_parser_state(lexer_tokens)
144+
interactive = self.interactive
145145

146146
# Parse the tokens
147147
self.time_accepts = 0

syncode/parsers/itergen_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def _store_parser_state(
230230
# Store parsed tokens, parser state, terminal sets, indent levels, dedent queue, and symbol pos map
231231
self.cur_pos_to_parser_state[key] = (
232232
copy.deepcopy(self.parsed_lexer_tokens),
233-
parser_state,
233+
parser_state.copy(),
234234
cur_ac_terminals,
235235
next_ac_terminals,
236236
indent_levels,
@@ -336,12 +336,12 @@ def get_acceptable_next_terminals(
336336
Now handles updating the symbol position map during parsing.
337337
"""
338338
# Get lexer tokens and initialize state
339-
interactive = self.interactive
340339
lexer_tokens, lexing_incomplete = self._lex_code(partial_code)
341-
self.next_ac_terminals = self._accepts(interactive)
340+
self.next_ac_terminals = self._accepts(self.interactive)
342341

343342
# Restore the previous state of the parser
344343
self._restore_recent_parser_state(lexer_tokens, symbol_pos_map=symbol_pos_map)
344+
interactive = self.interactive
345345

346346
# Update symbol position map for terminals if provided
347347
if symbol_pos_map is not None:

0 commit comments

Comments
 (0)