@designliquido/delegua 0.41.6 → 0.41.8
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.d.ts.map +1 -1
- package/analisador-semantico/analisador-semantico.js +5 -4
- package/analisador-semantico/analisador-semantico.js.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.js +21 -16
- package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +4 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-ipt.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-ipt.js.map +1 -1
- package/avaliador-sintatico/informacao-escopo.d.ts +1 -1
- package/avaliador-sintatico/pilha-escopos.d.ts +3 -3
- package/avaliador-sintatico/pilha-escopos.d.ts.map +1 -1
- package/avaliador-sintatico/pilha-escopos.js.map +1 -1
- package/bibliotecas/biblioteca-global.d.ts +20 -10
- package/bibliotecas/biblioteca-global.d.ts.map +1 -1
- package/bibliotecas/biblioteca-global.js +40 -20
- package/bibliotecas/biblioteca-global.js.map +1 -1
- package/bibliotecas/dialetos/egua-classico/index.js +0 -1
- package/bibliotecas/dialetos/egua-classico/index.js.map +1 -1
- package/bibliotecas/primitivas-dicionario.d.ts.map +1 -1
- package/bibliotecas/primitivas-dicionario.js +2 -2
- package/bibliotecas/primitivas-dicionario.js.map +1 -1
- package/bibliotecas/primitivas-numero.d.ts.map +1 -1
- package/bibliotecas/primitivas-numero.js +2 -2
- package/bibliotecas/primitivas-numero.js.map +1 -1
- package/bibliotecas/primitivas-texto.d.ts.map +1 -1
- package/bibliotecas/primitivas-texto.js +14 -14
- package/bibliotecas/primitivas-texto.js.map +1 -1
- package/bibliotecas/primitivas-vetor.d.ts.map +1 -1
- package/bibliotecas/primitivas-vetor.js +16 -16
- package/bibliotecas/primitivas-vetor.js.map +1 -1
- package/bin/package.json +3 -1
- package/construtos/acesso-metodo-ou-propriedade.d.ts.map +1 -1
- package/construtos/acesso-metodo-ou-propriedade.js.map +1 -1
- package/construtos/acesso-metodo.d.ts +2 -2
- package/construtos/acesso-propriedade.d.ts +2 -2
- package/construtos/acesso-propriedade.d.ts.map +1 -1
- package/construtos/acesso-propriedade.js.map +1 -1
- package/construtos/argumento-referencia-funcao.d.ts +2 -2
- package/construtos/binario.d.ts.map +1 -1
- package/construtos/binario.js.map +1 -1
- package/construtos/componente-linguagem.d.ts +2 -2
- package/construtos/componente-linguagem.js +1 -1
- package/construtos/referencia-funcao.d.ts +2 -2
- package/construtos/super.d.ts.map +1 -1
- package/construtos/super.js.map +1 -1
- package/inferenciador.d.ts.map +1 -1
- package/inferenciador.js.map +1 -1
- package/interfaces/construtos/index.d.ts +2 -2
- package/interpretador/comum.d.ts.map +1 -1
- package/interpretador/comum.js +2 -0
- package/interpretador/comum.js.map +1 -1
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.js +1 -1
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.js.map +1 -1
- package/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.js.map +1 -1
- package/interpretador/estruturas/delegua-funcao.d.ts.map +1 -1
- package/interpretador/estruturas/delegua-funcao.js +1 -1
- package/interpretador/estruturas/delegua-funcao.js.map +1 -1
- package/interpretador/interpretador-base.d.ts +3 -3
- package/interpretador/interpretador-base.d.ts.map +1 -1
- package/interpretador/interpretador-base.js +8 -16
- package/interpretador/interpretador-base.js.map +1 -1
- package/interpretador/interpretador.d.ts +4 -4
- package/interpretador/interpretador.d.ts.map +1 -1
- package/interpretador/interpretador.js +3 -3
- package/interpretador/interpretador.js.map +1 -1
- package/interpretador/pilha-escopos-execucao.js +3 -3
- package/interpretador/pilha-escopos-execucao.js.map +1 -1
- package/package.json +3 -1
- package/tipos-de-simbolos/delegua.d.ts +1 -0
- package/tipos-de-simbolos/delegua.d.ts.map +1 -1
- package/tipos-de-simbolos/delegua.js +1 -0
- package/tipos-de-simbolos/delegua.js.map +1 -1
- package/tradutores/tradutor-assemblyscript.d.ts.map +1 -1
- package/tradutores/tradutor-assemblyscript.js +2 -1
- package/tradutores/tradutor-assemblyscript.js.map +1 -1
- package/tradutores/tradutor-javascript.d.ts.map +1 -1
- package/tradutores/tradutor-javascript.js +18 -13
- package/tradutores/tradutor-javascript.js.map +1 -1
- package/tradutores/tradutor-mermaidjs.d.ts.map +1 -1
- package/tradutores/tradutor-mermaidjs.js +8 -8
- package/tradutores/tradutor-mermaidjs.js.map +1 -1
- package/tradutores/tradutor-python.d.ts.map +1 -1
- package/tradutores/tradutor-python.js +6 -6
- package/tradutores/tradutor-python.js.map +1 -1
- package/umd/delegua.js +152 -123
package/umd/delegua.js
CHANGED
|
@@ -288,6 +288,8 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
288
288
|
this.primitivasConhecidas[nomePrimitivaVetor] = 'vetor';
|
|
289
289
|
}
|
|
290
290
|
this.primitivasConhecidas['inteiro'] = 'inteiro';
|
|
291
|
+
this.primitivasConhecidas['numero'] = 'número';
|
|
292
|
+
this.primitivasConhecidas['número'] = 'número';
|
|
291
293
|
this.primitivasConhecidas['texto'] = 'texto';
|
|
292
294
|
this.pilhaEscopos = new pilha_escopos_1.PilhaEscopos();
|
|
293
295
|
}
|
|
@@ -397,6 +399,22 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
397
399
|
}
|
|
398
400
|
const tipoVetor = (0, inferenciador_1.inferirTipoVariavel)(valores);
|
|
399
401
|
return new construtos_1.Vetor(this.hashArquivo, Number(simboloAtual.linha), valores, valores.length, tipoVetor);
|
|
402
|
+
case delegua_2.default.EXPRESSAO_REGULAR:
|
|
403
|
+
let valor = '';
|
|
404
|
+
let linhaAtual = this.simbolos[this.atual].linha;
|
|
405
|
+
let eParExpressaoRegular = this.simbolos.filter((l) => l.linha === linhaAtual && l.tipo === delegua_2.default.EXPRESSAO_REGULAR)
|
|
406
|
+
.length %
|
|
407
|
+
2 ===
|
|
408
|
+
0;
|
|
409
|
+
if (eParExpressaoRegular) {
|
|
410
|
+
this.avancarEDevolverAnterior();
|
|
411
|
+
while (!this.verificarTipoSimboloAtual(delegua_2.default.EXPRESSAO_REGULAR)) {
|
|
412
|
+
valor += this.simbolos[this.atual].lexema || '';
|
|
413
|
+
this.avancarEDevolverAnterior();
|
|
414
|
+
}
|
|
415
|
+
this.avancarEDevolverAnterior();
|
|
416
|
+
return new construtos_1.ExpressaoRegular(this.hashArquivo, simboloAtual, valor);
|
|
417
|
+
}
|
|
400
418
|
case delegua_2.default.FALSO:
|
|
401
419
|
this.avancarEDevolverAnterior();
|
|
402
420
|
return new construtos_1.Literal(this.hashArquivo, Number(simboloAtual.linha), false, 'lógico');
|
|
@@ -434,6 +452,7 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
434
452
|
this.avancarEDevolverAnterior();
|
|
435
453
|
return new construtos_1.Literal(this.hashArquivo, Number(simboloAtual.linha), null, 'nulo');
|
|
436
454
|
case delegua_2.default.NUMERO:
|
|
455
|
+
case delegua_2.default.NÚMERO:
|
|
437
456
|
case delegua_2.default.TEXTO:
|
|
438
457
|
const simboloNumeroTexto = this.avancarEDevolverAnterior();
|
|
439
458
|
const tipoInferido = (0, inferenciador_1.inferirTipoVariavel)(simboloNumeroTexto.literal);
|
|
@@ -517,22 +536,6 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
517
536
|
}
|
|
518
537
|
}
|
|
519
538
|
return new construtos_1.TipoDe(this.hashArquivo, simboloAtual, construto);
|
|
520
|
-
case delegua_2.default.EXPRESSAO_REGULAR:
|
|
521
|
-
let valor = '';
|
|
522
|
-
let linhaAtual = this.simbolos[this.atual].linha;
|
|
523
|
-
let eParExpressaoRegular = this.simbolos.filter((l) => l.linha === linhaAtual && l.tipo === delegua_2.default.EXPRESSAO_REGULAR)
|
|
524
|
-
.length %
|
|
525
|
-
2 ===
|
|
526
|
-
0;
|
|
527
|
-
if (eParExpressaoRegular) {
|
|
528
|
-
this.avancarEDevolverAnterior();
|
|
529
|
-
while (!this.verificarTipoSimboloAtual(delegua_2.default.EXPRESSAO_REGULAR)) {
|
|
530
|
-
valor += this.simbolos[this.atual].lexema || '';
|
|
531
|
-
this.avancarEDevolverAnterior();
|
|
532
|
-
}
|
|
533
|
-
this.avancarEDevolverAnterior();
|
|
534
|
-
return new construtos_1.ExpressaoRegular(this.hashArquivo, simboloAtual, valor);
|
|
535
|
-
}
|
|
536
539
|
}
|
|
537
540
|
throw this.erro(this.simbolos[this.atual], 'Esperado expressão.');
|
|
538
541
|
}
|
|
@@ -1651,6 +1654,8 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
1651
1654
|
this.pilhaEscopos.definirTipoVariavel('filtrarPor', 'qualquer[]');
|
|
1652
1655
|
this.pilhaEscopos.definirTipoVariavel('inteiro', 'inteiro');
|
|
1653
1656
|
this.pilhaEscopos.definirTipoVariavel('mapear', 'qualquer[]');
|
|
1657
|
+
this.pilhaEscopos.definirTipoVariavel('numero', 'número');
|
|
1658
|
+
this.pilhaEscopos.definirTipoVariavel('número', 'número');
|
|
1654
1659
|
this.pilhaEscopos.definirTipoVariavel('paraCada', 'qualquer[]');
|
|
1655
1660
|
this.pilhaEscopos.definirTipoVariavel('primeiroEmCondicao', 'qualquer');
|
|
1656
1661
|
this.pilhaEscopos.definirTipoVariavel('real', 'número');
|
|
@@ -2425,7 +2430,10 @@ class AvaliadorSintaticoPitugues {
|
|
|
2425
2430
|
// Se tipo ainda não foi definido, infere.
|
|
2426
2431
|
// tipo = this.logicaComumInferenciaTiposVariaveisEConstantes(inicializadores[indice], tipo);
|
|
2427
2432
|
// this.pilhaEscopos.definirTipoVariavel(identificador.lexema, tipo);
|
|
2428
|
-
retorno.push(new declaracoes_1.Const(identificador, inicializadores[indice], tipo
|
|
2433
|
+
retorno.push(new declaracoes_1.Const(identificador, inicializadores[indice], tipo
|
|
2434
|
+
// TODO: Discutir decoradores com comunidade.
|
|
2435
|
+
// Array.from(this.pilhaDecoradores)
|
|
2436
|
+
));
|
|
2429
2437
|
}
|
|
2430
2438
|
// this.pilhaDecoradores = [];
|
|
2431
2439
|
return retorno;
|
|
@@ -3808,6 +3816,7 @@ exports.filtrarPor = filtrarPor;
|
|
|
3808
3816
|
exports.incluido = incluido;
|
|
3809
3817
|
exports.inteiro = inteiro;
|
|
3810
3818
|
exports.mapear = mapear;
|
|
3819
|
+
exports.numero = numero;
|
|
3811
3820
|
exports.ordenar = ordenar;
|
|
3812
3821
|
exports.paraCada = paraCada;
|
|
3813
3822
|
exports.primeiroEmCondicao = primeiroEmCondicao;
|
|
@@ -3838,7 +3847,6 @@ async function aleatorio(interpretador) {
|
|
|
3838
3847
|
* @returns {Promise<number>} Um número real entre os valores máximo e mínimo especificados.
|
|
3839
3848
|
*/
|
|
3840
3849
|
async function aleatorioEntre(interpretador, minimo, maximo) {
|
|
3841
|
-
// eslint-disable-next-line prefer-rest-params
|
|
3842
3850
|
if (arguments.length <= 0) {
|
|
3843
3851
|
return Promise.reject(new excecoes_1.ErroEmTempoDeExecucao(this.simbolo, 'A função recebe ao menos um parâmetro.'));
|
|
3844
3852
|
}
|
|
@@ -4023,23 +4031,27 @@ async function incluido(interpretador, vetor, valor) {
|
|
|
4023
4031
|
}
|
|
4024
4032
|
return false;
|
|
4025
4033
|
}
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
* @param {InterpretadorInterface} interpretador A instância do interpretador.
|
|
4029
|
-
* @param numero
|
|
4030
|
-
* @returns
|
|
4031
|
-
*/
|
|
4032
|
-
async function inteiro(interpretador, numero) {
|
|
4033
|
-
if (numero === null || numero === undefined)
|
|
4034
|
-
return Promise.resolve(0);
|
|
4035
|
-
const valor = numero.hasOwnProperty('valor') ? numero.valor : numero;
|
|
4036
|
-
if (isNaN(valor)) {
|
|
4034
|
+
function validacaoComumNumeros(valorParaConverter) {
|
|
4035
|
+
if (isNaN(valorParaConverter)) {
|
|
4037
4036
|
return Promise.reject(new excecoes_1.ErroEmTempoDeExecucao(this.simbolo, 'Valor não parece ser um número. Somente números ou textos com números podem ser convertidos para inteiro.'));
|
|
4038
4037
|
}
|
|
4039
|
-
if (!/^(-)?\d+(\.\d+)?$/.test(
|
|
4038
|
+
if (!/^(-)?\d+(\.\d+)?$/.test(valorParaConverter)) {
|
|
4040
4039
|
return Promise.reject(new excecoes_1.ErroEmTempoDeExecucao(this.simbolo, 'Valor não parece estar estruturado como um número (texto vazio, falso ou não definido). Somente números ou textos com números podem ser convertidos para inteiro.'));
|
|
4041
4040
|
}
|
|
4042
|
-
return
|
|
4041
|
+
return null;
|
|
4042
|
+
}
|
|
4043
|
+
/**
|
|
4044
|
+
* Converte um valor em um número inteiro.
|
|
4045
|
+
* @param {InterpretadorInterface} interpretador A instância do interpretador.
|
|
4046
|
+
* @param {VariavelInterface | any} valorParaConverter O valor a ser convertido.
|
|
4047
|
+
* @returns {Promise<any>} Uma Promise com o resultado da conversão.
|
|
4048
|
+
*/
|
|
4049
|
+
async function inteiro(interpretador, valorParaConverter) {
|
|
4050
|
+
if (valorParaConverter === null || valorParaConverter === undefined)
|
|
4051
|
+
return Promise.resolve(0);
|
|
4052
|
+
const valor = valorParaConverter.hasOwnProperty('valor') ? valorParaConverter.valor : valorParaConverter;
|
|
4053
|
+
const resultadoValidacao = validacaoComumNumeros(valor);
|
|
4054
|
+
return resultadoValidacao || Promise.resolve(parseInt(valor));
|
|
4043
4055
|
}
|
|
4044
4056
|
/**
|
|
4045
4057
|
*
|
|
@@ -4065,6 +4077,19 @@ async function mapear(interpretador, vetor, funcaoMapeamento) {
|
|
|
4065
4077
|
}
|
|
4066
4078
|
return resultados;
|
|
4067
4079
|
}
|
|
4080
|
+
/**
|
|
4081
|
+
* Converte um valor em um número, com parte decimal ou não.
|
|
4082
|
+
* @param {InterpretadorInterface} interpretador A instância do interpretador.
|
|
4083
|
+
* @param {VariavelInterface | any} valorParaConverter O valor a ser convertido.
|
|
4084
|
+
* @returns {Promise<any>} Uma Promise com o resultado da conversão.
|
|
4085
|
+
*/
|
|
4086
|
+
async function numero(interpretador, valorParaConverter) {
|
|
4087
|
+
if (valorParaConverter === null || valorParaConverter === undefined)
|
|
4088
|
+
return Promise.resolve(0);
|
|
4089
|
+
const valor = valorParaConverter.hasOwnProperty('valor') ? valorParaConverter.valor : valorParaConverter;
|
|
4090
|
+
const resultadoValidacao = validacaoComumNumeros(valor);
|
|
4091
|
+
return resultadoValidacao || Promise.resolve(Number(valor));
|
|
4092
|
+
}
|
|
4068
4093
|
/**
|
|
4069
4094
|
*
|
|
4070
4095
|
* @param vetor
|
|
@@ -4215,17 +4240,20 @@ async function tamanho(interpretador, objeto) {
|
|
|
4215
4240
|
* Transforma o valor ou variável em texto.
|
|
4216
4241
|
* @param {InterpretadorInterface} interpretador A instância do interpretador.
|
|
4217
4242
|
* @param {VariavelInterface | any} valorOuVariavel O valor ou variável.
|
|
4218
|
-
* @returns {string} O valor resolvido em texto.
|
|
4243
|
+
* @returns {Promise<string>} O valor resolvido em texto.
|
|
4219
4244
|
*/
|
|
4220
4245
|
async function texto(interpretador, valorOuVariavel) {
|
|
4221
4246
|
return Promise.resolve(`${valorOuVariavel.hasOwnProperty('valor') ? valorOuVariavel.valor : valorOuVariavel}`);
|
|
4222
4247
|
}
|
|
4223
4248
|
/**
|
|
4224
|
-
*
|
|
4225
|
-
*
|
|
4226
|
-
* @param
|
|
4227
|
-
* @param
|
|
4228
|
-
* @
|
|
4249
|
+
* Retorna verdadeiro se todos os elementos do primeiro parâmetro retornam verdadeiro ao
|
|
4250
|
+
* serem aplicados como argumentos da função passada como segundo parâmetro.
|
|
4251
|
+
* @param {InterpretadorInterface} interpretador A instância do interpretador.
|
|
4252
|
+
* @param {VariavelInterface | any} vetor O primeiro parâmetro, um vetor.
|
|
4253
|
+
* @param {VariavelInterface | any} funcaoCondicional A função que será executada com cada
|
|
4254
|
+
* valor do vetor passado como primeiro parâmetro.
|
|
4255
|
+
* @returns {Promise<boolean>} Verdadeiro, se todos os valores do vetor fazem a função passada
|
|
4256
|
+
* por parâmetro devolver verdadeiro, ou falso em caso contrário.
|
|
4229
4257
|
*/
|
|
4230
4258
|
async function todosEmCondicao(interpretador, vetor, funcaoCondicional) {
|
|
4231
4259
|
if (vetor === null || vetor === undefined)
|
|
@@ -4291,13 +4319,13 @@ exports.default = {
|
|
|
4291
4319
|
tipoRetorno: 'texto[]',
|
|
4292
4320
|
implementacao: (interpretador, valor) => {
|
|
4293
4321
|
return Promise.resolve(Object.keys(valor));
|
|
4294
|
-
}
|
|
4322
|
+
},
|
|
4295
4323
|
},
|
|
4296
4324
|
valores: {
|
|
4297
4325
|
tipoRetorno: 'qualquer[]',
|
|
4298
4326
|
implementacao: (interpretador, valor) => {
|
|
4299
4327
|
return Promise.resolve(Object.values(valor));
|
|
4300
|
-
}
|
|
4328
|
+
},
|
|
4301
4329
|
},
|
|
4302
4330
|
};
|
|
4303
4331
|
|
|
@@ -4309,13 +4337,13 @@ exports.default = {
|
|
|
4309
4337
|
tipoRetorno: 'número',
|
|
4310
4338
|
implementacao: (interpretador, valor) => {
|
|
4311
4339
|
return Promise.resolve(Math.floor(valor));
|
|
4312
|
-
}
|
|
4340
|
+
},
|
|
4313
4341
|
},
|
|
4314
4342
|
arredondarParaCima: {
|
|
4315
4343
|
tipoRetorno: 'número',
|
|
4316
4344
|
implementacao: (interpretador, valor) => {
|
|
4317
4345
|
return Promise.resolve(Math.ceil(valor));
|
|
4318
|
-
}
|
|
4346
|
+
},
|
|
4319
4347
|
},
|
|
4320
4348
|
};
|
|
4321
4349
|
|
|
@@ -4325,19 +4353,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4325
4353
|
exports.default = {
|
|
4326
4354
|
aparar: {
|
|
4327
4355
|
tipoRetorno: 'texto',
|
|
4328
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.trim())
|
|
4356
|
+
implementacao: (interpretador, texto) => Promise.resolve(texto.trim()),
|
|
4329
4357
|
},
|
|
4330
4358
|
apararFim: {
|
|
4331
4359
|
tipoRetorno: 'texto',
|
|
4332
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.trimEnd())
|
|
4360
|
+
implementacao: (interpretador, texto) => Promise.resolve(texto.trimEnd()),
|
|
4333
4361
|
},
|
|
4334
4362
|
apararInicio: {
|
|
4335
4363
|
tipoRetorno: 'texto',
|
|
4336
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.trimStart())
|
|
4364
|
+
implementacao: (interpretador, texto) => Promise.resolve(texto.trimStart()),
|
|
4337
4365
|
},
|
|
4338
4366
|
concatenar: {
|
|
4339
4367
|
tipoRetorno: 'texto',
|
|
4340
|
-
implementacao: (interpretador, ...texto) => Promise.resolve(''.concat(...texto))
|
|
4368
|
+
implementacao: (interpretador, ...texto) => Promise.resolve(''.concat(...texto)),
|
|
4341
4369
|
},
|
|
4342
4370
|
dividir: {
|
|
4343
4371
|
tipoRetorno: 'texto[]',
|
|
@@ -4346,40 +4374,40 @@ exports.default = {
|
|
|
4346
4374
|
return Promise.resolve(texto.split(divisor, limite));
|
|
4347
4375
|
}
|
|
4348
4376
|
return Promise.resolve(texto.split(divisor));
|
|
4349
|
-
}
|
|
4377
|
+
},
|
|
4350
4378
|
},
|
|
4351
4379
|
fatiar: {
|
|
4352
4380
|
tipoRetorno: 'texto',
|
|
4353
|
-
implementacao: (interpretador, texto, inicio, fim) => Promise.resolve(texto.slice(inicio, fim))
|
|
4381
|
+
implementacao: (interpretador, texto, inicio, fim) => Promise.resolve(texto.slice(inicio, fim)),
|
|
4354
4382
|
},
|
|
4355
4383
|
inclui: {
|
|
4356
4384
|
tipoRetorno: 'texto',
|
|
4357
|
-
implementacao: (interpretador, texto, elemento) => Promise.resolve(texto.includes(elemento))
|
|
4385
|
+
implementacao: (interpretador, texto, elemento) => Promise.resolve(texto.includes(elemento)),
|
|
4358
4386
|
},
|
|
4359
4387
|
inverter: {
|
|
4360
4388
|
tipoRetorno: 'texto',
|
|
4361
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.split('').reduce((texto, caracter) => (texto = caracter + texto), ''))
|
|
4389
|
+
implementacao: (interpretador, texto) => Promise.resolve(texto.split('').reduce((texto, caracter) => (texto = caracter + texto), '')),
|
|
4362
4390
|
},
|
|
4363
4391
|
maiusculo: {
|
|
4364
4392
|
tipoRetorno: 'texto',
|
|
4365
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.toUpperCase())
|
|
4393
|
+
implementacao: (interpretador, texto) => Promise.resolve(texto.toUpperCase()),
|
|
4366
4394
|
},
|
|
4367
4395
|
minusculo: {
|
|
4368
4396
|
tipoRetorno: 'texto',
|
|
4369
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.toLowerCase())
|
|
4397
|
+
implementacao: (interpretador, texto) => Promise.resolve(texto.toLowerCase()),
|
|
4370
4398
|
},
|
|
4371
4399
|
substituir: {
|
|
4372
4400
|
tipoRetorno: 'texto',
|
|
4373
|
-
implementacao: (interpretador, texto, elemento, substituto) => Promise.resolve(texto.replace(elemento, substituto))
|
|
4401
|
+
implementacao: (interpretador, texto, elemento, substituto) => Promise.resolve(texto.replace(elemento, substituto)),
|
|
4374
4402
|
},
|
|
4375
4403
|
subtexto: {
|
|
4376
4404
|
tipoRetorno: 'texto',
|
|
4377
|
-
implementacao: (interpretador, texto, inicio, fim) => Promise.resolve(texto.slice(inicio, fim))
|
|
4405
|
+
implementacao: (interpretador, texto, inicio, fim) => Promise.resolve(texto.slice(inicio, fim)),
|
|
4378
4406
|
},
|
|
4379
4407
|
tamanho: {
|
|
4380
4408
|
tipoRetorno: 'número',
|
|
4381
|
-
implementacao: (interpretador, texto) => Promise.resolve(texto.length)
|
|
4382
|
-
}
|
|
4409
|
+
implementacao: (interpretador, texto) => Promise.resolve(texto.length),
|
|
4410
|
+
},
|
|
4383
4411
|
};
|
|
4384
4412
|
|
|
4385
4413
|
},{}],19:[function(require,module,exports){
|
|
@@ -4391,20 +4419,20 @@ exports.default = {
|
|
|
4391
4419
|
implementacao: (interpretador, vetor, elemento) => {
|
|
4392
4420
|
vetor.push(elemento);
|
|
4393
4421
|
return Promise.resolve(vetor);
|
|
4394
|
-
}
|
|
4422
|
+
},
|
|
4395
4423
|
},
|
|
4396
4424
|
concatenar: {
|
|
4397
4425
|
tipoRetorno: 'qualquer[]',
|
|
4398
4426
|
implementacao: (interpretador, vetor, outroVetor) => {
|
|
4399
4427
|
return Promise.resolve(vetor.concat(outroVetor));
|
|
4400
|
-
}
|
|
4428
|
+
},
|
|
4401
4429
|
},
|
|
4402
4430
|
empilhar: {
|
|
4403
4431
|
tipoRetorno: 'qualquer[]',
|
|
4404
4432
|
implementacao: (interpretador, vetor, elemento) => {
|
|
4405
4433
|
vetor.push(elemento);
|
|
4406
4434
|
return Promise.resolve(vetor);
|
|
4407
|
-
}
|
|
4435
|
+
},
|
|
4408
4436
|
},
|
|
4409
4437
|
encaixar: {
|
|
4410
4438
|
tipoRetorno: 'qualquer[]',
|
|
@@ -4419,7 +4447,7 @@ exports.default = {
|
|
|
4419
4447
|
elementos = !items.length ? vetor.splice(inicio) : vetor.splice(inicio, ...items);
|
|
4420
4448
|
}
|
|
4421
4449
|
return Promise.resolve(elementos);
|
|
4422
|
-
}
|
|
4450
|
+
},
|
|
4423
4451
|
},
|
|
4424
4452
|
fatiar: {
|
|
4425
4453
|
tipoRetorno: 'qualquer[]',
|
|
@@ -4438,19 +4466,19 @@ exports.default = {
|
|
|
4438
4466
|
}
|
|
4439
4467
|
}
|
|
4440
4468
|
return retorno;
|
|
4441
|
-
}
|
|
4469
|
+
},
|
|
4442
4470
|
},
|
|
4443
4471
|
inclui: {
|
|
4444
4472
|
tipoRetorno: 'lógico',
|
|
4445
|
-
implementacao: (interpretador, vetor, elemento) => Promise.resolve(vetor.includes(elemento))
|
|
4473
|
+
implementacao: (interpretador, vetor, elemento) => Promise.resolve(vetor.includes(elemento)),
|
|
4446
4474
|
},
|
|
4447
4475
|
inverter: {
|
|
4448
4476
|
tipoRetorno: 'qualquer[]',
|
|
4449
|
-
implementacao: (interpretador, vetor) => Promise.resolve(vetor.reverse())
|
|
4477
|
+
implementacao: (interpretador, vetor) => Promise.resolve(vetor.reverse()),
|
|
4450
4478
|
},
|
|
4451
4479
|
juntar: {
|
|
4452
4480
|
tipoRetorno: 'texto',
|
|
4453
|
-
implementacao: (interpretador, vetor, separador) => Promise.resolve(vetor.join(separador))
|
|
4481
|
+
implementacao: (interpretador, vetor, separador) => Promise.resolve(vetor.join(separador)),
|
|
4454
4482
|
},
|
|
4455
4483
|
mapear: {
|
|
4456
4484
|
tipoRetorno: 'qualquer[]',
|
|
@@ -4464,7 +4492,7 @@ exports.default = {
|
|
|
4464
4492
|
retorno.push(resultado);
|
|
4465
4493
|
}
|
|
4466
4494
|
return retorno;
|
|
4467
|
-
}
|
|
4495
|
+
},
|
|
4468
4496
|
},
|
|
4469
4497
|
ordenar: {
|
|
4470
4498
|
tipoRetorno: 'qualquer[]',
|
|
@@ -4485,7 +4513,7 @@ exports.default = {
|
|
|
4485
4513
|
return vetor.sort();
|
|
4486
4514
|
}
|
|
4487
4515
|
return vetor.sort((a, b) => a - b);
|
|
4488
|
-
}
|
|
4516
|
+
},
|
|
4489
4517
|
},
|
|
4490
4518
|
remover: {
|
|
4491
4519
|
tipoRetorno: 'qualquer[]',
|
|
@@ -4494,32 +4522,32 @@ exports.default = {
|
|
|
4494
4522
|
if (index !== -1)
|
|
4495
4523
|
vetor.splice(index, 1);
|
|
4496
4524
|
return Promise.resolve(vetor);
|
|
4497
|
-
}
|
|
4525
|
+
},
|
|
4498
4526
|
},
|
|
4499
4527
|
removerPrimeiro: {
|
|
4500
4528
|
tipoRetorno: 'qualquer',
|
|
4501
4529
|
implementacao: (interpretador, vetor) => {
|
|
4502
4530
|
let elemento = vetor.shift();
|
|
4503
4531
|
return Promise.resolve(elemento);
|
|
4504
|
-
}
|
|
4532
|
+
},
|
|
4505
4533
|
},
|
|
4506
4534
|
removerUltimo: {
|
|
4507
4535
|
tipoRetorno: 'qualquer',
|
|
4508
4536
|
implementacao: (interpretador, vetor) => {
|
|
4509
4537
|
let elemento = vetor.pop();
|
|
4510
4538
|
return Promise.resolve(elemento);
|
|
4511
|
-
}
|
|
4539
|
+
},
|
|
4512
4540
|
},
|
|
4513
4541
|
somar: {
|
|
4514
4542
|
tipoRetorno: 'qualquer',
|
|
4515
4543
|
implementacao: (interpretador, vetor) => {
|
|
4516
4544
|
return Promise.resolve(vetor.reduce((acc, item) => acc + (typeof item === 'number' ? item : item.valor), 0));
|
|
4517
|
-
}
|
|
4545
|
+
},
|
|
4518
4546
|
},
|
|
4519
4547
|
tamanho: {
|
|
4520
4548
|
tipoRetorno: 'número',
|
|
4521
|
-
implementacao: (interpretador, vetor) => Promise.resolve(vetor.length)
|
|
4522
|
-
}
|
|
4549
|
+
implementacao: (interpretador, vetor) => Promise.resolve(vetor.length),
|
|
4550
|
+
},
|
|
4523
4551
|
};
|
|
4524
4552
|
|
|
4525
4553
|
},{}],20:[function(require,module,exports){
|
|
@@ -4827,7 +4855,7 @@ class ComponenteLinguagem {
|
|
|
4827
4855
|
this.valor = simbolo.lexema;
|
|
4828
4856
|
}
|
|
4829
4857
|
aceitar(visitante) {
|
|
4830
|
-
throw new Error(
|
|
4858
|
+
throw new Error('Um componente de linguagem não tem método de visita.');
|
|
4831
4859
|
}
|
|
4832
4860
|
}
|
|
4833
4861
|
exports.ComponenteLinguagem = ComponenteLinguagem;
|
|
@@ -7527,6 +7555,8 @@ function carregarBibliotecasGlobais(pilhaEscoposExecucao) {
|
|
|
7527
7555
|
pilhaEscoposExecucao.definirVariavel('incluido', new funcao_padrao_1.FuncaoPadrao(2, bibliotecaGlobal.incluido));
|
|
7528
7556
|
pilhaEscoposExecucao.definirVariavel('inteiro', new funcao_padrao_1.FuncaoPadrao(1, bibliotecaGlobal.inteiro));
|
|
7529
7557
|
pilhaEscoposExecucao.definirVariavel('mapear', new funcao_padrao_1.FuncaoPadrao(2, bibliotecaGlobal.mapear));
|
|
7558
|
+
pilhaEscoposExecucao.definirVariavel('numero', new funcao_padrao_1.FuncaoPadrao(1, bibliotecaGlobal.numero));
|
|
7559
|
+
pilhaEscoposExecucao.definirVariavel('número', new funcao_padrao_1.FuncaoPadrao(1, bibliotecaGlobal.numero));
|
|
7530
7560
|
pilhaEscoposExecucao.definirVariavel('ordenar', new funcao_padrao_1.FuncaoPadrao(1, bibliotecaGlobal.ordenar));
|
|
7531
7561
|
pilhaEscoposExecucao.definirVariavel('paraCada', new funcao_padrao_1.FuncaoPadrao(2, bibliotecaGlobal.paraCada));
|
|
7532
7562
|
pilhaEscoposExecucao.definirVariavel('primeiroEmCondicao', new funcao_padrao_1.FuncaoPadrao(2, bibliotecaGlobal.primeiroEmCondicao));
|
|
@@ -7681,7 +7711,7 @@ class DeleguaFuncao extends chamavel_1.Chamavel {
|
|
|
7681
7711
|
argumentos[i].valor = parametro['padrao'] ? parametro['padrao'].valor : null;
|
|
7682
7712
|
}
|
|
7683
7713
|
ambiente.valores[nome] = argumento && argumento.hasOwnProperty('valor') ? argumento.valor : argumento;
|
|
7684
|
-
// Se o argumento é `DeleguaFuncao`, para habilitar o recurso de _currying_,
|
|
7714
|
+
// Se o argumento é `DeleguaFuncao`, para habilitar o recurso de _currying_,
|
|
7685
7715
|
// copiamos seu valor para o escopo atual. Nem sempre podemos contar com a tipagem explícita aqui.
|
|
7686
7716
|
if (argumento.valor && ['funcao', 'função'].includes(argumento.valor.tipo)) {
|
|
7687
7717
|
parametro.referencia = true;
|
|
@@ -8575,7 +8605,7 @@ class InterpretadorBase {
|
|
|
8575
8605
|
for (let i = 0; i < diferenca; i++) {
|
|
8576
8606
|
argumentos.push({
|
|
8577
8607
|
nome: null,
|
|
8578
|
-
valor: null
|
|
8608
|
+
valor: null,
|
|
8579
8609
|
});
|
|
8580
8610
|
}
|
|
8581
8611
|
}
|
|
@@ -8888,7 +8918,9 @@ class InterpretadorBase {
|
|
|
8888
8918
|
}
|
|
8889
8919
|
else {
|
|
8890
8920
|
const literalErro = new construtos_1.Literal(declaracao.hashArquivo, Number(declaracao.linha), erro.mensagem);
|
|
8891
|
-
const chamadaPegue = new construtos_1.Chamada(declaracao.caminhoPegue.hashArquivo, declaracao.caminhoPegue, [
|
|
8921
|
+
const chamadaPegue = new construtos_1.Chamada(declaracao.caminhoPegue.hashArquivo, declaracao.caminhoPegue, [
|
|
8922
|
+
literalErro,
|
|
8923
|
+
]);
|
|
8892
8924
|
valorRetorno = await chamadaPegue.aceitar(this);
|
|
8893
8925
|
}
|
|
8894
8926
|
}
|
|
@@ -9239,11 +9271,7 @@ class InterpretadorBase {
|
|
|
9239
9271
|
dicionario[chaveLogico] = promises[1];
|
|
9240
9272
|
continue;
|
|
9241
9273
|
}
|
|
9242
|
-
|
|
9243
|
-
dicionario[promises[0]] = promises[1].valor;
|
|
9244
|
-
continue;
|
|
9245
|
-
}
|
|
9246
|
-
dicionario[promises[0]] = promises[1];
|
|
9274
|
+
dicionario[promises[0]] = promises[1].hasOwnProperty('valor') ? promises[1].valor : promises[1];
|
|
9247
9275
|
}
|
|
9248
9276
|
return dicionario;
|
|
9249
9277
|
}
|
|
@@ -9347,16 +9375,9 @@ class InterpretadorBase {
|
|
|
9347
9375
|
* @param mostrarResultado Se resultado deve ser mostrado ou não. Normalmente usado
|
|
9348
9376
|
* pelo modo LAIR.
|
|
9349
9377
|
*/
|
|
9350
|
-
async executar(declaracao
|
|
9378
|
+
async executar(declaracao) {
|
|
9351
9379
|
const resultado = await declaracao.aceitar(this);
|
|
9352
9380
|
/* console.log("Resultado aceitar: " + resultado, this); */
|
|
9353
|
-
// TODO: Mover a lógica abaixo para `delegua-node`.
|
|
9354
|
-
if (mostrarResultado) {
|
|
9355
|
-
this.funcaoDeRetorno(this.paraTexto(resultado));
|
|
9356
|
-
}
|
|
9357
|
-
if (resultado || typeof resultado === primitivos_1.default.BOOLEANO) {
|
|
9358
|
-
this.resultadoInterpretador.push(this.paraTexto(resultado));
|
|
9359
|
-
}
|
|
9360
9381
|
return resultado;
|
|
9361
9382
|
}
|
|
9362
9383
|
/**
|
|
@@ -9426,7 +9447,8 @@ class InterpretadorBase {
|
|
|
9426
9447
|
this.erros.push(retornoOuErro);
|
|
9427
9448
|
}
|
|
9428
9449
|
}
|
|
9429
|
-
catch (erro) {
|
|
9450
|
+
catch (erro) {
|
|
9451
|
+
// TODO: Estudar remoção do `catch`.
|
|
9430
9452
|
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)}.`);
|
|
9431
9453
|
}
|
|
9432
9454
|
finally {
|
|
@@ -10029,13 +10051,13 @@ const estruturas_1 = require("./estruturas");
|
|
|
10029
10051
|
const interpretador_base_1 = require("./interpretador-base");
|
|
10030
10052
|
const inferenciador_1 = require("../inferenciador");
|
|
10031
10053
|
const excecoes_1 = require("../excecoes");
|
|
10054
|
+
const quebras_1 = require("../quebras");
|
|
10032
10055
|
const primitivas_dicionario_1 = __importDefault(require("../bibliotecas/primitivas-dicionario"));
|
|
10033
10056
|
const primitivas_numero_1 = __importDefault(require("../bibliotecas/primitivas-numero"));
|
|
10034
10057
|
const primitivas_texto_1 = __importDefault(require("../bibliotecas/primitivas-texto"));
|
|
10035
10058
|
const primitivas_vetor_1 = __importDefault(require("../bibliotecas/primitivas-vetor"));
|
|
10036
10059
|
const primitivos_1 = __importDefault(require("../tipos-de-dados/primitivos"));
|
|
10037
10060
|
const delegua_1 = __importDefault(require("../tipos-de-dados/delegua"));
|
|
10038
|
-
const quebras_1 = require("../quebras");
|
|
10039
10061
|
/**
|
|
10040
10062
|
* O interpretador de Delégua.
|
|
10041
10063
|
*/
|
|
@@ -10275,9 +10297,9 @@ class Interpretador extends interpretador_base_1.InterpretadorBase {
|
|
|
10275
10297
|
const acessoPropriedade = valorTipoDe;
|
|
10276
10298
|
return acessoPropriedade.tipoRetornoPropriedade;
|
|
10277
10299
|
case 'AcessoMetodoOuPropriedade':
|
|
10278
|
-
// TODO: Deve ser removido mais futuramente.
|
|
10300
|
+
// TODO: Deve ser removido mais futuramente.
|
|
10279
10301
|
// Apenas `AcessoMetodo` e `AcessoPropriedade` devem funcionar aqui.
|
|
10280
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simbolo,
|
|
10302
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simbolo, 'Não deveria cair aqui.');
|
|
10281
10303
|
case 'Escreva':
|
|
10282
10304
|
return 'função<vazio>';
|
|
10283
10305
|
case 'Leia':
|
|
@@ -10445,9 +10467,9 @@ class PilhaEscoposExecucao {
|
|
|
10445
10467
|
if (variavel.imutavel) {
|
|
10446
10468
|
throw new excecoes_1.ErroEmTempoDeExecucao(simbolo, `Constante '${simbolo.lexema}' não pode receber novos valores.`);
|
|
10447
10469
|
}
|
|
10448
|
-
const tipoInferido = variavel && variavel.hasOwnProperty('tipo') && variavel.tipo
|
|
10449
|
-
variavel.tipo
|
|
10450
|
-
(0, inferenciador_1.inferirTipoVariavel)(valor);
|
|
10470
|
+
const tipoInferido = variavel && variavel.hasOwnProperty('tipo') && variavel.tipo
|
|
10471
|
+
? variavel.tipo
|
|
10472
|
+
: (0, inferenciador_1.inferirTipoVariavel)(valor);
|
|
10451
10473
|
const tipo = tipoInferido.toLowerCase();
|
|
10452
10474
|
const valorResolvido = this.converterValor(tipo, valor);
|
|
10453
10475
|
if (indice !== undefined && indice !== null) {
|
|
@@ -12828,6 +12850,7 @@ exports.default = {
|
|
|
12828
12850
|
NEGACAO: 'NEGACAO',
|
|
12829
12851
|
NULO: 'NULO',
|
|
12830
12852
|
NUMERO: 'NUMERO',
|
|
12853
|
+
NÚMERO: 'NÚMERO',
|
|
12831
12854
|
OU: 'OU',
|
|
12832
12855
|
PADRAO: 'PADRAO',
|
|
12833
12856
|
PADRÃO: 'PADRÃO',
|
|
@@ -26034,7 +26057,8 @@ class TradutorAssemblyScript {
|
|
|
26034
26057
|
case 'Retorna':
|
|
26035
26058
|
const declaracaoRetorna = declaracao;
|
|
26036
26059
|
resultado +=
|
|
26037
|
-
'return ' +
|
|
26060
|
+
'return ' +
|
|
26061
|
+
this.dicionarioConstrutos[declaracaoRetorna.valor.constructor.name](declaracaoRetorna.valor);
|
|
26038
26062
|
break;
|
|
26039
26063
|
default:
|
|
26040
26064
|
resultado += this.dicionarioDeclaracoes[declaracao.constructor.name](declaracao) + '\n';
|
|
@@ -26349,7 +26373,7 @@ class TradutorJavaScript {
|
|
|
26349
26373
|
const argumentoResolvido = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
26350
26374
|
argumentosResolvidos.push(argumentoResolvido);
|
|
26351
26375
|
}
|
|
26352
|
-
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => atual += proximo + ', ',
|
|
26376
|
+
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => (atual += proximo + ', '), '');
|
|
26353
26377
|
textoArgumentos = textoArgumentos.slice(0, -2);
|
|
26354
26378
|
switch (nomeMetodo) {
|
|
26355
26379
|
case 'adicionar':
|
|
@@ -26449,7 +26473,7 @@ class TradutorJavaScript {
|
|
|
26449
26473
|
let resultado = '{';
|
|
26450
26474
|
for (let i = 0; i < dicionario.chaves.length; i++) {
|
|
26451
26475
|
resultado += this.dicionarioConstrutos[dicionario.chaves[i].constructor.name](dicionario.chaves[i]);
|
|
26452
|
-
resultado +=
|
|
26476
|
+
resultado += ':';
|
|
26453
26477
|
resultado += this.dicionarioConstrutos[dicionario.valores[i].constructor.name](dicionario.valores[i]) + ',';
|
|
26454
26478
|
}
|
|
26455
26479
|
resultado += '}';
|
|
@@ -26460,10 +26484,14 @@ class TradutorJavaScript {
|
|
|
26460
26484
|
const possuiInterpolacao = /\$\{(verdadeiro|falso|nulo)\}/.test(literal.valor);
|
|
26461
26485
|
const valor = literal.valor.replace(/\$\{(verdadeiro|falso|nulo)\}/g, (_, match) => {
|
|
26462
26486
|
switch (match) {
|
|
26463
|
-
case 'verdadeiro':
|
|
26464
|
-
|
|
26465
|
-
case '
|
|
26466
|
-
|
|
26487
|
+
case 'verdadeiro':
|
|
26488
|
+
return '${true}';
|
|
26489
|
+
case 'falso':
|
|
26490
|
+
return '${false}';
|
|
26491
|
+
case 'nulo':
|
|
26492
|
+
return '${null}';
|
|
26493
|
+
default:
|
|
26494
|
+
return match;
|
|
26467
26495
|
}
|
|
26468
26496
|
});
|
|
26469
26497
|
return possuiInterpolacao ? `\`${valor}\`` : `'${literal.valor}'`;
|
|
@@ -26477,13 +26505,13 @@ class TradutorJavaScript {
|
|
|
26477
26505
|
const argumentoResolvido = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
26478
26506
|
argumentosResolvidos.push(argumentoResolvido);
|
|
26479
26507
|
}
|
|
26480
|
-
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => atual += proximo + ', ',
|
|
26508
|
+
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => (atual += proximo + ', '), '');
|
|
26481
26509
|
textoArgumentos = textoArgumentos.slice(0, -2);
|
|
26482
26510
|
switch (variavel.simbolo.lexema) {
|
|
26483
26511
|
case 'texto':
|
|
26484
26512
|
return `String(${textoArgumentos})`;
|
|
26485
26513
|
default:
|
|
26486
|
-
const buscaClasseCorrespondente = this.declaracoesDeClasses.filter(d => d.simbolo.lexema === variavel.simbolo.lexema);
|
|
26514
|
+
const buscaClasseCorrespondente = this.declaracoesDeClasses.filter((d) => d.simbolo.lexema === variavel.simbolo.lexema);
|
|
26487
26515
|
if (buscaClasseCorrespondente.length === 0 && argumentosValidados.length === 0) {
|
|
26488
26516
|
return `${variavel.simbolo.lexema}`;
|
|
26489
26517
|
}
|
|
@@ -26571,7 +26599,8 @@ class TradutorJavaScript {
|
|
|
26571
26599
|
case 'Retorna':
|
|
26572
26600
|
const declaracaoRetorna = declaracao;
|
|
26573
26601
|
resultado +=
|
|
26574
|
-
'return ' +
|
|
26602
|
+
'return ' +
|
|
26603
|
+
this.dicionarioConstrutos[declaracaoRetorna.valor.constructor.name](declaracaoRetorna.valor);
|
|
26575
26604
|
break;
|
|
26576
26605
|
default:
|
|
26577
26606
|
resultado += this.dicionarioDeclaracoes[declaracao.constructor.name](declaracao) + '\n';
|
|
@@ -26766,7 +26795,7 @@ class TradutorJavaScript {
|
|
|
26766
26795
|
}
|
|
26767
26796
|
// TODO: Talvez terminar (ou remover, sei lá).
|
|
26768
26797
|
traduzirFuncaoAnonimaParaLambda(argumento) {
|
|
26769
|
-
return
|
|
26798
|
+
return '';
|
|
26770
26799
|
}
|
|
26771
26800
|
traduzirAcessoMetodoVetor(objeto, nomeMetodo, argumentos) {
|
|
26772
26801
|
const objetoResolvido = this.dicionarioConstrutos[objeto.constructor.name](objeto);
|
|
@@ -26778,7 +26807,7 @@ class TradutorJavaScript {
|
|
|
26778
26807
|
switch (nomeMetodo) {
|
|
26779
26808
|
case 'adicionar':
|
|
26780
26809
|
case 'empilhar':
|
|
26781
|
-
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => atual += proximo + ', ',
|
|
26810
|
+
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => (atual += proximo + ', '), '');
|
|
26782
26811
|
textoArgumentos = textoArgumentos.slice(0, -2);
|
|
26783
26812
|
return `${objetoResolvido}.push(${textoArgumentos})`;
|
|
26784
26813
|
case 'fatiar':
|
|
@@ -26879,7 +26908,7 @@ class TradutorJavaScript {
|
|
|
26879
26908
|
const argumentoResolvido = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
26880
26909
|
argumentosResolvidos.push(argumentoResolvido);
|
|
26881
26910
|
}
|
|
26882
|
-
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => atual += proximo + ', ',
|
|
26911
|
+
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => (atual += proximo + ', '), '');
|
|
26883
26912
|
textoArgumentos = textoArgumentos.slice(0, -2);
|
|
26884
26913
|
return `${argumentoReferenciaFuncao.simboloFuncao.lexema}(${textoArgumentos})`;
|
|
26885
26914
|
}
|
|
@@ -26889,7 +26918,7 @@ class TradutorJavaScript {
|
|
|
26889
26918
|
const argumentoResolvido = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
26890
26919
|
argumentosResolvidos.push(argumentoResolvido);
|
|
26891
26920
|
}
|
|
26892
|
-
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => atual += proximo + ', ',
|
|
26921
|
+
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => (atual += proximo + ', '), '');
|
|
26893
26922
|
textoArgumentos = textoArgumentos.slice(0, -2);
|
|
26894
26923
|
return `${referenciaFuncao.simboloFuncao.lexema}(${textoArgumentos})`;
|
|
26895
26924
|
}
|
|
@@ -27011,7 +27040,7 @@ class TradutorMermaidJs {
|
|
|
27011
27040
|
Literal: this.traduzirConstrutoLiteral.bind(this),
|
|
27012
27041
|
Unario: this.traduzirConstrutoUnario.bind(this),
|
|
27013
27042
|
Variavel: this.traduzirConstrutoVariavel.bind(this),
|
|
27014
|
-
Vetor: this.traduzirConstrutoVetor.bind(this)
|
|
27043
|
+
Vetor: this.traduzirConstrutoVetor.bind(this),
|
|
27015
27044
|
};
|
|
27016
27045
|
this.dicionarioDeclaracoes = {
|
|
27017
27046
|
Bloco: this.traduzirDeclaracaoBloco.bind(this),
|
|
@@ -27024,7 +27053,7 @@ class TradutorMermaidJs {
|
|
|
27024
27053
|
Para: this.traduzirDeclaracaoPara.bind(this),
|
|
27025
27054
|
ParaCada: this.traduzirDeclaracaoParaCada.bind(this),
|
|
27026
27055
|
Se: this.traduzirDeclaracaoSe.bind(this),
|
|
27027
|
-
Var: this.traduzirDeclaracaoVar.bind(this)
|
|
27056
|
+
Var: this.traduzirDeclaracaoVar.bind(this),
|
|
27028
27057
|
};
|
|
27029
27058
|
}
|
|
27030
27059
|
traduzirConstrutoAcessoIndiceVariavel(acessoIndiceVariavel) {
|
|
@@ -27057,7 +27086,7 @@ class TradutorMermaidJs {
|
|
|
27057
27086
|
case delegua_1.default.MENOR:
|
|
27058
27087
|
return `${operandoEsquerdo} for menor que ${operandoDireito}`;
|
|
27059
27088
|
}
|
|
27060
|
-
return
|
|
27089
|
+
return '';
|
|
27061
27090
|
}
|
|
27062
27091
|
traduzirConstrutoChamada(chamada) {
|
|
27063
27092
|
const textoEntidadeChamada = this.dicionarioConstrutos[chamada.entidadeChamada.constructor.name](chamada.entidadeChamada);
|
|
@@ -27097,7 +27126,7 @@ class TradutorMermaidJs {
|
|
|
27097
27126
|
return `função`;
|
|
27098
27127
|
}
|
|
27099
27128
|
traduzirConstrutoLeia(leia) {
|
|
27100
|
-
let texto =
|
|
27129
|
+
let texto = 'leia da entrada';
|
|
27101
27130
|
if (leia.argumentos && leia.argumentos.length > 0) {
|
|
27102
27131
|
const textoArgumento = this.dicionarioConstrutos[leia.argumentos[0].constructor.name](leia.argumentos[0]);
|
|
27103
27132
|
texto += `, imprimindo antes: \\'${textoArgumento}\\'`;
|
|
@@ -27116,7 +27145,7 @@ class TradutorMermaidJs {
|
|
|
27116
27145
|
}
|
|
27117
27146
|
traduzirConstrutoUnario(unario) {
|
|
27118
27147
|
const textoOperando = this.dicionarioConstrutos[unario.operando.constructor.name](unario.operando);
|
|
27119
|
-
let textoOperador =
|
|
27148
|
+
let textoOperador = '';
|
|
27120
27149
|
switch (unario.operador.tipo) {
|
|
27121
27150
|
case delegua_1.default.INCREMENTAR:
|
|
27122
27151
|
textoOperador = `incrementar ${textoOperando} em 1`;
|
|
@@ -27126,9 +27155,9 @@ class TradutorMermaidJs {
|
|
|
27126
27155
|
break;
|
|
27127
27156
|
}
|
|
27128
27157
|
switch (unario.incidenciaOperador) {
|
|
27129
|
-
case
|
|
27158
|
+
case 'ANTES':
|
|
27130
27159
|
return `${textoOperador}, devolver valor de ${textoOperando}`;
|
|
27131
|
-
case
|
|
27160
|
+
case 'DEPOIS':
|
|
27132
27161
|
return `devolver valor de ${textoOperando}, ${textoOperador}`;
|
|
27133
27162
|
}
|
|
27134
27163
|
}
|
|
@@ -27216,7 +27245,7 @@ class TradutorMermaidJs {
|
|
|
27216
27245
|
this.anteriores.pop();
|
|
27217
27246
|
return {
|
|
27218
27247
|
caminho: arestaCondicaoCaminho,
|
|
27219
|
-
declaracoesCaminho: verticesResolvidos
|
|
27248
|
+
declaracoesCaminho: verticesResolvidos,
|
|
27220
27249
|
};
|
|
27221
27250
|
}
|
|
27222
27251
|
traduzirDeclaracaoEscolha(declaracaoEscolha) {
|
|
@@ -27570,7 +27599,7 @@ class TradutorPython {
|
|
|
27570
27599
|
const argumentoResolvido = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
27571
27600
|
argumentosResolvidos.push(argumentoResolvido);
|
|
27572
27601
|
}
|
|
27573
|
-
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => atual += proximo + ', ',
|
|
27602
|
+
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => (atual += proximo + ', '), '');
|
|
27574
27603
|
textoArgumentos = textoArgumentos.slice(0, -2);
|
|
27575
27604
|
switch (nomeMetodo) {
|
|
27576
27605
|
case 'adicionar':
|
|
@@ -27632,7 +27661,7 @@ class TradutorPython {
|
|
|
27632
27661
|
}
|
|
27633
27662
|
// TODO: Talvez terminar (ou remover, sei lá).
|
|
27634
27663
|
traduzirFuncaoAnonimaParaLambda(argumento) {
|
|
27635
|
-
return
|
|
27664
|
+
return '';
|
|
27636
27665
|
}
|
|
27637
27666
|
traduzirAcessoMetodoVetor(objeto, nomeMetodo, argumentos) {
|
|
27638
27667
|
const objetoResolvido = this.dicionarioConstrutos[objeto.constructor.name](objeto);
|
|
@@ -27644,7 +27673,7 @@ class TradutorPython {
|
|
|
27644
27673
|
switch (nomeMetodo) {
|
|
27645
27674
|
case 'adicionar':
|
|
27646
27675
|
case 'empilhar':
|
|
27647
|
-
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => atual += proximo + ', ',
|
|
27676
|
+
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => (atual += proximo + ', '), '');
|
|
27648
27677
|
textoArgumentos = textoArgumentos.slice(0, -2);
|
|
27649
27678
|
return `${objetoResolvido}.append(${textoArgumentos})`;
|
|
27650
27679
|
case 'fatiar':
|
|
@@ -27709,7 +27738,7 @@ class TradutorPython {
|
|
|
27709
27738
|
const argumentoResolvido = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
27710
27739
|
argumentosResolvidos.push(argumentoResolvido);
|
|
27711
27740
|
}
|
|
27712
|
-
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => atual += proximo + ', ',
|
|
27741
|
+
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => (atual += proximo + ', '), '');
|
|
27713
27742
|
textoArgumentos = textoArgumentos.slice(0, -2);
|
|
27714
27743
|
return `${argumentoReferenciaFuncao.simboloFuncao.lexema}(${textoArgumentos})`;
|
|
27715
27744
|
}
|
|
@@ -27814,7 +27843,7 @@ class TradutorPython {
|
|
|
27814
27843
|
const argumentoResolvido = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
27815
27844
|
argumentosResolvidos.push(argumentoResolvido);
|
|
27816
27845
|
}
|
|
27817
|
-
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => atual += proximo + ', ',
|
|
27846
|
+
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => (atual += proximo + ', '), '');
|
|
27818
27847
|
textoArgumentos = textoArgumentos.slice(0, -2);
|
|
27819
27848
|
return `${referenciaFuncao.simboloFuncao.lexema}(${textoArgumentos})`;
|
|
27820
27849
|
}
|
|
@@ -27835,7 +27864,7 @@ class TradutorPython {
|
|
|
27835
27864
|
const argumentoResolvido = this.dicionarioConstrutos[argumento.constructor.name](argumento);
|
|
27836
27865
|
argumentosResolvidos.push(argumentoResolvido);
|
|
27837
27866
|
}
|
|
27838
|
-
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => atual += proximo + ', ',
|
|
27867
|
+
let textoArgumentos = argumentosResolvidos.reduce((atual, proximo) => (atual += proximo + ', '), '');
|
|
27839
27868
|
textoArgumentos = textoArgumentos.slice(0, -2);
|
|
27840
27869
|
switch (variavel.simbolo.lexema) {
|
|
27841
27870
|
case 'texto':
|