refactor: use token-based terminator detection in parse_command#329
Merged
refactor: use token-based terminator detection in parse_command#329
Conversation
Replace character-based terminator checks with token-based detection using the Lexer. This enables the EOF token mechanism to work at the command level and improves architectural alignment. Changes: - Add _lex_is_command_terminator() method for token-based checking - Update parse_command() to use token-based terminator detection - Remove unused _is_list_terminator() function - Update PLAN.md to document hybrid approach progress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_lex_is_command_terminator()method that uses the Lexer to detect command terminators via token typesparse_command()to use token-based terminator detection instead of character-level checks_is_list_terminator()functionMotivation
This change improves the Parser's architectural alignment with bash's tokenizer-parser separation. By using token-based terminator detection, the EOF token mechanism (implemented in #327) now works at the command level, not just the list level.
Key Insight
The hybrid approach works because:
_lex_peek_token()doesn't advance Parser position (only_lex_next_token()does)_sync_lexer()bridges the two modesChanges
All 4515 tests pass in both Python and JavaScript.