Skip to content

Commit

Permalink
Removendo código que re-instancia elementos de análise a cada execução.
Browse files Browse the repository at this point in the history
  • Loading branch information
leonelsanchesdasilva committed Jan 10, 2022
1 parent 2088f98 commit 8c2b06b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/delegua.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,39 +84,35 @@ export class Delegua {
this.teveErro = false;
this.teveErroEmTempoDeExecucao = false;

this.run(linha, interpretador);
this.run(linha);
leiaLinha.prompt();
});
}

carregarArquivo(nomeArquivo: any) {
this.nomeArquivo = caminho.basename(nomeArquivo);
const interpretador = new Interpretador(this, process.cwd());

const dadosDoArquivo = fs.readFileSync(nomeArquivo).toString();
this.run(dadosDoArquivo, interpretador);
this.run(dadosDoArquivo);

if (this.teveErro) process.exit(65);
if (this.teveErroEmTempoDeExecucao) process.exit(70);
}

run(codigo: any, interpretador: any) {
const lexer = new Lexer(this);
const simbolos = lexer.scan(codigo);
run(codigo: any) {
const simbolos = this.lexador.scan(codigo);

if (this.teveErro === true) return;

const analisar = new Parser(this);
const declaracoes = analisar.analisar(simbolos);
const declaracoes = this.avaliadorSintatico.analisar(simbolos);

if (this.teveErro === true) return;

const resolver = new Resolver(this, interpretador);
resolver.resolver(declaracoes);
this.resolvedor.resolver(declaracoes);

if (this.teveErro === true) return;

interpretador.interpretar(declaracoes);
this.interpretador.interpretar(declaracoes);
}

reportar(linha: any, onde: any, mensagem: any) {
Expand Down

0 comments on commit 8c2b06b

Please sign in to comment.