feat(parser): Implementa parser para if-elif-else e corrige função 'keyword' #52
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.
Responsáveis:
Mudanças feitas
Este PR introduz um parser mais robusto para estruturas condicionais na linguagem r-python, adicionando suporte completo para a cadeia
if-elif-else, e corrige um bug encontrado na funçãokeyworddurante o desenvolvimento.Principais Mudanças:
Novo Parser
if-elif-else:parse_if_chain_statementque lida comif, múltiploselifs e umelseopcional.parse_if_else_statementfoi mantida no código. No parser principal (parse_statement), a nova função é chamada antes da antiga para garantir que estruturas comelifsejam reconhecidas corretamente.Correção em
keyword:keywordfalhava ao tentar analisar uma palavra-chave seguida por outro identificador (ex:if True), o que impediu a execução inicial dos testes.peek(not(alphanumeric1)), garantindo que a palavra-chave seja reconhecida corretamente sem conflito com o código que a sucede. Com isso, conseguimos executar os testes para o novo parser com sucesso.Testes:
Adicionado um novo conjunto de testes unitários para a função
parse_if_chain_statement, cobrindo os cenários deif,if-else,if-elifeif-elif-else. Ao executá-los utilizando o comandocargo test, obtivemos sucesso.Como Testar:
Basta rodar
cargo test. Todos os testes devem passar.Arquivos alterados