@designliquido/delegua 0.39.3 → 0.39.5
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/README.md +21 -9
- package/avaliador-sintatico/avaliador-sintatico.d.ts +10 -1
- package/avaliador-sintatico/avaliador-sintatico.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.js +93 -57
- package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts +1 -0
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js +7 -4
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.js +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts +1 -0
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +6 -5
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js.map +1 -1
- package/avaliador-sintatico/index.d.ts +1 -0
- package/avaliador-sintatico/index.d.ts.map +1 -1
- package/avaliador-sintatico/index.js +1 -0
- package/avaliador-sintatico/index.js.map +1 -1
- package/bibliotecas/dialetos/egua-classico/index.d.ts.map +1 -1
- package/bin/package.json +26 -26
- package/construtos/super.d.ts +2 -2
- package/construtos/super.d.ts.map +1 -1
- package/construtos/super.js +2 -2
- package/construtos/super.js.map +1 -1
- package/estruturas/delegua-funcao.d.ts +2 -0
- package/estruturas/delegua-funcao.d.ts.map +1 -1
- package/estruturas/delegua-funcao.js +5 -1
- package/estruturas/delegua-funcao.js.map +1 -1
- package/estruturas/descritor-tipo-classe.js +1 -1
- package/estruturas/descritor-tipo-classe.js.map +1 -1
- package/formatadores/formatador-delegua.d.ts.map +1 -1
- package/formatadores/formatador-delegua.js +1 -3
- package/formatadores/formatador-delegua.js.map +1 -1
- package/formatadores/formatador-pitugues.d.ts +62 -0
- package/formatadores/formatador-pitugues.d.ts.map +1 -0
- package/formatadores/formatador-pitugues.js +172 -0
- package/formatadores/formatador-pitugues.js.map +1 -0
- package/interpretador/comum.js +17 -7
- package/interpretador/comum.js.map +1 -1
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.d.ts.map +1 -1
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.js +2 -8
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.js.map +1 -1
- package/interpretador/interpretador-base.d.ts +2 -8
- package/interpretador/interpretador-base.d.ts.map +1 -1
- package/interpretador/interpretador-base.js +10 -41
- package/interpretador/interpretador-base.js.map +1 -1
- package/package.json +26 -26
- package/tradutores/python/python3-lexer.js +17 -7
- package/tradutores/python/python3-lexer.js.map +1 -1
- package/tradutores/python/python3-parser.js +17 -7
- package/tradutores/python/python3-parser.js.map +1 -1
- package/tradutores/tradutor-assemblyscript.js +1 -1
- package/tradutores/tradutor-assemblyscript.js.map +1 -1
- package/umd/delegua.js +180 -138
package/umd/delegua.js
CHANGED
|
@@ -243,7 +243,6 @@ const construtos_1 = require("../construtos");
|
|
|
243
243
|
const erro_avaliador_sintatico_1 = require("./erro-avaliador-sintatico");
|
|
244
244
|
const tuplas_1 = require("../construtos/tuplas");
|
|
245
245
|
const declaracoes_1 = require("../declaracoes");
|
|
246
|
-
const lexador_1 = require("../lexador");
|
|
247
246
|
const avaliador_sintatico_base_1 = require("./avaliador-sintatico-base");
|
|
248
247
|
const inferenciador_1 = require("../inferenciador");
|
|
249
248
|
const pilha_escopos_1 = require("./pilha-escopos");
|
|
@@ -430,18 +429,36 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
430
429
|
return new construtos_1.Agrupamento(this.hashArquivo, Number(simboloAtual.linha), expressao);
|
|
431
430
|
case delegua_2.default.SUPER:
|
|
432
431
|
const simboloSuper = this.avancarEDevolverAnterior();
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
// Se o próximo símbolo for um ponto, significa que é uma chamada
|
|
436
|
-
// a um método da superclasse.
|
|
437
|
-
switch (this.simbolos[this.atual].tipo) {
|
|
438
|
-
case delegua_2.default.PARENTESE_ESQUERDO:
|
|
439
|
-
return new construtos_1.Super(this.hashArquivo, simboloSuper, new lexador_1.Simbolo(delegua_2.default.IDENTIFICADOR, 'construtor', null, simboloSuper.linha, this.hashArquivo));
|
|
440
|
-
default:
|
|
441
|
-
this.consumir(delegua_2.default.PONTO, "Esperado '.' após 'super'.");
|
|
442
|
-
const metodoSuperclasse = this.consumir(delegua_2.default.IDENTIFICADOR, 'Esperado nome do método da Superclasse.');
|
|
443
|
-
return new construtos_1.Super(this.hashArquivo, simboloSuper, metodoSuperclasse);
|
|
432
|
+
if (!this.superclasseAtual) {
|
|
433
|
+
throw this.erro(this.simbolos[this.atual], "'Super' usado fora de declaração de classe com herança.");
|
|
444
434
|
}
|
|
435
|
+
return new construtos_1.Super(this.hashArquivo, simboloSuper, this.superclasseAtual);
|
|
436
|
+
/* Se o próximo símbolo for uma abertura de parênteses, significa que
|
|
437
|
+
// é uma chamada ao construtor da classe ancestral (superclasse).
|
|
438
|
+
// Se o próximo símbolo for um ponto, significa que é uma chamada
|
|
439
|
+
// a um método da superclasse.
|
|
440
|
+
switch (this.simbolos[this.atual].tipo) {
|
|
441
|
+
case tiposDeSimbolos.PARENTESE_ESQUERDO:
|
|
442
|
+
return new Super(
|
|
443
|
+
this.hashArquivo,
|
|
444
|
+
simboloSuper,
|
|
445
|
+
new Simbolo(
|
|
446
|
+
tiposDeSimbolos.IDENTIFICADOR,
|
|
447
|
+
'construtor',
|
|
448
|
+
null,
|
|
449
|
+
simboloSuper.linha,
|
|
450
|
+
this.hashArquivo
|
|
451
|
+
)
|
|
452
|
+
);
|
|
453
|
+
default:
|
|
454
|
+
this.consumir(tiposDeSimbolos.PONTO, "Esperado '.' após 'super'.");
|
|
455
|
+
const metodoSuperclasse = this.consumir(
|
|
456
|
+
tiposDeSimbolos.IDENTIFICADOR,
|
|
457
|
+
'Esperado nome do método da Superclasse.'
|
|
458
|
+
);
|
|
459
|
+
// TODO: Validar se o método existe no ancestral.
|
|
460
|
+
return new Super(this.hashArquivo, simboloSuper, metodoSuperclasse);
|
|
461
|
+
} */
|
|
445
462
|
case delegua_2.default.VERDADEIRO:
|
|
446
463
|
this.avancarEDevolverAnterior();
|
|
447
464
|
return new construtos_1.Literal(this.hashArquivo, Number(simboloAtual.linha), true, 'lógico');
|
|
@@ -549,6 +566,49 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
549
566
|
}
|
|
550
567
|
return expressao;
|
|
551
568
|
}
|
|
569
|
+
/**
|
|
570
|
+
* `AcessoMetodoOuPropriedade` é um construto intermediário em Delégua, e deve ser resolvido como outro
|
|
571
|
+
* construto antes de qualquer outra próxima etapa. Algumas validações adicionais também ocorrem aqui.
|
|
572
|
+
* @param {AcessoMetodoOuPropriedade} entidadeChamadaResolvida O construto original.
|
|
573
|
+
* @returns {Construto} O construto resolvido como um tipo mais específico.
|
|
574
|
+
* @see finalizarChamada
|
|
575
|
+
*/
|
|
576
|
+
resolverEntidadeChamadaAcessoMetodoOuPropriedade(entidadeChamadaResolvida) {
|
|
577
|
+
const construtoTipado = entidadeChamadaResolvida;
|
|
578
|
+
switch (entidadeChamadaResolvida.tipo) {
|
|
579
|
+
case delegua_1.default.DICIONARIO:
|
|
580
|
+
case delegua_1.default.DICIONÁRIO:
|
|
581
|
+
if (!(construtoTipado.simbolo.lexema in primitivas_dicionario_1.default)) {
|
|
582
|
+
throw this.erro(construtoTipado.simbolo, `${construtoTipado.simbolo.lexema} não é uma primitiva de dicionário.`);
|
|
583
|
+
}
|
|
584
|
+
const primitivaDicionarioSelecionada = primitivas_dicionario_1.default[construtoTipado.simbolo.lexema];
|
|
585
|
+
return new construtos_1.AcessoMetodo(construtoTipado.hashArquivo, construtoTipado.objeto, construtoTipado.simbolo.lexema, primitivaDicionarioSelecionada.tipoRetorno);
|
|
586
|
+
case delegua_1.default.INTEIRO:
|
|
587
|
+
case delegua_1.default.NUMERO:
|
|
588
|
+
case delegua_1.default.NÚMERO:
|
|
589
|
+
if (!(construtoTipado.simbolo.lexema in primitivas_numero_1.default)) {
|
|
590
|
+
throw this.erro(construtoTipado.simbolo, `${construtoTipado.simbolo.lexema} não é uma primitiva de número.`);
|
|
591
|
+
}
|
|
592
|
+
const primitivaNumeroSelecionada = primitivas_numero_1.default[construtoTipado.simbolo.lexema];
|
|
593
|
+
return new construtos_1.AcessoMetodo(construtoTipado.hashArquivo, construtoTipado.objeto, construtoTipado.simbolo.lexema, primitivaNumeroSelecionada.tipoRetorno);
|
|
594
|
+
case delegua_1.default.TEXTO:
|
|
595
|
+
if (!(construtoTipado.simbolo.lexema in primitivas_texto_1.default)) {
|
|
596
|
+
throw this.erro(construtoTipado.simbolo, `${construtoTipado.simbolo.lexema} não é uma primitiva de texto.`);
|
|
597
|
+
}
|
|
598
|
+
const primitivaTextoSelecionada = primitivas_texto_1.default[construtoTipado.simbolo.lexema];
|
|
599
|
+
return new construtos_1.AcessoMetodo(construtoTipado.hashArquivo, construtoTipado.objeto, construtoTipado.simbolo.lexema, primitivaTextoSelecionada.tipoRetorno);
|
|
600
|
+
case delegua_1.default.VETOR:
|
|
601
|
+
case delegua_1.default.VETOR_NUMERO:
|
|
602
|
+
case delegua_1.default.VETOR_NÚMERO:
|
|
603
|
+
case delegua_1.default.VETOR_TEXTO:
|
|
604
|
+
if (!(construtoTipado.simbolo.lexema in primitivas_vetor_1.default)) {
|
|
605
|
+
throw this.erro(construtoTipado.simbolo, `${construtoTipado.simbolo.lexema} não é uma primitiva de vetor.`);
|
|
606
|
+
}
|
|
607
|
+
const primitivaVetorSelecionada = primitivas_vetor_1.default[construtoTipado.simbolo.lexema];
|
|
608
|
+
return new construtos_1.AcessoMetodo(construtoTipado.hashArquivo, construtoTipado.objeto, construtoTipado.simbolo.lexema, primitivaVetorSelecionada.tipoRetorno);
|
|
609
|
+
}
|
|
610
|
+
return entidadeChamadaResolvida;
|
|
611
|
+
}
|
|
552
612
|
finalizarChamada(entidadeChamada) {
|
|
553
613
|
const argumentos = [];
|
|
554
614
|
if (!this.verificarTipoSimboloAtual(delegua_2.default.PARENTESE_DIREITO)) {
|
|
@@ -564,44 +624,9 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
564
624
|
// Toda chamada precisa saber de antemão qual o tipo resolvido.
|
|
565
625
|
let entidadeChamadaResolvida = entidadeChamada;
|
|
566
626
|
if (entidadeChamadaResolvida.constructor.name === 'AcessoMetodoOuPropriedade') {
|
|
567
|
-
|
|
568
|
-
switch (entidadeChamadaResolvida.tipo) {
|
|
569
|
-
case delegua_1.default.DICIONARIO:
|
|
570
|
-
case delegua_1.default.DICIONÁRIO:
|
|
571
|
-
if (!(construtoTipado.simbolo.lexema in primitivas_dicionario_1.default)) {
|
|
572
|
-
throw this.erro(construtoTipado.simbolo, `${construtoTipado.simbolo.lexema} não é uma primitiva de dicionário.`);
|
|
573
|
-
}
|
|
574
|
-
const primitivaDicionarioSelecionada = primitivas_dicionario_1.default[construtoTipado.simbolo.lexema];
|
|
575
|
-
entidadeChamadaResolvida = new construtos_1.AcessoMetodo(construtoTipado.hashArquivo, construtoTipado.objeto, construtoTipado.simbolo.lexema, primitivaDicionarioSelecionada.tipoRetorno);
|
|
576
|
-
break;
|
|
577
|
-
case delegua_1.default.INTEIRO:
|
|
578
|
-
case delegua_1.default.NUMERO:
|
|
579
|
-
case delegua_1.default.NÚMERO:
|
|
580
|
-
if (!(construtoTipado.simbolo.lexema in primitivas_numero_1.default)) {
|
|
581
|
-
throw this.erro(construtoTipado.simbolo, `${construtoTipado.simbolo.lexema} não é uma primitiva de número.`);
|
|
582
|
-
}
|
|
583
|
-
const primitivaNumeroSelecionada = primitivas_numero_1.default[construtoTipado.simbolo.lexema];
|
|
584
|
-
entidadeChamadaResolvida = new construtos_1.AcessoMetodo(construtoTipado.hashArquivo, construtoTipado.objeto, construtoTipado.simbolo.lexema, primitivaNumeroSelecionada.tipoRetorno);
|
|
585
|
-
break;
|
|
586
|
-
case delegua_1.default.TEXTO:
|
|
587
|
-
if (!(construtoTipado.simbolo.lexema in primitivas_texto_1.default)) {
|
|
588
|
-
throw this.erro(construtoTipado.simbolo, `${construtoTipado.simbolo.lexema} não é uma primitiva de texto.`);
|
|
589
|
-
}
|
|
590
|
-
const primitivaTextoSelecionada = primitivas_texto_1.default[construtoTipado.simbolo.lexema];
|
|
591
|
-
entidadeChamadaResolvida = new construtos_1.AcessoMetodo(construtoTipado.hashArquivo, construtoTipado.objeto, construtoTipado.simbolo.lexema, primitivaTextoSelecionada.tipoRetorno);
|
|
592
|
-
break;
|
|
593
|
-
case delegua_1.default.VETOR:
|
|
594
|
-
case delegua_1.default.VETOR_NUMERO:
|
|
595
|
-
case delegua_1.default.VETOR_NÚMERO:
|
|
596
|
-
case delegua_1.default.VETOR_TEXTO:
|
|
597
|
-
if (!(construtoTipado.simbolo.lexema in primitivas_vetor_1.default)) {
|
|
598
|
-
throw this.erro(construtoTipado.simbolo, `${construtoTipado.simbolo.lexema} não é uma primitiva de vetor.`);
|
|
599
|
-
}
|
|
600
|
-
const primitivaVetorSelecionada = primitivas_vetor_1.default[construtoTipado.simbolo.lexema];
|
|
601
|
-
entidadeChamadaResolvida = new construtos_1.AcessoMetodo(construtoTipado.hashArquivo, construtoTipado.objeto, construtoTipado.simbolo.lexema, primitivaVetorSelecionada.tipoRetorno);
|
|
602
|
-
break;
|
|
603
|
-
}
|
|
627
|
+
entidadeChamadaResolvida = this.resolverEntidadeChamadaAcessoMetodoOuPropriedade(entidadeChamadaResolvida);
|
|
604
628
|
}
|
|
629
|
+
// TODO: Criar forma de validar tipos dos argumentos da entidade chamada.
|
|
605
630
|
return new construtos_1.Chamada(this.hashArquivo, entidadeChamadaResolvida, argumentos);
|
|
606
631
|
}
|
|
607
632
|
unario() {
|
|
@@ -727,14 +752,22 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
727
752
|
else if (this.verificarSeSimboloAtualEIgualA(delegua_2.default.IGUAL)) {
|
|
728
753
|
const igual = this.simbolos[this.atual - 1];
|
|
729
754
|
const valor = this.expressao();
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
755
|
+
switch (expressao.constructor.name) {
|
|
756
|
+
case 'Variavel':
|
|
757
|
+
return new construtos_1.Atribuir(this.hashArquivo, expressao, valor);
|
|
758
|
+
case 'AcessoMetodoOuPropriedade':
|
|
759
|
+
const expressaoAcessoMetodoOuPropriedade = expressao;
|
|
760
|
+
return new construtos_1.DefinirValor(this.hashArquivo, igual.linha, expressaoAcessoMetodoOuPropriedade.objeto, expressaoAcessoMetodoOuPropriedade.simbolo, valor);
|
|
761
|
+
/* case 'Super':
|
|
762
|
+
const expressaoSuper = expressao as Super;
|
|
763
|
+
return new DefinirValor(
|
|
764
|
+
this.hashArquivo,
|
|
765
|
+
igual.linha,
|
|
766
|
+
expressaoSuper.
|
|
767
|
+
); */
|
|
768
|
+
case 'AcessoIndiceVariavel':
|
|
769
|
+
const expressaoAcessoIndiceVariavel = expressao;
|
|
770
|
+
return new construtos_1.AtribuicaoPorIndice(this.hashArquivo, expressaoAcessoIndiceVariavel.linha, expressaoAcessoIndiceVariavel.entidadeChamada, expressaoAcessoIndiceVariavel.indice, valor);
|
|
738
771
|
}
|
|
739
772
|
throw this.erro(igual, 'Tarefa de atribuição inválida');
|
|
740
773
|
}
|
|
@@ -1480,6 +1513,8 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
1480
1513
|
let superClasse = null;
|
|
1481
1514
|
if (this.verificarSeSimboloAtualEIgualA(delegua_2.default.HERDA)) {
|
|
1482
1515
|
const simboloSuperclasse = this.consumir(delegua_2.default.IDENTIFICADOR, 'Esperado nome da Superclasse.');
|
|
1516
|
+
// TODO: Validar classes existentes?
|
|
1517
|
+
this.superclasseAtual = simboloSuperclasse.lexema;
|
|
1483
1518
|
// TODO: Colocar tipo aqui?
|
|
1484
1519
|
superClasse = new construtos_1.Variavel(this.hashArquivo, this.simbolos[this.atual - 1], simboloSuperclasse.lexema);
|
|
1485
1520
|
}
|
|
@@ -1516,6 +1551,7 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
1516
1551
|
this.consumir(delegua_2.default.CHAVE_DIREITA, "Esperado '}' após o escopo da classe.");
|
|
1517
1552
|
const definicaoClasse = new declaracoes_1.Classe(simbolo, superClasse, metodos, propriedades, pilhaDecoradoresClasse);
|
|
1518
1553
|
this.tiposDefinidosEmCodigo[definicaoClasse.simbolo.lexema] = definicaoClasse;
|
|
1554
|
+
this.superclasseAtual = undefined;
|
|
1519
1555
|
return definicaoClasse;
|
|
1520
1556
|
}
|
|
1521
1557
|
/**
|
|
@@ -1630,7 +1666,7 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
1630
1666
|
}
|
|
1631
1667
|
exports.AvaliadorSintatico = AvaliadorSintatico;
|
|
1632
1668
|
|
|
1633
|
-
},{"../bibliotecas/primitivas-dicionario":18,"../bibliotecas/primitivas-numero":19,"../bibliotecas/primitivas-texto":20,"../bibliotecas/primitivas-vetor":21,"../construtos":44,"../construtos/tuplas":53,"../declaracoes":82,"../inferenciador":116,"../
|
|
1669
|
+
},{"../bibliotecas/primitivas-dicionario":18,"../bibliotecas/primitivas-numero":19,"../bibliotecas/primitivas-texto":20,"../bibliotecas/primitivas-vetor":21,"../construtos":44,"../construtos/tuplas":53,"../declaracoes":82,"../inferenciador":116,"../tipos-de-dados/delegua":161,"../tipos-de-simbolos/delegua":164,"./avaliador-sintatico-base":1,"./erro-avaliador-sintatico":7,"./informacao-escopo":9,"./pilha-escopos":12,"browser-process-hrtime":340}],3:[function(require,module,exports){
|
|
1634
1670
|
"use strict";
|
|
1635
1671
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1636
1672
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -1732,9 +1768,10 @@ class AvaliadorSintaticoEguaClassico {
|
|
|
1732
1768
|
primario() {
|
|
1733
1769
|
if (this.verificarSeSimboloAtualEIgualA(egua_classico_1.default.SUPER)) {
|
|
1734
1770
|
const simboloChave = this.simboloAnterior();
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1771
|
+
return new construtos_1.Super(this.hashArquivo, simboloChave, this.superclasseAtual);
|
|
1772
|
+
/* this.consumir(tiposDeSimbolos.PONTO, "Esperado '.' após 'super'.");
|
|
1773
|
+
const metodo = this.consumir(tiposDeSimbolos.IDENTIFICADOR, 'Esperado nome do método da Superclasse.');
|
|
1774
|
+
return new Super(this.hashArquivo, simboloChave, metodo); */
|
|
1738
1775
|
}
|
|
1739
1776
|
if (this.verificarSeSimboloAtualEIgualA(egua_classico_1.default.COLCHETE_ESQUERDO)) {
|
|
1740
1777
|
const valores = [];
|
|
@@ -2232,7 +2269,8 @@ class AvaliadorSintaticoEguaClassico {
|
|
|
2232
2269
|
const nome = this.consumir(egua_classico_1.default.IDENTIFICADOR, 'Esperado nome da classe.');
|
|
2233
2270
|
let superClasse = null;
|
|
2234
2271
|
if (this.verificarSeSimboloAtualEIgualA(egua_classico_1.default.HERDA)) {
|
|
2235
|
-
this.consumir(egua_classico_1.default.IDENTIFICADOR, 'Esperado nome da Superclasse.');
|
|
2272
|
+
const simboloSuperclasse = this.consumir(egua_classico_1.default.IDENTIFICADOR, 'Esperado nome da Superclasse.');
|
|
2273
|
+
this.superclasseAtual = simboloSuperclasse.lexema;
|
|
2236
2274
|
superClasse = new construtos_1.Variavel(this.hashArquivo, this.simboloAnterior());
|
|
2237
2275
|
}
|
|
2238
2276
|
this.consumir(egua_classico_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo da classe.");
|
|
@@ -2241,6 +2279,7 @@ class AvaliadorSintaticoEguaClassico {
|
|
|
2241
2279
|
metodos.push(this.funcao('método'));
|
|
2242
2280
|
}
|
|
2243
2281
|
this.consumir(egua_classico_1.default.CHAVE_DIREITA, "Esperado '}' após o escopo da classe.");
|
|
2282
|
+
this.superclasseAtual = undefined;
|
|
2244
2283
|
return new declaracoes_1.Classe(nome, superClasse, metodos);
|
|
2245
2284
|
}
|
|
2246
2285
|
resolverDeclaracaoForaDeBloco() {
|
|
@@ -2326,7 +2365,6 @@ class AvaliadorSintaticoPitugues {
|
|
|
2326
2365
|
this.verificarSeSimboloAtualEIgualA(pitugues_1.default.PONTO_E_VIRGULA);
|
|
2327
2366
|
return retorno;
|
|
2328
2367
|
}
|
|
2329
|
-
//this.consumir(tiposDeSimbolos.IGUAL, "Esperado '=' após identificador em instrução 'var'.");
|
|
2330
2368
|
const inicializadores = [];
|
|
2331
2369
|
do {
|
|
2332
2370
|
inicializadores.push(this.expressao());
|
|
@@ -2408,9 +2446,9 @@ class AvaliadorSintaticoPitugues {
|
|
|
2408
2446
|
primario() {
|
|
2409
2447
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_1.default.SUPER)) {
|
|
2410
2448
|
const simboloChave = this.simboloAnterior();
|
|
2411
|
-
this.consumir(
|
|
2412
|
-
const metodo = this.consumir(
|
|
2413
|
-
return new construtos_1.Super(this.hashArquivo, simboloChave,
|
|
2449
|
+
/* this.consumir(tiposDeSimbolos.PONTO, "Esperado '.' após 'super'.");
|
|
2450
|
+
const metodo = this.consumir(tiposDeSimbolos.IDENTIFICADOR, 'Esperado nome do método da Superclasse.'); */
|
|
2451
|
+
return new construtos_1.Super(this.hashArquivo, simboloChave, this.superclassseAtual);
|
|
2414
2452
|
}
|
|
2415
2453
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_1.default.COLCHETE_ESQUERDO)) {
|
|
2416
2454
|
const valores = [];
|
|
@@ -2981,7 +3019,8 @@ class AvaliadorSintaticoPitugues {
|
|
|
2981
3019
|
const simbolo = this.consumir(pitugues_1.default.IDENTIFICADOR, 'Esperado nome da classe.');
|
|
2982
3020
|
let superClasse = null;
|
|
2983
3021
|
if (this.verificarSeSimboloAtualEIgualA(pitugues_1.default.HERDA)) {
|
|
2984
|
-
this.consumir(pitugues_1.default.IDENTIFICADOR, 'Esperado nome da Superclasse.');
|
|
3022
|
+
const simboloSuperclasse = this.consumir(pitugues_1.default.IDENTIFICADOR, 'Esperado nome da Superclasse.');
|
|
3023
|
+
this.superclassseAtual = simboloSuperclasse.lexema;
|
|
2985
3024
|
superClasse = new construtos_1.Variavel(this.hashArquivo, this.simboloAnterior());
|
|
2986
3025
|
}
|
|
2987
3026
|
this.consumir(pitugues_1.default.DOIS_PONTOS, "Esperado ':' antes do escopo da classe.");
|
|
@@ -2990,6 +3029,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
2990
3029
|
this.verificarSeSimboloAtualEIgualA(pitugues_1.default.CONSTRUTOR, pitugues_1.default.FUNCAO, pitugues_1.default.FUNÇÃO)) {
|
|
2991
3030
|
metodos.push(this.funcao('método', this.simbolos[this.atual - 1].tipo === pitugues_1.default.CONSTRUTOR));
|
|
2992
3031
|
}
|
|
3032
|
+
this.superclassseAtual = undefined;
|
|
2993
3033
|
return new declaracoes_1.Classe(simbolo, superClasse, metodos);
|
|
2994
3034
|
}
|
|
2995
3035
|
declaracaoFalhar() {
|
|
@@ -3275,9 +3315,10 @@ __exportStar(require("./avaliador-sintatico-base"), exports);
|
|
|
3275
3315
|
__exportStar(require("./dialetos"), exports);
|
|
3276
3316
|
__exportStar(require("./erro-avaliador-sintatico"), exports);
|
|
3277
3317
|
__exportStar(require("./micro-avaliador-sintatico"), exports);
|
|
3318
|
+
__exportStar(require("./pilha-escopos"), exports);
|
|
3278
3319
|
__exportStar(require("./retornos"), exports);
|
|
3279
3320
|
|
|
3280
|
-
},{"./avaliador-sintatico":2,"./avaliador-sintatico-base":1,"./dialetos":6,"./erro-avaliador-sintatico":7,"./micro-avaliador-sintatico":11,"./retornos":13}],9:[function(require,module,exports){
|
|
3321
|
+
},{"./avaliador-sintatico":2,"./avaliador-sintatico-base":1,"./dialetos":6,"./erro-avaliador-sintatico":7,"./micro-avaliador-sintatico":11,"./pilha-escopos":12,"./retornos":13}],9:[function(require,module,exports){
|
|
3281
3322
|
"use strict";
|
|
3282
3323
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3283
3324
|
exports.InformacaoEscopo = void 0;
|
|
@@ -5013,11 +5054,11 @@ exports.QualTipo = QualTipo;
|
|
|
5013
5054
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5014
5055
|
exports.Super = void 0;
|
|
5015
5056
|
class Super {
|
|
5016
|
-
constructor(hashArquivo, simboloChave,
|
|
5057
|
+
constructor(hashArquivo, simboloChave, superclasse) {
|
|
5017
5058
|
this.linha = Number(simboloChave.linha);
|
|
5018
5059
|
this.hashArquivo = hashArquivo;
|
|
5019
5060
|
this.simboloChave = simboloChave;
|
|
5020
|
-
this.
|
|
5061
|
+
this.superclasse = superclasse;
|
|
5021
5062
|
}
|
|
5022
5063
|
async aceitar(visitante) {
|
|
5023
5064
|
return Promise.resolve(visitante.visitarExpressaoSuper(this));
|
|
@@ -6210,7 +6251,7 @@ class DeleguaFuncao extends chamavel_1.Chamavel {
|
|
|
6210
6251
|
}
|
|
6211
6252
|
return argumentosResolvidos;
|
|
6212
6253
|
}
|
|
6213
|
-
|
|
6254
|
+
resolverAmbiente(argumentos) {
|
|
6214
6255
|
const ambiente = new espaco_variaveis_1.EspacoVariaveis();
|
|
6215
6256
|
const parametros = this.declaracao.parametros || [];
|
|
6216
6257
|
for (let i = 0; i < parametros.length; i++) {
|
|
@@ -6229,6 +6270,10 @@ class DeleguaFuncao extends chamavel_1.Chamavel {
|
|
|
6229
6270
|
ambiente.valores[nome] = argumento && argumento.hasOwnProperty('valor') ? argumento.valor : argumento;
|
|
6230
6271
|
}
|
|
6231
6272
|
}
|
|
6273
|
+
return ambiente;
|
|
6274
|
+
}
|
|
6275
|
+
async chamar(visitante, argumentos) {
|
|
6276
|
+
const ambiente = this.resolverAmbiente(argumentos);
|
|
6232
6277
|
if (this.instancia !== undefined) {
|
|
6233
6278
|
ambiente.valores['isto'] = {
|
|
6234
6279
|
valor: this.instancia,
|
|
@@ -6329,7 +6374,7 @@ class DescritorTipoClasse extends chamavel_1.Chamavel {
|
|
|
6329
6374
|
* @returns {string} A representação da classe como texto.
|
|
6330
6375
|
*/
|
|
6331
6376
|
paraTexto() {
|
|
6332
|
-
let texto = `<
|
|
6377
|
+
let texto = `<DescritorTipoClasse ${this.simboloOriginal.lexema}`;
|
|
6333
6378
|
for (let propriedade of this.propriedades) {
|
|
6334
6379
|
texto += ` ${propriedade.nome.lexema}`;
|
|
6335
6380
|
if (propriedade.tipo) {
|
|
@@ -7128,9 +7173,7 @@ class FormatadorDelegua {
|
|
|
7128
7173
|
this.codigoFormatado += `${this.quebraLinha}`;
|
|
7129
7174
|
}
|
|
7130
7175
|
visitarExpressaoSuper(expressao) {
|
|
7131
|
-
|
|
7132
|
-
this.codigoFormatado += `super.${expressao.metodo.lexema}()`;
|
|
7133
|
-
console.log(expressao);
|
|
7176
|
+
this.codigoFormatado += `super`;
|
|
7134
7177
|
}
|
|
7135
7178
|
visitarExpressaoSustar(declaracao) {
|
|
7136
7179
|
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}sustar${this.quebraLinha}`;
|
|
@@ -7694,13 +7737,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
7694
7737
|
}) : function(o, v) {
|
|
7695
7738
|
o["default"] = v;
|
|
7696
7739
|
});
|
|
7697
|
-
var __importStar = (this && this.__importStar) || function (
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
};
|
|
7740
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
7741
|
+
var ownKeys = function(o) {
|
|
7742
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
7743
|
+
var ar = [];
|
|
7744
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
7745
|
+
return ar;
|
|
7746
|
+
};
|
|
7747
|
+
return ownKeys(o);
|
|
7748
|
+
};
|
|
7749
|
+
return function (mod) {
|
|
7750
|
+
if (mod && mod.__esModule) return mod;
|
|
7751
|
+
var result = {};
|
|
7752
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
7753
|
+
__setModuleDefault(result, mod);
|
|
7754
|
+
return result;
|
|
7755
|
+
};
|
|
7756
|
+
})();
|
|
7704
7757
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7705
7758
|
exports.carregarBibliotecasGlobais = carregarBibliotecasGlobais;
|
|
7706
7759
|
const funcao_padrao_1 = require("../estruturas/funcao-padrao");
|
|
@@ -8239,20 +8292,6 @@ class InterpretadorBase {
|
|
|
8239
8292
|
}
|
|
8240
8293
|
return argumentos;
|
|
8241
8294
|
}
|
|
8242
|
-
/**
|
|
8243
|
-
* Resolve paraâmetros da chamada de acordo com o tipo da entidade chamada.
|
|
8244
|
-
* @param {Chamavel} entidadeChamada A entidade chamada.
|
|
8245
|
-
* @returns Os parâmetros resolvidos.
|
|
8246
|
-
*/
|
|
8247
|
-
resolverParametrosChamada(entidadeChamada) {
|
|
8248
|
-
if (entidadeChamada instanceof estruturas_1.DeleguaFuncao) {
|
|
8249
|
-
return entidadeChamada.declaracao.parametros;
|
|
8250
|
-
}
|
|
8251
|
-
if (entidadeChamada instanceof estruturas_1.DescritorTipoClasse) {
|
|
8252
|
-
return entidadeChamada.metodos.construtor ? entidadeChamada.metodos.construtor.declaracao.parametros : [];
|
|
8253
|
-
}
|
|
8254
|
-
return [];
|
|
8255
|
-
}
|
|
8256
8295
|
/**
|
|
8257
8296
|
* Executa uma chamada de função, método ou classe.
|
|
8258
8297
|
* @param expressao A expressão chamada.
|
|
@@ -8274,10 +8313,6 @@ class InterpretadorBase {
|
|
|
8274
8313
|
return await this.chamarMetodoPrimitiva(expressao, entidadeChamada);
|
|
8275
8314
|
}
|
|
8276
8315
|
const argumentos = await this.resolverArgumentosChamada(expressao);
|
|
8277
|
-
// TODO: Aparentemente isso nunca é usado se o bloco de resolução de parâmetros,
|
|
8278
|
-
// mais abaixo, também não é.
|
|
8279
|
-
// Estudar remoção mais adiante.
|
|
8280
|
-
const parametros = this.resolverParametrosChamada(entidadeChamada);
|
|
8281
8316
|
const aridade = entidadeChamada.aridade ? entidadeChamada.aridade() : entidadeChamada.length;
|
|
8282
8317
|
// Completar os parâmetros não preenchidos com nulos.
|
|
8283
8318
|
if (argumentos.length < aridade) {
|
|
@@ -8285,22 +8320,7 @@ class InterpretadorBase {
|
|
|
8285
8320
|
for (let i = 0; i < diferenca; i++) {
|
|
8286
8321
|
argumentos.push(null);
|
|
8287
8322
|
}
|
|
8288
|
-
}
|
|
8289
|
-
// TODO: Aparentemente isso aqui nunca funcionou.
|
|
8290
|
-
// Avaliar de simplesmente apagar este código, e usar o que foi
|
|
8291
|
-
// implementado em `DeleguaFuncao.chamar`.
|
|
8292
|
-
if (
|
|
8293
|
-
parametros &&
|
|
8294
|
-
parametros.length > 0 &&
|
|
8295
|
-
parametros[parametros.length - 1].abrangencia === 'multiplo'
|
|
8296
|
-
) {
|
|
8297
|
-
let novosArgumentos = argumentos.slice(0, parametros.length - 1);
|
|
8298
|
-
novosArgumentos = novosArgumentos.concat(
|
|
8299
|
-
argumentos.slice(parametros.length - 1, argumentos.length)
|
|
8300
|
-
);
|
|
8301
|
-
argumentos = novosArgumentos;
|
|
8302
|
-
}
|
|
8303
|
-
} */
|
|
8323
|
+
}
|
|
8304
8324
|
if (entidadeChamada instanceof estruturas_1.FuncaoPadrao) {
|
|
8305
8325
|
try {
|
|
8306
8326
|
return entidadeChamada.chamar(this, argumentos.map((a) => a && a.valor && a.valor.hasOwnProperty('valor') ? a.valor.valor : a === null || a === void 0 ? void 0 : a.valor), expressao.entidadeChamada.simbolo);
|
|
@@ -8320,6 +8340,14 @@ class InterpretadorBase {
|
|
|
8320
8340
|
const retornoEntidadeChamada = await entidadeChamada.chamar(this, argumentos);
|
|
8321
8341
|
return retornoEntidadeChamada;
|
|
8322
8342
|
}
|
|
8343
|
+
// Chamadas a `super()`.
|
|
8344
|
+
// Basicamente, chamar o construtor da superclasse.
|
|
8345
|
+
if (expressao.entidadeChamada instanceof construtos_1.Super) {
|
|
8346
|
+
const descritorSuperclasse = variavelEntidadeChamada.classe.superClasse;
|
|
8347
|
+
const metodoConstrutor = descritorSuperclasse.encontrarMetodo('construtor');
|
|
8348
|
+
await metodoConstrutor.chamar(this, argumentos);
|
|
8349
|
+
return null;
|
|
8350
|
+
}
|
|
8323
8351
|
// A função chamada pode ser de uma biblioteca JavaScript.
|
|
8324
8352
|
// Neste caso apenas testamos se o tipo é uma função.
|
|
8325
8353
|
// TODO: Descobrir qual caso exatamente passa aqui.
|
|
@@ -8999,14 +9027,8 @@ class InterpretadorBase {
|
|
|
8999
9027
|
return valores;
|
|
9000
9028
|
}
|
|
9001
9029
|
visitarExpressaoSuper(expressao) {
|
|
9002
|
-
const superClasse = this.pilhaEscoposExecucao.obterVariavelPorNome('super');
|
|
9003
9030
|
const objeto = this.pilhaEscoposExecucao.obterVariavelPorNome('isto');
|
|
9004
|
-
|
|
9005
|
-
if (metodo === undefined) {
|
|
9006
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.metodo, 'Método chamado indefinido.', expressao.linha);
|
|
9007
|
-
}
|
|
9008
|
-
metodo.instancia = objeto.valor;
|
|
9009
|
-
return metodo;
|
|
9031
|
+
return objeto.valor;
|
|
9010
9032
|
}
|
|
9011
9033
|
/**
|
|
9012
9034
|
* Executa expressão de definição de variável.
|
|
@@ -12817,13 +12839,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
12817
12839
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12818
12840
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12819
12841
|
};
|
|
12820
|
-
var __importStar = (this && this.__importStar) || function (
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
};
|
|
12842
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
12843
|
+
var ownKeys = function(o) {
|
|
12844
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
12845
|
+
var ar = [];
|
|
12846
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
12847
|
+
return ar;
|
|
12848
|
+
};
|
|
12849
|
+
return ownKeys(o);
|
|
12850
|
+
};
|
|
12851
|
+
return function (mod) {
|
|
12852
|
+
if (mod && mod.__esModule) return mod;
|
|
12853
|
+
var result = {};
|
|
12854
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
12855
|
+
__setModuleDefault(result, mod);
|
|
12856
|
+
return result;
|
|
12857
|
+
};
|
|
12858
|
+
})();
|
|
12827
12859
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12828
12860
|
exports.Python3Lexer = void 0;
|
|
12829
12861
|
const Token_1 = require("antlr4ts/Token");
|
|
@@ -14040,13 +14072,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14040
14072
|
}) : function(o, v) {
|
|
14041
14073
|
o["default"] = v;
|
|
14042
14074
|
});
|
|
14043
|
-
var __importStar = (this && this.__importStar) || function (
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
|
|
14048
|
-
|
|
14049
|
-
};
|
|
14075
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
14076
|
+
var ownKeys = function(o) {
|
|
14077
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
14078
|
+
var ar = [];
|
|
14079
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
14080
|
+
return ar;
|
|
14081
|
+
};
|
|
14082
|
+
return ownKeys(o);
|
|
14083
|
+
};
|
|
14084
|
+
return function (mod) {
|
|
14085
|
+
if (mod && mod.__esModule) return mod;
|
|
14086
|
+
var result = {};
|
|
14087
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
14088
|
+
__setModuleDefault(result, mod);
|
|
14089
|
+
return result;
|
|
14090
|
+
};
|
|
14091
|
+
})();
|
|
14050
14092
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14051
14093
|
exports.Except_clauseContext = exports.With_itemContext = exports.With_stmtContext = exports.Try_stmtContext = exports.For_stmtContext = exports.While_stmtContext = exports.If_stmtContext = exports.Async_stmtContext = exports.Compound_stmtContext = exports.Assert_stmtContext = exports.Nonlocal_stmtContext = exports.Global_stmtContext = exports.Dotted_nameContext = exports.Dotted_as_namesContext = exports.Import_as_namesContext = exports.Dotted_as_nameContext = exports.Import_as_nameContext = exports.Import_fromContext = exports.Import_nameContext = exports.Import_stmtContext = exports.Raise_stmtContext = exports.Yield_stmtContext = exports.Return_stmtContext = exports.Continue_stmtContext = exports.Break_stmtContext = exports.Flow_stmtContext = exports.Pass_stmtContext = exports.Del_stmtContext = exports.AugassignContext = exports.Testlist_star_exprContext = exports.AnnassignContext = exports.Simple_assignContext = exports.Expr_stmtContext = exports.Small_stmtContext = exports.Simple_stmtContext = exports.StmtContext = exports.VfpdefContext = exports.VarargslistContext = exports.TfpdefContext = exports.TypedargslistContext = exports.ParametersContext = exports.FuncdefContext = exports.Async_funcdefContext = exports.DecoratedContext = exports.DecoratorsContext = exports.DecoratorContext = exports.Eval_inputContext = exports.File_inputContext = exports.Single_inputContext = exports.Python3Parser = void 0;
|
|
14052
14094
|
exports.Yield_argContext = exports.Yield_exprContext = exports.Encoding_declContext = exports.Comp_ifContext = exports.Comp_forContext = exports.Comp_iterContext = exports.ArgumentContext = exports.ArglistContext = exports.ClassdefContext = exports.DictorsetmakerContext = exports.TestlistContext = exports.ExprlistContext = exports.SliceopContext = exports.SubscriptContext = exports.SubscriptlistContext = exports.TrailerContext = exports.Testlist_compContext = exports.AtomContext = exports.Atom_exprContext = exports.PowerContext = exports.FactorContext = exports.TermContext = exports.Arith_exprContext = exports.Shift_exprContext = exports.And_exprContext = exports.Xor_exprContext = exports.ExprContext = exports.Star_exprContext = exports.Comp_opContext = exports.ComparisonContext = exports.Not_testContext = exports.And_testContext = exports.Or_testContext = exports.Lambdef_nocondContext = exports.LambdefContext = exports.Test_nocondContext = exports.TestContext = exports.SuiteContext = void 0;
|
|
@@ -25718,7 +25760,7 @@ class TradutorAssemblyScript {
|
|
|
25718
25760
|
else if (tipoDe.valor instanceof construtos_1.Vetor)
|
|
25719
25761
|
resultado += this.traduzirConstrutoVetor(tipoDe.valor);
|
|
25720
25762
|
else
|
|
25721
|
-
resultado += tipoDe.valor;
|
|
25763
|
+
resultado += this.dicionarioConstrutos[tipoDe.valor.constructor.name](tipoDe.valor);
|
|
25722
25764
|
return resultado;
|
|
25723
25765
|
}
|
|
25724
25766
|
traduzirConstrutoLogico(logico) {
|