Aprimoramento no loop for #51
Open
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:
Inácio Leal e Pedro Cortez Maia
Técnicas utilizadas: Pair programming, Extreme Programming e programação funcional.
#O objetivo principal das mudanças é adicionar suporte para strings e tuplas em loops for
#Em adição melhoramos o escopo variavel do loop
O que foi alterado:
Estende a funcionalidade do loop
for
para iterar sobre strings e tuplas homogêneas, além do suporte existente para listas.Motivo
Como
Type Checker (
statement_type_checker.rs
)get_iterable_element_type()
para centralizar validação de tipos iteráveischeck_for_stmt()
para usar escopo adequado compush()
/pop()
Runtime (
statement_execute.rs
)Statement::For
para tratarExpression::CString
eExpression::Tuple
Mudanças
Iteráveis Suportados
TList<T>
- funcionalidade existente preservadaTString
- itera sobre caracteres como strings individuaisTTuple<T>
- apenas tuplas homogêneas, tuplas heterogêneas rejeitadas em tempo de compilaçãoEscopo da Variável do loop for:
Testando
Breaking Changes
for
continua funcionando inalterado(1, "hello", true)
agora são adequadamente rejeitadas com mensagens de erro clarasArquivos Modificados
src/type_checker/statement_type_checker.rs
src/interpreter/statement_execute.rs