Skip to content

Commit

Permalink
Avisar sobre o Portugol no formato Algol
Browse files Browse the repository at this point in the history
  • Loading branch information
dgadelha committed Feb 18, 2024
1 parent d0d31c6 commit e3f5e1b
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions packages/runner/src/PortugolExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,38 @@ export class PortugolExecutor {
const errors = PortugolErrorChecker.checkTree(tree);

if (errors.length > 0) {
const argueAboutAlgolIfNeeded = () => {
if (
["fimalgoritmo", "fimenquanto", "fimpara", "fimse", "fimfuncao"].some(keyword => code.includes(keyword))
) {
this.stdOut += `\n`;
this.stdOut += `╔═════════════════════════════════════╗\n`;
this.stdOut += `║ ATENÇÃO ║\n`;
this.stdOut += `║ ║\n`;
this.stdOut += `║ Foi detectado que o seu código está ║\n`;
this.stdOut += `║ usando o Portugol no formato Algol. ║\n`;
this.stdOut += `║ O Portugol Webstudio dá suporte ao ║\n`;
this.stdOut += `║ Portugol no formato definido pela ║\n`;
this.stdOut += `║ UNIVALI. Por favor, leia mais sobre ║\n`;
this.stdOut += `║ na seção Ajuda. ║\n`;
this.stdOut += `╚═════════════════════════════════════╝\n\n`;
}
};

argueAboutAlgolIfNeeded();

this.stdOut += `⛔ O seu código possui ${errors.length} erro${errors.length > 1 ? "s" : ""} de compilação:\n`;
this.stdOut += errors
.map(error => ` - ${error.message} (linha ${error.startLine}, posição ${error.startCol})\n`)
.join("");

this.stdOut +=
"\n⚠️ Durante essa fase experimental, o código ainda será executado mesmo com erros, porém se não corrigi-los, a execução abaixo pode exibir mensagens de erro em inglês ou sem explicação.\n";
this.stdOut += ` Caso acredite que o erro não faça sentido, por favor, abra uma issue em https://github.com/dgadelha/Portugol-Webstudio/issues/new e anexe o código que você está tentando executar.\n`;
this.stdOut += "\n- O seu programa irá iniciar abaixo -\n";
this.stdOut += ` Caso acredite que o erro não faça sentido, por favor, abra uma issue em https://github.com/dgadelha/Portugol-Webstudio/issues/new e anexe o código que você está tentando executar.\n\n`;

argueAboutAlgolIfNeeded();

this.stdOut += "- O seu programa irá iniciar abaixo -\n";
this.stdOut$.next(this.stdOut);
}

Expand Down

0 comments on commit e3f5e1b

Please sign in to comment.