@designliquido/delegua 1.22.1 → 1.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analisador-semantico/analisador-semantico.js +12 -12
- package/analisador-semantico/analisador-semantico.js.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.d.ts +0 -1
- package/avaliador-sintatico/avaliador-sintatico.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.js +1 -7
- package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts +0 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +22 -26
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-tenda.d.ts +0 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-tenda.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-tenda.js +0 -4
- package/avaliador-sintatico/dialetos/avaliador-sintatico-tenda.js.map +1 -1
- package/bibliotecas/testes/modulo-afirmar.d.ts.map +1 -1
- package/bibliotecas/testes/modulo-afirmar.js +5 -0
- package/bibliotecas/testes/modulo-afirmar.js.map +1 -1
- package/bin/package.json +1 -1
- package/declaracoes/bloco.d.ts.map +1 -1
- package/declaracoes/bloco.js +0 -2
- package/declaracoes/bloco.js.map +1 -1
- package/declaracoes/const-multiplo.js +2 -2
- package/declaracoes/const-multiplo.js.map +1 -1
- package/declaracoes/enquanto.d.ts.map +1 -1
- package/declaracoes/enquanto.js +1 -2
- package/declaracoes/enquanto.js.map +1 -1
- package/declaracoes/escolha.d.ts.map +1 -1
- package/declaracoes/escolha.js +9 -2
- package/declaracoes/escolha.js.map +1 -1
- package/declaracoes/fazer.d.ts.map +1 -1
- package/declaracoes/fazer.js +1 -2
- package/declaracoes/fazer.js.map +1 -1
- package/declaracoes/funcao.d.ts.map +1 -1
- package/declaracoes/funcao.js +1 -2
- package/declaracoes/funcao.js.map +1 -1
- package/declaracoes/inicio-algoritmo.d.ts +4 -0
- package/declaracoes/inicio-algoritmo.d.ts.map +1 -1
- package/declaracoes/inicio-algoritmo.js +4 -2
- package/declaracoes/inicio-algoritmo.js.map +1 -1
- package/declaracoes/para-cada.d.ts.map +1 -1
- package/declaracoes/para-cada.js +1 -2
- package/declaracoes/para-cada.js.map +1 -1
- package/declaracoes/para.d.ts.map +1 -1
- package/declaracoes/para.js +3 -4
- package/declaracoes/para.js.map +1 -1
- package/declaracoes/se.d.ts.map +1 -1
- package/declaracoes/se.js +10 -2
- package/declaracoes/se.js.map +1 -1
- package/declaracoes/tendo-como.d.ts.map +1 -1
- package/declaracoes/tendo-como.js +1 -2
- package/declaracoes/tendo-como.js.map +1 -1
- package/declaracoes/tente.d.ts.map +1 -1
- package/declaracoes/tente.js +7 -2
- package/declaracoes/tente.js.map +1 -1
- package/declaracoes/var-multiplo.js +2 -2
- package/declaracoes/var-multiplo.js.map +1 -1
- package/inferenciador.d.ts.map +1 -1
- package/inferenciador.js +5 -3
- package/inferenciador.js.map +1 -1
- package/interfaces/primitiva-interface.d.ts.map +1 -1
- package/interfaces/variavel-interface.d.ts.map +1 -1
- package/interpretador/estruturas/delegua-funcao.d.ts.map +1 -1
- package/interpretador/estruturas/delegua-funcao.js +0 -2
- package/interpretador/estruturas/delegua-funcao.js.map +1 -1
- package/interpretador/interpretador-base.d.ts.map +1 -1
- package/interpretador/interpretador-base.js +34 -22
- package/interpretador/interpretador-base.js.map +1 -1
- package/interpretador/pilha-escopos-execucao.d.ts.map +1 -1
- package/interpretador/pilha-escopos-execucao.js +20 -10
- package/interpretador/pilha-escopos-execucao.js.map +1 -1
- package/package.json +1 -1
- package/umd/delegua.js +141 -114
package/umd/delegua.js
CHANGED
|
@@ -626,19 +626,19 @@ class AnalisadorSemantico extends analisador_semantico_base_1.AnalisadorSemantic
|
|
|
626
626
|
this.erro(simboloFuncao, `Função '${simboloFuncao.lexema}' espera ${parametros.length} parâmetros. Atual: ${argumentos.length}.`);
|
|
627
627
|
}
|
|
628
628
|
for (let [indice, parametro] of parametros.entries()) {
|
|
629
|
-
// TODO: `argumento` pode ser Literal (tipo já resolvido) ou variável (tipo inferido em outra etapa).
|
|
630
629
|
const argumento = argumentos[indice];
|
|
631
|
-
if (argumento)
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
630
|
+
if (!argumento)
|
|
631
|
+
continue;
|
|
632
|
+
const tipoArgumento = argumento.tipo ?? 'qualquer';
|
|
633
|
+
if (tipoArgumento === 'qualquer')
|
|
634
|
+
continue;
|
|
635
|
+
if (parametro.tipoDado === 'texto' && tipoArgumento !== 'texto') {
|
|
636
|
+
this.erro(simboloFuncao, `O valor passado para o parâmetro '${parametro.nome.lexema}' (${parametro.tipoDado}) é diferente do esperado pela função (${tipoArgumento}).`);
|
|
637
|
+
}
|
|
638
|
+
else if (['inteiro', 'número', 'real'].includes(parametro.tipoDado)) {
|
|
639
|
+
// Delégua pode trabalhar com conversões implícitas entre tipos numéricos.
|
|
640
|
+
if (!['inteiro', 'número', 'real'].includes(tipoArgumento)) {
|
|
641
|
+
this.erro(simboloFuncao, `O valor passado para o parâmetro '${parametro.nome.lexema}' (${parametro.tipoDado}) é diferente do esperado pela função (${tipoArgumento}).`);
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
644
|
}
|
|
@@ -2836,8 +2836,7 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
2836
2836
|
// Esta indicação é utilizada para compreensões de lista, onde o
|
|
2837
2837
|
// tipo do identificador de iteração é 'qualquer' por definição.
|
|
2838
2838
|
tipoOperando = 'qualquer';
|
|
2839
|
-
this.pilhaEscopos.definirInformacoesVariavel(simboloIdentificador.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(simboloIdentificador.lexema, 'qualquer')
|
|
2840
|
-
);
|
|
2839
|
+
this.pilhaEscopos.definirInformacoesVariavel(simboloIdentificador.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(simboloIdentificador.lexema, 'qualquer'));
|
|
2841
2840
|
}
|
|
2842
2841
|
else if (simboloIdentificador.lexema in this.tiposDefinidosEmCodigo) {
|
|
2843
2842
|
tipoOperando = simboloIdentificador.lexema;
|
|
@@ -3626,10 +3625,6 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
3626
3625
|
this.consumir(delegua_2.default.PARENTESE_DIREITO, "Esperado ')' após os argumentos em instrução `leia`.");
|
|
3627
3626
|
return new construtos_1.Leia(simboloLeia, argumentos);
|
|
3628
3627
|
}
|
|
3629
|
-
// TODO: Depreciar.
|
|
3630
|
-
async expressao() {
|
|
3631
|
-
return await this.atribuir();
|
|
3632
|
-
}
|
|
3633
3628
|
async blocoEscopo() {
|
|
3634
3629
|
this.pilhaEscopos.empilhar(new informacao_escopo_1.InformacaoEscopo());
|
|
3635
3630
|
let declaracoes = [];
|
|
@@ -4384,7 +4379,6 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
4384
4379
|
const inicializador = await this.expressao();
|
|
4385
4380
|
const retornos = [];
|
|
4386
4381
|
for (let identificador of identificadores) {
|
|
4387
|
-
// TODO: Melhorar dicionário para intuir o tipo de cada propriedade.
|
|
4388
4382
|
this.pilhaEscopos.definirInformacoesVariavel(identificador.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(identificador.lexema, 'qualquer'));
|
|
4389
4383
|
const declaracaoConst = new declaracoes_1.Const(identificador, new construtos_1.AcessoMetodoOuPropriedade(this.hashArquivo, inicializador, identificador));
|
|
4390
4384
|
declaracaoConst.decoradores = Array.from(this.pilhaDecoradores);
|
|
@@ -6432,7 +6426,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
6432
6426
|
this.consumir(pitugues_2.default.PARENTESE_ESQUERDO, "Esperado '(' antes dos valores em leia.");
|
|
6433
6427
|
const argumentos = [];
|
|
6434
6428
|
do {
|
|
6435
|
-
argumentos.push(await this.
|
|
6429
|
+
argumentos.push(await this.atribuir());
|
|
6436
6430
|
} while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA));
|
|
6437
6431
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após os valores em leia.");
|
|
6438
6432
|
return new construtos_1.Leia(simboloLeia, argumentos);
|
|
@@ -6462,7 +6456,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
6462
6456
|
if (this.estaNoFinal()) {
|
|
6463
6457
|
throw this.erro(this.simboloAnterior(), 'Esperado valor após o símbolo de igual.');
|
|
6464
6458
|
}
|
|
6465
|
-
const valor = await this.
|
|
6459
|
+
const valor = await this.atribuir();
|
|
6466
6460
|
if (!tipoExplicito) {
|
|
6467
6461
|
tipo = this.logicaComumInferenciaTiposVariaveisEConstantes(valor, 'qualquer');
|
|
6468
6462
|
}
|
|
@@ -6561,7 +6555,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
6561
6555
|
if (this.estaNoFinal()) {
|
|
6562
6556
|
throw this.erro(this.simboloAtual(), 'Esperado inicializador após vírgula.');
|
|
6563
6557
|
}
|
|
6564
|
-
inicializadores.push(await this.
|
|
6558
|
+
inicializadores.push(await this.atribuir());
|
|
6565
6559
|
} while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA));
|
|
6566
6560
|
return inicializadores;
|
|
6567
6561
|
}
|
|
@@ -6834,7 +6828,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
6834
6828
|
case pitugues_2.default.TIPO:
|
|
6835
6829
|
const simboloTipo = this.avancarEDevolverAnterior();
|
|
6836
6830
|
this.consumir(pitugues_2.default.PARENTESE_ESQUERDO, "Esperado '(' após 'tipo'.");
|
|
6837
|
-
const expressaoAvaliar = await this.
|
|
6831
|
+
const expressaoAvaliar = await this.atribuir();
|
|
6838
6832
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após expressão em 'tipo'.");
|
|
6839
6833
|
return new construtos_1.TipoDe(simboloTipo.hashArquivo, simboloTipo, expressaoAvaliar);
|
|
6840
6834
|
case pitugues_2.default.IDENTIFICADOR:
|
|
@@ -6910,7 +6904,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
6910
6904
|
if (argumentos.length >= 255) {
|
|
6911
6905
|
throw this.erro(this.simboloAtual(), 'Não pode haver mais de 255 argumentos.');
|
|
6912
6906
|
}
|
|
6913
|
-
argumentos.push(await this.
|
|
6907
|
+
argumentos.push(await this.atribuir());
|
|
6914
6908
|
} while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA));
|
|
6915
6909
|
}
|
|
6916
6910
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após os argumentos.");
|
|
@@ -6930,7 +6924,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
6930
6924
|
}
|
|
6931
6925
|
else if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.COLCHETE_ESQUERDO)) {
|
|
6932
6926
|
const inicio = !this.verificarTipoSimboloAtual(pitugues_2.default.DOIS_PONTOS)
|
|
6933
|
-
? await this.
|
|
6927
|
+
? await this.atribuir()
|
|
6934
6928
|
: null;
|
|
6935
6929
|
let ehFatiamento = false;
|
|
6936
6930
|
let fim = null;
|
|
@@ -6939,10 +6933,10 @@ class AvaliadorSintaticoPitugues {
|
|
|
6939
6933
|
ehFatiamento = true;
|
|
6940
6934
|
if (!this.verificarTipoSimboloAtual(pitugues_2.default.DOIS_PONTOS) &&
|
|
6941
6935
|
!this.verificarTipoSimboloAtual(pitugues_2.default.COLCHETE_DIREITO))
|
|
6942
|
-
fim = await this.
|
|
6936
|
+
fim = await this.atribuir();
|
|
6943
6937
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.DOIS_PONTOS) &&
|
|
6944
6938
|
!this.verificarTipoSimboloAtual(pitugues_2.default.COLCHETE_DIREITO))
|
|
6945
|
-
passo = await this.
|
|
6939
|
+
passo = await this.atribuir();
|
|
6946
6940
|
}
|
|
6947
6941
|
const simboloFechamento = this.consumir(pitugues_2.default.COLCHETE_DIREITO, "Esperado ']' após escrita do indice.");
|
|
6948
6942
|
if (ehFatiamento) {
|
|
@@ -7176,15 +7170,11 @@ class AvaliadorSintaticoPitugues {
|
|
|
7176
7170
|
}
|
|
7177
7171
|
return expressao;
|
|
7178
7172
|
}
|
|
7179
|
-
// TODO: Depreciar.
|
|
7180
|
-
async expressao() {
|
|
7181
|
-
return await this.atribuir();
|
|
7182
|
-
}
|
|
7183
7173
|
async declaracaoEscreva(simboloEscreva) {
|
|
7184
7174
|
this.consumir(pitugues_2.default.PARENTESE_ESQUERDO, "Esperado '(' antes dos valores em escreva.");
|
|
7185
7175
|
const argumentos = [];
|
|
7186
7176
|
do {
|
|
7187
|
-
argumentos.push(await this.
|
|
7177
|
+
argumentos.push(await this.atribuir());
|
|
7188
7178
|
} while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VIRGULA));
|
|
7189
7179
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após os valores em escreva.");
|
|
7190
7180
|
const declaracaoEscreva = new declaracoes_1.Escreva(Number(simboloEscreva.linha), simboloEscreva.hashArquivo, argumentos);
|
|
@@ -7192,7 +7182,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
7192
7182
|
return declaracaoEscreva;
|
|
7193
7183
|
}
|
|
7194
7184
|
async declaracaoExpressao() {
|
|
7195
|
-
const expressao = await this.
|
|
7185
|
+
const expressao = await this.atribuir();
|
|
7196
7186
|
return new declaracoes_1.Expressao(expressao);
|
|
7197
7187
|
}
|
|
7198
7188
|
async blocoEscopo() {
|
|
@@ -7236,7 +7226,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
7236
7226
|
async declaracaoEnquanto() {
|
|
7237
7227
|
try {
|
|
7238
7228
|
this.blocos += 1;
|
|
7239
|
-
const condicao = await this.
|
|
7229
|
+
const condicao = await this.atribuir();
|
|
7240
7230
|
const bloco = (await this.resolverDeclaracao());
|
|
7241
7231
|
return new declaracoes_1.Enquanto(condicao, bloco);
|
|
7242
7232
|
}
|
|
@@ -7247,18 +7237,18 @@ class AvaliadorSintaticoPitugues {
|
|
|
7247
7237
|
async declaracaoEscolha() {
|
|
7248
7238
|
try {
|
|
7249
7239
|
this.blocos += 1;
|
|
7250
|
-
const condicao = await this.
|
|
7240
|
+
const condicao = await this.atribuir();
|
|
7251
7241
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após 'escolha'.");
|
|
7252
7242
|
const caminhos = [];
|
|
7253
7243
|
let caminhoPadrao = null;
|
|
7254
7244
|
while (!this.estaNoFinal() &&
|
|
7255
7245
|
[pitugues_2.default.CASO, pitugues_2.default.PADRAO].includes(this.simbolos[this.atual].tipo)) {
|
|
7256
7246
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.CASO)) {
|
|
7257
|
-
const caminhoCondicoes = [await this.
|
|
7247
|
+
const caminhoCondicoes = [await this.atribuir()];
|
|
7258
7248
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após o 'caso'.");
|
|
7259
7249
|
while (this.verificarTipoSimboloAtual(pitugues_2.default.CASO)) {
|
|
7260
7250
|
this.consumir(pitugues_2.default.CASO, null);
|
|
7261
|
-
caminhoCondicoes.push(await this.
|
|
7251
|
+
caminhoCondicoes.push(await this.atribuir());
|
|
7262
7252
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após declaração do 'caso'.");
|
|
7263
7253
|
}
|
|
7264
7254
|
// Como dois-pontos é um símbolo usado para conferir se há um início de bloco,
|
|
@@ -7301,7 +7291,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
7301
7291
|
if (!this.verificarSeSimboloAtualEIgualA(pitugues_2.default.DE, pitugues_2.default.EM)) {
|
|
7302
7292
|
throw this.erro(this.simbolos[this.atual], "Esperado palavras reservadas 'em' ou 'de' após variável de iteração em instrução 'para cada'.");
|
|
7303
7293
|
}
|
|
7304
|
-
const vetor = await this.
|
|
7294
|
+
const vetor = await this.atribuir();
|
|
7305
7295
|
if (!vetor.hasOwnProperty('tipo')) {
|
|
7306
7296
|
throw this.erro(simboloPara, `Variável ou constante em 'para cada' não parece possuir um tipo iterável.`);
|
|
7307
7297
|
}
|
|
@@ -7336,7 +7326,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
7336
7326
|
if (!this.verificarSeSimboloAtualEIgualA(pitugues_2.default.DE, pitugues_2.default.EM)) {
|
|
7337
7327
|
throw this.erro(this.simbolos[this.atual], "Esperado palavras reservadas 'em' ou 'de' após variável de iteração em instrução 'para cada'.");
|
|
7338
7328
|
}
|
|
7339
|
-
const alvoIteracao = await this.
|
|
7329
|
+
const alvoIteracao = await this.atribuir();
|
|
7340
7330
|
this.validarSeAlvoEIteravel(simboloPara, alvoIteracao, !!simboloSegundaVariavel);
|
|
7341
7331
|
this.pilhaEscopos.definirInformacoesVariavel(primeiraVariavel.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(primeiraVariavel.lexema, 'qualquer'));
|
|
7342
7332
|
if (simboloSegundaVariavel) {
|
|
@@ -7371,7 +7361,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
7371
7361
|
}
|
|
7372
7362
|
}
|
|
7373
7363
|
async declaracaoSe() {
|
|
7374
|
-
const condicao = await this.
|
|
7364
|
+
const condicao = await this.atribuir();
|
|
7375
7365
|
this.consumir(pitugues_2.default.DOIS_PONTOS, "Esperado ':' após condição do 'se'.");
|
|
7376
7366
|
const simboloColonEntao = this.simboloAnterior();
|
|
7377
7367
|
const caminhoEntao = new declaracoes_1.Bloco(simboloColonEntao.hashArquivo, Number(simboloColonEntao.linha), await this.blocoEscopo());
|
|
@@ -7438,14 +7428,14 @@ class AvaliadorSintaticoPitugues {
|
|
|
7438
7428
|
const palavraChave = this.simboloAnterior();
|
|
7439
7429
|
let valor = null;
|
|
7440
7430
|
if (!this.verificarTipoSimboloAtual(pitugues_2.default.PONTO_E_VIRGULA)) {
|
|
7441
|
-
valor = await this.
|
|
7431
|
+
valor = await this.atribuir();
|
|
7442
7432
|
}
|
|
7443
7433
|
return new declaracoes_1.Retorna(palavraChave, valor);
|
|
7444
7434
|
}
|
|
7445
7435
|
async construtoImportar() {
|
|
7446
7436
|
this.avancarEDevolverAnterior();
|
|
7447
7437
|
this.consumir(pitugues_2.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração.");
|
|
7448
|
-
const caminho = await this.
|
|
7438
|
+
const caminho = await this.atribuir();
|
|
7449
7439
|
this.consumir(pitugues_2.default.PARENTESE_DIREITO, "Esperado ')' após declaração.");
|
|
7450
7440
|
return new construtos_1.ImportarComoConstruto(caminho);
|
|
7451
7441
|
}
|
|
@@ -7522,7 +7512,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
7522
7512
|
this.blocos += 1;
|
|
7523
7513
|
const declaracaoOuBlocoFazer = (await this.resolverDeclaracao());
|
|
7524
7514
|
this.consumir(pitugues_2.default.ENQUANTO, "Esperado declaração do 'enquanto' após o escopo da declaração 'fazer'.");
|
|
7525
|
-
const condicaoEnquanto = await this.
|
|
7515
|
+
const condicaoEnquanto = await this.atribuir();
|
|
7526
7516
|
return new declaracoes_1.Fazer(simboloFazer.hashArquivo, Number(simboloFazer.linha), declaracaoOuBlocoFazer, condicaoEnquanto);
|
|
7527
7517
|
}
|
|
7528
7518
|
finally {
|
|
@@ -7598,7 +7588,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
7598
7588
|
// TODO: Reavaliar a precedência do se ternário.
|
|
7599
7589
|
const vetor = await this.ou();
|
|
7600
7590
|
this.consumir(pitugues_2.default.SE, "Esperado condição 'se' após vetor.");
|
|
7601
|
-
const condicao = await this.
|
|
7591
|
+
const condicao = await this.atribuir();
|
|
7602
7592
|
this.consumir(pitugues_2.default.COLCHETE_DIREITO, 'Espero fechamento de colchetes após condição.');
|
|
7603
7593
|
const tipoVetor = vetor.tipo;
|
|
7604
7594
|
if (!tipoVetor.endsWith('[]') && !['qualquer', 'vetor'].includes(tipoVetor)) {
|
|
@@ -7708,7 +7698,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
7708
7698
|
tipoLexema = simboloTipo.lexema;
|
|
7709
7699
|
}
|
|
7710
7700
|
else if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.IGUAL)) {
|
|
7711
|
-
valorPropriedade = await this.
|
|
7701
|
+
valorPropriedade = await this.atribuir();
|
|
7712
7702
|
possuiValorInicial = true;
|
|
7713
7703
|
}
|
|
7714
7704
|
else {
|
|
@@ -10186,10 +10176,6 @@ class AvaliadorSintaticoTenda extends avaliador_sintatico_base_1.AvaliadorSintat
|
|
|
10186
10176
|
this.consumir(tenda_1.default.PARENTESE_DIREITO, "Esperado ')' após os argumentos em instrução `leia`.");
|
|
10187
10177
|
return new construtos_1.Leia(simboloLeia, argumentos);
|
|
10188
10178
|
}
|
|
10189
|
-
// TODO: Depreciar.
|
|
10190
|
-
async expressao() {
|
|
10191
|
-
return await this.atribuir();
|
|
10192
|
-
}
|
|
10193
10179
|
async blocoEscopo(tipo) {
|
|
10194
10180
|
this.pilhaEscopos.empilhar(new informacao_escopo_1.InformacaoEscopo());
|
|
10195
10181
|
let declaracoes = [];
|
|
@@ -13742,12 +13728,17 @@ function construirModuloAfirmar() {
|
|
|
13742
13728
|
modulo.componentes['erro'] = new funcao_padrao_1.FuncaoPadrao(1, async function (interpretador, funcaoTestada) {
|
|
13743
13729
|
const funcao = interpretador.resolverValor(funcaoTestada);
|
|
13744
13730
|
let erroLancado = false;
|
|
13731
|
+
const errosAntes = interpretador.erros.length;
|
|
13745
13732
|
try {
|
|
13746
13733
|
await funcao.chamar(interpretador, [], null);
|
|
13747
13734
|
}
|
|
13748
13735
|
catch (_) {
|
|
13749
13736
|
erroLancado = true;
|
|
13750
13737
|
}
|
|
13738
|
+
if (!erroLancado && interpretador.erros.length > errosAntes) {
|
|
13739
|
+
erroLancado = true;
|
|
13740
|
+
interpretador.erros.splice(errosAntes);
|
|
13741
|
+
}
|
|
13751
13742
|
if (!erroLancado) {
|
|
13752
13743
|
return Promise.reject(new erro_de_assertiva_1.ErroDeAssertiva(simboloAtual(interpretador), 'Esperava que a função lançasse um erro, mas ela completou sem erros.'));
|
|
13753
13744
|
}
|
|
@@ -15673,8 +15664,6 @@ exports.Ajuda = Ajuda;
|
|
|
15673
15664
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15674
15665
|
exports.Bloco = void 0;
|
|
15675
15666
|
const declaracao_1 = require("./declaracao");
|
|
15676
|
-
// TODO: `Bloco` só deveria ser declaração quando representa um escopo órfão.
|
|
15677
|
-
// Estudar transformar em construto e suas implicações.
|
|
15678
15667
|
class Bloco extends declaracao_1.Declaracao {
|
|
15679
15668
|
constructor(hashArquivo, linha, declaracoes) {
|
|
15680
15669
|
super(linha, hashArquivo);
|
|
@@ -15807,8 +15796,8 @@ class ConstMultiplo extends declaracao_1.Declaracao {
|
|
|
15807
15796
|
return await visitante.visitarDeclaracaoConstMultiplo(this);
|
|
15808
15797
|
}
|
|
15809
15798
|
paraTexto() {
|
|
15810
|
-
|
|
15811
|
-
return `<const-múltiplo />`;
|
|
15799
|
+
const nomes = this.simbolos.map((s) => s.lexema).join(',');
|
|
15800
|
+
return `<const-múltiplo nomes=[${nomes}] inicializador=${this.inicializador.paraTexto()} tipo=${this.tipo ?? 'qualquer'} />`;
|
|
15812
15801
|
}
|
|
15813
15802
|
}
|
|
15814
15803
|
exports.ConstMultiplo = ConstMultiplo;
|
|
@@ -15899,8 +15888,7 @@ class Enquanto extends declaracao_1.Declaracao {
|
|
|
15899
15888
|
return await visitante.visitarDeclaracaoEnquanto(this);
|
|
15900
15889
|
}
|
|
15901
15890
|
paraTexto() {
|
|
15902
|
-
|
|
15903
|
-
return `<enquanto condição=${this.condicao.paraTexto()} />`;
|
|
15891
|
+
return `<enquanto condição=${this.condicao.paraTexto()}>${this.corpo.paraTexto()}</enquanto>`;
|
|
15904
15892
|
}
|
|
15905
15893
|
}
|
|
15906
15894
|
exports.Enquanto = Enquanto;
|
|
@@ -15924,8 +15912,15 @@ class Escolha extends declaracao_1.Declaracao {
|
|
|
15924
15912
|
return await visitante.visitarDeclaracaoEscolha(this);
|
|
15925
15913
|
}
|
|
15926
15914
|
paraTexto() {
|
|
15927
|
-
|
|
15928
|
-
|
|
15915
|
+
const caminhos = this.caminhos
|
|
15916
|
+
.map((c) => {
|
|
15917
|
+
const condicoes = c.condicoes.map((cond) => cond.paraTexto()).join(',');
|
|
15918
|
+
const declaracoes = c.declaracoes.map((d) => d.paraTexto()).join('');
|
|
15919
|
+
return `<caminho condicoes=[${condicoes}]>${declaracoes}</caminho>`;
|
|
15920
|
+
})
|
|
15921
|
+
.join('');
|
|
15922
|
+
const padrao = this.caminhoPadrao?.declaracoes.map((d) => d.paraTexto()).join('') ?? '';
|
|
15923
|
+
return `<escolha identificadorOuLiteral=${this.identificadorOuLiteral.paraTexto()}>${caminhos}<padrão>${padrao}</padrão></escolha>`;
|
|
15929
15924
|
}
|
|
15930
15925
|
}
|
|
15931
15926
|
exports.Escolha = Escolha;
|
|
@@ -16052,8 +16047,7 @@ class Fazer extends declaracao_1.Declaracao {
|
|
|
16052
16047
|
return await visitante.visitarDeclaracaoFazer(this);
|
|
16053
16048
|
}
|
|
16054
16049
|
paraTexto() {
|
|
16055
|
-
|
|
16056
|
-
return `<fazer condição=${this.condicaoEnquanto.paraTexto()} />`;
|
|
16050
|
+
return `<fazer>${this.caminhoFazer.paraTexto()}<condição>${this.condicaoEnquanto.paraTexto()}</condição></fazer>`;
|
|
16057
16051
|
}
|
|
16058
16052
|
}
|
|
16059
16053
|
exports.Fazer = Fazer;
|
|
@@ -16086,8 +16080,7 @@ class FuncaoDeclaracao extends declaracao_1.Declaracao {
|
|
|
16086
16080
|
return await visitante.visitarDeclaracaoDefinicaoFuncao(this);
|
|
16087
16081
|
}
|
|
16088
16082
|
paraTexto() {
|
|
16089
|
-
|
|
16090
|
-
return `<declaração-função nome=${this.simbolo.lexema} tipo=${this.tipo} />`;
|
|
16083
|
+
return `<declaração-função nome=${this.simbolo.lexema} tipo=${this.tipo}>${this.funcao.paraTexto()}</declaração-função>`;
|
|
16091
16084
|
}
|
|
16092
16085
|
}
|
|
16093
16086
|
exports.FuncaoDeclaracao = FuncaoDeclaracao;
|
|
@@ -16174,8 +16167,10 @@ __exportStar(require("./var-multiplo"), exports);
|
|
|
16174
16167
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16175
16168
|
exports.InicioAlgoritmo = void 0;
|
|
16176
16169
|
const declaracao_1 = require("./declaracao");
|
|
16177
|
-
|
|
16178
|
-
|
|
16170
|
+
/**
|
|
16171
|
+
* Representa a declaração de início do algoritmo, que é o ponto de entrada do programa.
|
|
16172
|
+
* Usado por dialetos como Portugol Studio, Portugol IPT e VisusAlg.
|
|
16173
|
+
*/
|
|
16179
16174
|
class InicioAlgoritmo extends declaracao_1.Declaracao {
|
|
16180
16175
|
constructor(linha, hashArquivo) {
|
|
16181
16176
|
super(linha, hashArquivo);
|
|
@@ -16252,8 +16247,7 @@ class ParaCada extends declaracao_1.Declaracao {
|
|
|
16252
16247
|
return await visitante.visitarDeclaracaoParaCada(this);
|
|
16253
16248
|
}
|
|
16254
16249
|
paraTexto() {
|
|
16255
|
-
|
|
16256
|
-
return `<para-cada variávelIteração=${this.variavelIteracao.paraTexto()} />`;
|
|
16250
|
+
return `<para-cada variávelIteração=${this.variavelIteracao.paraTexto()} vetor=${this.vetorOuDicionario.paraTexto()}>${this.corpo.paraTexto()}</para-cada>`;
|
|
16257
16251
|
}
|
|
16258
16252
|
}
|
|
16259
16253
|
exports.ParaCada = ParaCada;
|
|
@@ -16284,13 +16278,12 @@ class Para extends declaracao_1.Declaracao {
|
|
|
16284
16278
|
paraTexto() {
|
|
16285
16279
|
let inicializador = '';
|
|
16286
16280
|
if (Array.isArray(this.inicializador)) {
|
|
16287
|
-
inicializador = this.inicializador.
|
|
16281
|
+
inicializador = this.inicializador.map((d) => d.paraTexto()).join(' ');
|
|
16288
16282
|
}
|
|
16289
16283
|
else if (this.inicializador) {
|
|
16290
|
-
inicializador =
|
|
16284
|
+
inicializador = this.inicializador.paraTexto();
|
|
16291
16285
|
}
|
|
16292
|
-
|
|
16293
|
-
return `<para ${this.inicializador} condição=${this.condicao.paraTexto()} />`;
|
|
16286
|
+
return `<para inicializador=[${inicializador}] condição=${this.condicao.paraTexto()} incremento=${this.incrementar.paraTexto()}>${this.corpo.paraTexto()}</para>`;
|
|
16294
16287
|
}
|
|
16295
16288
|
}
|
|
16296
16289
|
exports.Para = Para;
|
|
@@ -16364,8 +16357,16 @@ class Se extends declaracao_1.Declaracao {
|
|
|
16364
16357
|
return await visitante.visitarDeclaracaoSe(this);
|
|
16365
16358
|
}
|
|
16366
16359
|
paraTexto() {
|
|
16367
|
-
|
|
16368
|
-
|
|
16360
|
+
let resultado = `<se condicao=${this.condicao.paraTexto()}><então>${this.caminhoEntao.paraTexto()}</então>`;
|
|
16361
|
+
if (this.caminhosSeSenao) {
|
|
16362
|
+
for (const seSenao of this.caminhosSeSenao) {
|
|
16363
|
+
resultado += `<senão-se condicao=${seSenao.condicao.paraTexto()}>${seSenao.caminho.paraTexto()}</senão-se>`;
|
|
16364
|
+
}
|
|
16365
|
+
}
|
|
16366
|
+
if (this.caminhoSenao) {
|
|
16367
|
+
resultado += `<senão>${this.caminhoSenao.paraTexto()}</senão>`;
|
|
16368
|
+
}
|
|
16369
|
+
return resultado + '</se>';
|
|
16369
16370
|
}
|
|
16370
16371
|
}
|
|
16371
16372
|
exports.Se = Se;
|
|
@@ -16409,8 +16410,7 @@ class TendoComo extends declaracao_1.Declaracao {
|
|
|
16409
16410
|
return await visitante.visitarDeclaracaoTendoComo(this);
|
|
16410
16411
|
}
|
|
16411
16412
|
paraTexto() {
|
|
16412
|
-
|
|
16413
|
-
return `<tendo variável=${this.simboloVariavel.lexema} como=${this.inicializacaoVariavel.paraTexto()} />`;
|
|
16413
|
+
return `<tendo variável=${this.simboloVariavel.lexema} como=${this.inicializacaoVariavel.paraTexto()}>${this.corpo.paraTexto()}</tendo>`;
|
|
16414
16414
|
}
|
|
16415
16415
|
}
|
|
16416
16416
|
exports.TendoComo = TendoComo;
|
|
@@ -16435,8 +16435,13 @@ class Tente extends declaracao_1.Declaracao {
|
|
|
16435
16435
|
return await visitante.visitarDeclaracaoTente(this);
|
|
16436
16436
|
}
|
|
16437
16437
|
paraTexto() {
|
|
16438
|
-
|
|
16439
|
-
|
|
16438
|
+
const tente = this.caminhoTente.map((d) => d.paraTexto()).join('');
|
|
16439
|
+
const pegue = Array.isArray(this.caminhoPegue)
|
|
16440
|
+
? this.caminhoPegue.map((d) => d.paraTexto()).join('')
|
|
16441
|
+
: this.caminhoPegue.paraTexto();
|
|
16442
|
+
const senao = this.caminhoSenao.map((d) => d.paraTexto()).join('');
|
|
16443
|
+
const finalmente = this.caminhoFinalmente.map((d) => d.paraTexto()).join('');
|
|
16444
|
+
return `<tente><tente-corpo>${tente}</tente-corpo><pegue>${pegue}</pegue><senão>${senao}</senão><finalmente>${finalmente}</finalmente></tente>`;
|
|
16440
16445
|
}
|
|
16441
16446
|
}
|
|
16442
16447
|
exports.Tente = Tente;
|
|
@@ -16483,8 +16488,8 @@ class VarMultiplo extends declaracao_1.Declaracao {
|
|
|
16483
16488
|
return await visitante.visitarDeclaracaoVarMultiplo(this);
|
|
16484
16489
|
}
|
|
16485
16490
|
paraTexto() {
|
|
16486
|
-
|
|
16487
|
-
return `<var-múltiplo />`;
|
|
16491
|
+
const nomes = this.simbolos.map((s) => s.lexema).join(',');
|
|
16492
|
+
return `<var-múltiplo nomes=[${nomes}] inicializador=${this.inicializador.paraTexto()} tipo=${this.tipo ?? 'qualquer'} />`;
|
|
16488
16493
|
}
|
|
16489
16494
|
}
|
|
16490
16495
|
exports.VarMultiplo = VarMultiplo;
|
|
@@ -19036,8 +19041,10 @@ function inferirVetor(vetor) {
|
|
|
19036
19041
|
}
|
|
19037
19042
|
return `${tiposObjetosEmVetor.values().next().value}[]`;
|
|
19038
19043
|
case 'Literal':
|
|
19039
|
-
|
|
19040
|
-
|
|
19044
|
+
const tiposLiterais = new Set(vetor.map((e) => e.tipo));
|
|
19045
|
+
if (tiposLiterais.size > 1)
|
|
19046
|
+
return 'vetor';
|
|
19047
|
+
return `${tiposLiterais.values().next().value}[]`;
|
|
19041
19048
|
default:
|
|
19042
19049
|
return 'vetor';
|
|
19043
19050
|
}
|
|
@@ -19078,7 +19085,7 @@ function inferirTipoVariavel(variavel) {
|
|
|
19078
19085
|
case 'DescritorTipoClasse':
|
|
19079
19086
|
case 'ObjetoDeleguaClasse':
|
|
19080
19087
|
return 'objeto';
|
|
19081
|
-
case 'Simbolo':
|
|
19088
|
+
case 'Simbolo':
|
|
19082
19089
|
const simbolo = variavel;
|
|
19083
19090
|
switch (simbolo.tipo) {
|
|
19084
19091
|
case primitivos_1.default.BOOLEANO:
|
|
@@ -20408,8 +20415,6 @@ class DeleguaFuncao extends chamavel_1.Chamavel {
|
|
|
20408
20415
|
};
|
|
20409
20416
|
}
|
|
20410
20417
|
}
|
|
20411
|
-
// TODO: Repensar essa dinâmica para análise semântica (levar toda a lógica abaixo para
|
|
20412
|
-
// o interpretador).
|
|
20413
20418
|
const interpretador = visitante;
|
|
20414
20419
|
interpretador.proximoEscopo = 'funcao';
|
|
20415
20420
|
// Rastrear a classe atual em execução para verificação de acesso.
|
|
@@ -21828,12 +21833,11 @@ class InterpretadorBase {
|
|
|
21828
21833
|
retirarInterpolacao(texto, interpolacoes) {
|
|
21829
21834
|
let textoFinal = texto;
|
|
21830
21835
|
for (const elemento of interpolacoes) {
|
|
21831
|
-
|
|
21832
|
-
|
|
21833
|
-
if (valor.hasOwnProperty && valor.hasOwnProperty('valorRetornado')) {
|
|
21836
|
+
let valor = elemento.valor;
|
|
21837
|
+
if (valor?.hasOwnProperty && valor.hasOwnProperty('valorRetornado')) {
|
|
21834
21838
|
valor = valor.valorRetornado;
|
|
21835
21839
|
}
|
|
21836
|
-
if (valor
|
|
21840
|
+
if (valor?.tipo === delegua_2.default.LOGICO) {
|
|
21837
21841
|
textoFinal = textoFinal.replace('${' + elemento.expressaoInterpolacao + '}', this.paraTexto(valor));
|
|
21838
21842
|
}
|
|
21839
21843
|
else {
|
|
@@ -21962,9 +21966,9 @@ class InterpretadorBase {
|
|
|
21962
21966
|
return valor;
|
|
21963
21967
|
}
|
|
21964
21968
|
const valorAnteriorIncremento = valor;
|
|
21965
|
-
|
|
21966
|
-
|
|
21967
|
-
|
|
21969
|
+
if (expressao.operando instanceof construtos_1.Variavel) {
|
|
21970
|
+
this.pilhaEscoposExecucao.atribuirVariavel(expressao.operando.simbolo, ++valor);
|
|
21971
|
+
}
|
|
21968
21972
|
return valorAnteriorIncremento;
|
|
21969
21973
|
case delegua_1.default.DECREMENTAR:
|
|
21970
21974
|
if (expressao.incidenciaOperador === 'ANTES') {
|
|
@@ -21975,9 +21979,9 @@ class InterpretadorBase {
|
|
|
21975
21979
|
return valor;
|
|
21976
21980
|
}
|
|
21977
21981
|
const valorAnteriorDecremento = valor;
|
|
21978
|
-
|
|
21979
|
-
|
|
21980
|
-
|
|
21982
|
+
if (expressao.operando instanceof construtos_1.Variavel) {
|
|
21983
|
+
this.pilhaEscoposExecucao.atribuirVariavel(expressao.operando.simbolo, --valor);
|
|
21984
|
+
}
|
|
21981
21985
|
return valorAnteriorDecremento;
|
|
21982
21986
|
}
|
|
21983
21987
|
return null;
|
|
@@ -22351,8 +22355,10 @@ class InterpretadorBase {
|
|
|
22351
22355
|
*/
|
|
22352
22356
|
async visitarExpressaoDeChamada(expressao) {
|
|
22353
22357
|
try {
|
|
22354
|
-
let variavelEntidadeChamada = await this
|
|
22355
|
-
|
|
22358
|
+
let variavelEntidadeChamada = await this
|
|
22359
|
+
.avaliar(expressao.entidadeChamada);
|
|
22360
|
+
if (variavelEntidadeChamada === null ||
|
|
22361
|
+
variavelEntidadeChamada === undefined) {
|
|
22356
22362
|
return Promise.reject(new excecoes_1.ErroEmTempoDeExecucao(expressao.parentese, 'Chamada de função ou método inexistente: ' +
|
|
22357
22363
|
String(expressao.entidadeChamada), expressao.linha));
|
|
22358
22364
|
}
|
|
@@ -22370,7 +22376,8 @@ class InterpretadorBase {
|
|
|
22370
22376
|
if (entidadeChamada instanceof metodo_primitiva_1.MetodoPrimitiva) {
|
|
22371
22377
|
return await this.chamarMetodoPrimitiva(expressao, entidadeChamada);
|
|
22372
22378
|
}
|
|
22373
|
-
const argumentos = await this
|
|
22379
|
+
const argumentos = await this
|
|
22380
|
+
.resolverArgumentosChamada(expressao);
|
|
22374
22381
|
const aridade = entidadeChamada.aridade
|
|
22375
22382
|
? entidadeChamada.aridade()
|
|
22376
22383
|
: entidadeChamada.length;
|
|
@@ -22381,6 +22388,16 @@ class InterpretadorBase {
|
|
|
22381
22388
|
const ehPolimorfico = entidadeChamada instanceof estruturas_1.MetodoPolimorfico ||
|
|
22382
22389
|
(entidadeChamada instanceof estruturas_1.DescritorTipoClasse &&
|
|
22383
22390
|
entidadeChamada.encontrarMetodo('construtor') instanceof estruturas_1.MetodoPolimorfico);
|
|
22391
|
+
if (entidadeChamada instanceof estruturas_1.DeleguaFuncao && entidadeChamada.declaracao) {
|
|
22392
|
+
// Pega os parâmetros da declaração e filtra apenas os obrigatórios
|
|
22393
|
+
// (ignora os que têm valor padrão ou são rest parameters)
|
|
22394
|
+
const parametros = entidadeChamada.declaracao.parametros || [];
|
|
22395
|
+
const parametrosObrigatorios = parametros.filter((p) => !p.valorPadrao && p.abrangencia !== 'multiplo').length;
|
|
22396
|
+
if (argumentos.length < parametrosObrigatorios) {
|
|
22397
|
+
const nomeFuncao = entidadeChamada.nome || 'anônima';
|
|
22398
|
+
return Promise.reject(new excecoes_1.ErroEmTempoDeExecucao(expressao.parentese, `A função '${nomeFuncao}' esperava no mínimo ${parametrosObrigatorios} argumento(s), mas recebeu ${argumentos.length}.`, expressao.linha));
|
|
22399
|
+
}
|
|
22400
|
+
}
|
|
22384
22401
|
if (!ehPolimorfico && argumentos.length < aridade) {
|
|
22385
22402
|
const diferenca = aridade - argumentos.length;
|
|
22386
22403
|
for (let i = 0; i < diferenca; i++) {
|
|
@@ -23037,8 +23054,15 @@ class InterpretadorBase {
|
|
|
23037
23054
|
if (objeto instanceof construtos_1.Vetor) {
|
|
23038
23055
|
return objeto.valores[valorIndice];
|
|
23039
23056
|
}
|
|
23040
|
-
if (objeto.constructor === Object
|
|
23041
|
-
objeto
|
|
23057
|
+
if (objeto.constructor === Object) {
|
|
23058
|
+
if (!Object.prototype.hasOwnProperty.call(objeto, valorIndice)) {
|
|
23059
|
+
return Promise.reject(new excecoes_1.ErroEmTempoDeExecucao(expressao.simboloFechamento, `Chave '${valorIndice}' não encontrada no dicionário.`, expressao.linha));
|
|
23060
|
+
}
|
|
23061
|
+
if (objeto[valorIndice] === 0)
|
|
23062
|
+
return 0;
|
|
23063
|
+
return objeto[valorIndice];
|
|
23064
|
+
}
|
|
23065
|
+
if (objeto instanceof estruturas_1.ObjetoDeleguaClasse ||
|
|
23042
23066
|
objeto instanceof estruturas_1.DeleguaFuncao ||
|
|
23043
23067
|
objeto instanceof estruturas_1.DescritorTipoClasse ||
|
|
23044
23068
|
objeto instanceof estruturas_1.DeleguaModulo) {
|
|
@@ -23264,7 +23288,6 @@ class InterpretadorBase {
|
|
|
23264
23288
|
tipoObjeto = (0, inferenciador_1.inferirTipoVariavel)(variavelObjeto);
|
|
23265
23289
|
}
|
|
23266
23290
|
// Caso 3: Vetor simples do JavaScript.
|
|
23267
|
-
// TODO: Em teoria, isso deve estar no interpretador de Delégua, não aqui.
|
|
23268
23291
|
if (Array.isArray(objeto)) {
|
|
23269
23292
|
if (expressao.simbolo.lexema in primitivas_vetor_1.default) {
|
|
23270
23293
|
const metodoDePrimitivaVetor = primitivas_vetor_1.default[expressao.simbolo.lexema].implementacao;
|
|
@@ -23689,17 +23712,11 @@ class InterpretadorBase {
|
|
|
23689
23712
|
const inicioInterpretacao = (0, browser_process_hrtime_1.default)();
|
|
23690
23713
|
try {
|
|
23691
23714
|
const retornoOuErro = await this.executarUltimoEscopo(manterAmbiente);
|
|
23692
|
-
// TODO: Esta lógica já ocorre em `executarUltimoEscopo`.
|
|
23693
|
-
// Estudar remoção.
|
|
23694
|
-
if (retornoOuErro instanceof excecoes_1.ErroEmTempoDeExecucao) {
|
|
23695
|
-
this.erros.push(retornoOuErro);
|
|
23696
|
-
}
|
|
23697
23715
|
if (retornoOuErro !== undefined) {
|
|
23698
23716
|
this.resultadoInterpretador.push(retornoOuErro);
|
|
23699
23717
|
}
|
|
23700
23718
|
}
|
|
23701
23719
|
catch (erro) {
|
|
23702
|
-
// TODO: Estudar remoção do `catch`.
|
|
23703
23720
|
throw new Error(`Não deveria estar caindo aqui. Há erros no interpretador que não estão tratados corretamente. Erro atual: ${JSON.stringify(erro)}.`);
|
|
23704
23721
|
}
|
|
23705
23722
|
finally {
|
|
@@ -25398,15 +25415,20 @@ class PilhaEscoposExecucao {
|
|
|
25398
25415
|
if ([delegua_1.default.VETOR, delegua_1.default.TUPLA].includes(tipoConstante)) {
|
|
25399
25416
|
let subtipo = '';
|
|
25400
25417
|
if (valor instanceof Array) {
|
|
25401
|
-
|
|
25402
|
-
|
|
25403
|
-
|
|
25404
|
-
|
|
25418
|
+
const numeros = valor.some((v) => typeof v === 'number');
|
|
25419
|
+
const textos = valor.some((v) => typeof v === 'string');
|
|
25420
|
+
const logicos = valor.some((v) => typeof v === 'boolean');
|
|
25421
|
+
const tiposDistintos = [numeros, textos, logicos].filter(Boolean).length;
|
|
25422
|
+
if (tiposDistintos > 1)
|
|
25405
25423
|
subtipo = delegua_1.default.QUALQUER;
|
|
25406
25424
|
else if (numeros)
|
|
25407
25425
|
subtipo = delegua_1.default.NUMERO;
|
|
25408
|
-
else
|
|
25426
|
+
else if (logicos)
|
|
25427
|
+
subtipo = delegua_1.default.LOGICO;
|
|
25428
|
+
else if (textos)
|
|
25409
25429
|
subtipo = delegua_1.default.TEXTO;
|
|
25430
|
+
else
|
|
25431
|
+
subtipo = delegua_1.default.QUALQUER;
|
|
25410
25432
|
}
|
|
25411
25433
|
elementoAlvo.subtipo = subtipo;
|
|
25412
25434
|
}
|
|
@@ -25442,15 +25464,20 @@ class PilhaEscoposExecucao {
|
|
|
25442
25464
|
if ([delegua_1.default.VETOR, delegua_1.default.TUPLA].includes(tipoVariavel)) {
|
|
25443
25465
|
let subtipo = '';
|
|
25444
25466
|
if (valor instanceof Array) {
|
|
25445
|
-
|
|
25446
|
-
|
|
25447
|
-
|
|
25448
|
-
|
|
25467
|
+
const numeros = valor.some((v) => typeof v === 'number');
|
|
25468
|
+
const textos = valor.some((v) => typeof v === 'string');
|
|
25469
|
+
const logicos = valor.some((v) => typeof v === 'boolean');
|
|
25470
|
+
const tiposDistintos = [numeros, textos, logicos].filter(Boolean).length;
|
|
25471
|
+
if (tiposDistintos > 1)
|
|
25449
25472
|
subtipo = delegua_1.default.QUALQUER;
|
|
25450
25473
|
else if (numeros)
|
|
25451
25474
|
subtipo = delegua_1.default.NUMERO;
|
|
25452
|
-
else
|
|
25475
|
+
else if (logicos)
|
|
25476
|
+
subtipo = delegua_1.default.LOGICO;
|
|
25477
|
+
else if (textos)
|
|
25453
25478
|
subtipo = delegua_1.default.TEXTO;
|
|
25479
|
+
else
|
|
25480
|
+
subtipo = delegua_1.default.QUALQUER;
|
|
25454
25481
|
}
|
|
25455
25482
|
elementoAlvo.subtipo = subtipo;
|
|
25456
25483
|
}
|