Skip to content

Commit

Permalink
Situações com vírgula.
Browse files Browse the repository at this point in the history
  • Loading branch information
leonelsanchesdasilva committed Feb 27, 2024
1 parent 3cc86e7 commit c4416a5
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions fontes/interpretador/comum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,26 @@ export async function visitarExpressaoLeiaMultiplo(
let valores = 0;
const argumento = expressao.argumento;
if (argumento instanceof Literal) {
valores = argumento.valor;
switch (argumento.valor) {
case ',':
await interpretador.interfaceEntradaSaida.question('> ', (resposta: any) => {
respostas = String(resposta)
.split(',')
.filter((valor) => !/(\s+)/.test(valor));
});
break;
default:
valores = argumento.valor;
for (let i = 0; i < valores; i++) {
await interpretador.interfaceEntradaSaida.question('> ', (resposta: any) => {
respostas.push(resposta);
});
}

break;
}
}

for (let i = 0; i < valores; i++) {
await interpretador.interfaceEntradaSaida.question('> ', (resposta: any) => {
respostas.push(resposta);
});
}

return Promise.resolve(respostas);
}

Expand Down

0 comments on commit c4416a5

Please sign in to comment.