@designliquido/delegua 0.60.0 → 0.61.1
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/avaliador-sintatico/avaliador-sintatico-base.d.ts +5 -0
- package/avaliador-sintatico/avaliador-sintatico-base.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico-base.js +6 -1
- package/avaliador-sintatico/avaliador-sintatico-base.js.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.d.ts +7 -2
- package/avaliador-sintatico/avaliador-sintatico.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.js +31 -18
- package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts +5 -0
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js +5 -0
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts +2 -4
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +25 -46
- 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/dialetos/micro-avaliador-sintatico-pitugues.js +1 -1
- package/avaliador-sintatico/dialetos/micro-avaliador-sintatico-pitugues.js.map +1 -1
- package/avaliador-sintatico/micro-avaliador-sintatico-base.js +1 -1
- package/avaliador-sintatico/micro-avaliador-sintatico-base.js.map +1 -1
- package/avaliador-sintatico/micro-avaliador-sintatico.d.ts +2 -1
- package/avaliador-sintatico/micro-avaliador-sintatico.d.ts.map +1 -1
- package/avaliador-sintatico/micro-avaliador-sintatico.js +13 -10
- package/avaliador-sintatico/micro-avaliador-sintatico.js.map +1 -1
- package/bin/package.json +1 -1
- package/construtos/logico.d.ts +1 -0
- package/construtos/logico.d.ts.map +1 -1
- package/construtos/logico.js +1 -0
- package/construtos/logico.js.map +1 -1
- package/interpretador/interpretador-base.d.ts +1 -0
- package/interpretador/interpretador-base.d.ts.map +1 -1
- package/interpretador/interpretador-base.js +23 -9
- package/interpretador/interpretador-base.js.map +1 -1
- package/lexador/dialetos/lexador-pitugues.d.ts +1 -1
- package/lexador/dialetos/lexador-pitugues.d.ts.map +1 -1
- package/lexador/dialetos/lexador-pitugues.js +6 -6
- package/lexador/dialetos/lexador-pitugues.js.map +1 -1
- package/lexador/dialetos/palavras-reservadas/pitugues.d.ts +5 -1
- package/lexador/dialetos/palavras-reservadas/pitugues.d.ts.map +1 -1
- package/lexador/dialetos/palavras-reservadas/pitugues.js +6 -2
- package/lexador/dialetos/palavras-reservadas/pitugues.js.map +1 -1
- package/lexador/lexador.js +2 -2
- package/lexador/lexador.js.map +1 -1
- package/lexador/palavras-reservadas.d.ts +6 -2
- package/lexador/palavras-reservadas.d.ts.map +1 -1
- package/lexador/palavras-reservadas.js +7 -3
- package/lexador/palavras-reservadas.js.map +1 -1
- package/package.json +1 -1
- package/tipos-de-simbolos/delegua.d.ts +2 -0
- package/tipos-de-simbolos/delegua.d.ts.map +1 -1
- package/tipos-de-simbolos/delegua.js +2 -0
- package/tipos-de-simbolos/delegua.js.map +1 -1
- package/tipos-de-simbolos/microgramaticas/delegua.d.ts +2 -0
- package/tipos-de-simbolos/microgramaticas/delegua.d.ts.map +1 -1
- package/tipos-de-simbolos/microgramaticas/delegua.js +2 -0
- package/tipos-de-simbolos/microgramaticas/delegua.js.map +1 -1
- package/tipos-de-simbolos/pitugues.d.ts +2 -0
- package/tipos-de-simbolos/pitugues.d.ts.map +1 -1
- package/tipos-de-simbolos/pitugues.js +2 -0
- package/tipos-de-simbolos/pitugues.js.map +1 -1
- package/umd/delegua.js +132 -98
package/umd/delegua.js
CHANGED
|
@@ -88,11 +88,16 @@ class AvaliadorSintaticoBase {
|
|
|
88
88
|
}
|
|
89
89
|
return this.chamar();
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* A exponenciacão é uma exceção na ordem de avaliação (resolve primeiro à direita).
|
|
93
|
+
* Por isso `direito` chama `exponenciacao()`, e não `unario()`.
|
|
94
|
+
* @returns {Binario} A expressão binária na forma do construto `Binario`.
|
|
95
|
+
*/
|
|
91
96
|
exponenciacao() {
|
|
92
97
|
let expressao = this.unario();
|
|
93
98
|
while (this.verificarSeSimboloAtualEIgualA(comum_1.default.EXPONENCIACAO)) {
|
|
94
99
|
const operador = this.simbolos[this.atual - 1];
|
|
95
|
-
const direito = this.
|
|
100
|
+
const direito = this.exponenciacao();
|
|
96
101
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
97
102
|
}
|
|
98
103
|
return expressao;
|
|
@@ -426,7 +431,7 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
426
431
|
throw this.erro(simboloPara, 'Identificador de iteração deve ser ou um par chave-valor, ou um nome de variável.');
|
|
427
432
|
}
|
|
428
433
|
paraTradicionalComoConstruto(simboloPara) {
|
|
429
|
-
const { inicializador, condicao, incrementar, corpo } = this.logicaComumPara(
|
|
434
|
+
const { inicializador, condicao, incrementar, corpo } = this.logicaComumPara();
|
|
430
435
|
return new construtos_1.ParaComoConstruto(simboloPara.hashArquivo, simboloPara.linha, inicializador, condicao, incrementar, corpo);
|
|
431
436
|
}
|
|
432
437
|
/**
|
|
@@ -711,7 +716,8 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
711
716
|
return this.resolverCadeiaChamadas(chamada);
|
|
712
717
|
case delegua_2.default.PONTO:
|
|
713
718
|
this.avancarEDevolverAnterior();
|
|
714
|
-
|
|
719
|
+
this.verificarSeSimboloAtualEIgualA();
|
|
720
|
+
const nome = this.avancarEDevolverAnterior();
|
|
715
721
|
let tipoInferido = expressaoAnterior.tipo;
|
|
716
722
|
// Se não for um dicionário anônimo (ou seja, ser variável ou constante com nome)
|
|
717
723
|
if (expressaoAnterior.tipo === 'dicionário' &&
|
|
@@ -904,26 +910,23 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
904
910
|
return construtoChamada;
|
|
905
911
|
}
|
|
906
912
|
unario() {
|
|
907
|
-
if (this.verificarSeSimboloAtualEIgualA(delegua_2.default.NEGACAO, delegua_2.default.SUBTRACAO, delegua_2.default.BIT_NOT, delegua_2.default.INCREMENTAR, delegua_2.default.DECREMENTAR)) {
|
|
913
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_2.default.NAO, delegua_2.default.NEGACAO, delegua_2.default.SUBTRACAO, delegua_2.default.BIT_NOT, delegua_2.default.INCREMENTAR, delegua_2.default.DECREMENTAR)) {
|
|
908
914
|
const operador = this.simbolos[this.atual - 1];
|
|
909
915
|
const direito = this.unario();
|
|
910
916
|
return new construtos_1.Unario(this.hashArquivo, operador, direito, 'ANTES');
|
|
911
917
|
}
|
|
912
918
|
return this.chamar();
|
|
913
919
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
}
|
|
920
|
-
return expressao;
|
|
921
|
-
}
|
|
920
|
+
/**
|
|
921
|
+
* A exponenciacão é uma exceção na ordem de avaliação (resolve primeiro à direita).
|
|
922
|
+
* Por isso `direito` chama `exponenciacao()`, e não `unario()`.
|
|
923
|
+
* @returns {Binario} A expressão binária na forma do construto `Binario`.
|
|
924
|
+
*/
|
|
922
925
|
exponenciacao() {
|
|
923
|
-
let expressao = this.
|
|
926
|
+
let expressao = this.unario();
|
|
924
927
|
while (this.verificarSeSimboloAtualEIgualA(delegua_2.default.EXPONENCIACAO)) {
|
|
925
928
|
const operador = this.simbolos[this.atual - 1];
|
|
926
|
-
const direito = this.
|
|
929
|
+
const direito = this.exponenciacao();
|
|
927
930
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
928
931
|
}
|
|
929
932
|
return expressao;
|
|
@@ -1004,10 +1007,16 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
1004
1007
|
}
|
|
1005
1008
|
em() {
|
|
1006
1009
|
let expressao = this.comparacaoIgualdade();
|
|
1007
|
-
while (this.verificarSeSimboloAtualEIgualA(delegua_2.default.EM)) {
|
|
1008
|
-
|
|
1010
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_2.default.EM, delegua_2.default.CONTEM, delegua_2.default.NAO)) {
|
|
1011
|
+
let operador = this.simbolos[this.atual - 1];
|
|
1012
|
+
let negado = false;
|
|
1013
|
+
if (operador.tipo === delegua_2.default.NAO) {
|
|
1014
|
+
operador = this.consumir(delegua_2.default.CONTEM, `Esperado palavra reservada 'contém' ou 'contem' após palavra reservada ${operador.lexema}.`);
|
|
1015
|
+
negado = true;
|
|
1016
|
+
}
|
|
1009
1017
|
const direito = this.comparacaoIgualdade();
|
|
1010
1018
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
1019
|
+
expressao.negado = negado;
|
|
1011
1020
|
}
|
|
1012
1021
|
return expressao;
|
|
1013
1022
|
}
|
|
@@ -1020,8 +1029,16 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
1020
1029
|
}
|
|
1021
1030
|
return expressao;
|
|
1022
1031
|
}
|
|
1032
|
+
elvis() {
|
|
1033
|
+
let expressao = this.ou();
|
|
1034
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_2.default.ELVIS)) {
|
|
1035
|
+
const direito = this.ou();
|
|
1036
|
+
return new construtos_1.Elvis(this.hashArquivo, expressao, direito);
|
|
1037
|
+
}
|
|
1038
|
+
return expressao;
|
|
1039
|
+
}
|
|
1023
1040
|
seTernario() {
|
|
1024
|
-
let expressaoOuCondicao = this.
|
|
1041
|
+
let expressaoOuCondicao = this.elvis();
|
|
1025
1042
|
while (this.verificarSeSimboloAtualEIgualA(delegua_2.default.INTERROGACAO)) {
|
|
1026
1043
|
const operador = this.simbolos[this.atual - 1];
|
|
1027
1044
|
const expressaoEntao = this.seTernario();
|
|
@@ -1391,7 +1408,7 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
1391
1408
|
}
|
|
1392
1409
|
throw this.erro(simboloPara, 'Identificador de iteração deve ser ou um par chave-valor, ou um nome de variável.');
|
|
1393
1410
|
}
|
|
1394
|
-
logicaComumPara(
|
|
1411
|
+
logicaComumPara() {
|
|
1395
1412
|
const comParenteses = this.verificarSeSimboloAtualEIgualA(delegua_2.default.PARENTESE_ESQUERDO);
|
|
1396
1413
|
let inicializador;
|
|
1397
1414
|
if (this.verificarSeSimboloAtualEIgualA(delegua_2.default.PONTO_E_VIRGULA)) {
|
|
@@ -1430,7 +1447,7 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
1430
1447
|
};
|
|
1431
1448
|
}
|
|
1432
1449
|
declaracaoParaTradicional(simboloPara) {
|
|
1433
|
-
const { inicializador, condicao, incrementar, corpo } = this.logicaComumPara(
|
|
1450
|
+
const { inicializador, condicao, incrementar, corpo } = this.logicaComumPara();
|
|
1434
1451
|
return new declaracoes_1.Para(this.hashArquivo, Number(simboloPara.linha), inicializador, condicao, incrementar, corpo);
|
|
1435
1452
|
}
|
|
1436
1453
|
declaracaoRetorna() {
|
|
@@ -1444,6 +1461,7 @@ class AvaliadorSintatico extends avaliador_sintatico_base_1.AvaliadorSintaticoBa
|
|
|
1444
1461
|
delegua_2.default.FUNÇÃO,
|
|
1445
1462
|
delegua_2.default.IDENTIFICADOR,
|
|
1446
1463
|
delegua_2.default.ISTO,
|
|
1464
|
+
delegua_2.default.NAO,
|
|
1447
1465
|
delegua_2.default.NEGACAO,
|
|
1448
1466
|
delegua_2.default.NUMERO,
|
|
1449
1467
|
delegua_2.default.NULO,
|
|
@@ -2770,6 +2788,11 @@ class AvaliadorSintaticoEguaClassico {
|
|
|
2770
2788
|
}
|
|
2771
2789
|
return this.chamar();
|
|
2772
2790
|
}
|
|
2791
|
+
/**
|
|
2792
|
+
* A exponenciacão de Égua [é implementada com resolução à esquerda](https://github.com/eguadev/egua/blob/main/src/parser.js#L230).
|
|
2793
|
+
* Por isso esse dialeto resolve `direito` chamando `unario()`, e não `exponenciacao()` como os demais.
|
|
2794
|
+
* @returns {Binario} A expressão binária na forma do construto `Binario`.
|
|
2795
|
+
*/
|
|
2773
2796
|
exponenciacao() {
|
|
2774
2797
|
let expressao = this.unario();
|
|
2775
2798
|
while (this.verificarSeSimboloAtualEIgualA(egua_classico_1.default.EXPONENCIACAO)) {
|
|
@@ -3582,7 +3605,7 @@ class AvaliadorSintaticoPitugues {
|
|
|
3582
3605
|
let expressao = this.unario();
|
|
3583
3606
|
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.EXPONENCIACAO)) {
|
|
3584
3607
|
const operador = this.simboloAnterior();
|
|
3585
|
-
const direito = this.
|
|
3608
|
+
const direito = this.exponenciacao();
|
|
3586
3609
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
3587
3610
|
}
|
|
3588
3611
|
return expressao;
|
|
@@ -3652,10 +3675,16 @@ class AvaliadorSintaticoPitugues {
|
|
|
3652
3675
|
}
|
|
3653
3676
|
em() {
|
|
3654
3677
|
let expressao = this.comparacaoIgualdade();
|
|
3655
|
-
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.EM)) {
|
|
3656
|
-
|
|
3678
|
+
while (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.EM, pitugues_2.default.CONTEM, pitugues_2.default.NAO)) {
|
|
3679
|
+
let operador = this.simboloAnterior();
|
|
3680
|
+
let negado = false;
|
|
3681
|
+
if (operador.tipo === pitugues_2.default.NAO) {
|
|
3682
|
+
operador = this.consumir(pitugues_2.default.CONTEM, `Esperado palavra reservada 'contém' ou 'contem' após palavra reservada ${operador.lexema}.`);
|
|
3683
|
+
negado = true;
|
|
3684
|
+
}
|
|
3657
3685
|
const direito = this.comparacaoIgualdade();
|
|
3658
3686
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
3687
|
+
expressao.negado = negado;
|
|
3659
3688
|
}
|
|
3660
3689
|
return expressao;
|
|
3661
3690
|
}
|
|
@@ -3839,54 +3868,27 @@ class AvaliadorSintaticoPitugues {
|
|
|
3839
3868
|
this.blocos -= 1;
|
|
3840
3869
|
}
|
|
3841
3870
|
}
|
|
3842
|
-
declaracaoParaCada(simboloPara) {
|
|
3843
|
-
const nomeVariavelIteracao = this.consumir(pitugues_2.default.IDENTIFICADOR, "Esperado identificador de variável de iteração para instrução 'para cada'.");
|
|
3844
|
-
if (!this.verificarSeSimboloAtualEIgualA(pitugues_2.default.DE, pitugues_2.default.EM)) {
|
|
3845
|
-
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'.");
|
|
3846
|
-
}
|
|
3847
|
-
const vetor = this.expressao();
|
|
3848
|
-
if (!vetor.hasOwnProperty('tipo')) {
|
|
3849
|
-
throw this.erro(simboloPara, `Variável ou constante em 'para cada' não parece possuir um tipo iterável.`);
|
|
3850
|
-
}
|
|
3851
|
-
const tipoVetor = vetor.tipo;
|
|
3852
|
-
if (!tipoVetor.endsWith('[]') && !['qualquer', 'vetor'].includes(tipoVetor)) {
|
|
3853
|
-
throw this.erro(simboloPara, `Variável ou constante em 'para cada' não é iterável. Tipo resolvido: ${tipoVetor}.`);
|
|
3854
|
-
}
|
|
3855
|
-
this.pilhaEscopos.definirInformacoesVariavel(nomeVariavelIteracao.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(nomeVariavelIteracao.lexema, tipoVetor.slice(0, -2)));
|
|
3856
|
-
// TODO: Talvez não seja uma ideia melhor chamar o método de `Bloco` aqui?
|
|
3857
|
-
const corpo = this.resolverDeclaracao();
|
|
3858
|
-
return new declaracoes_1.ParaCada(this.hashArquivo, Number(simboloPara.linha), new construtos_1.Variavel(this.hashArquivo, nomeVariavelIteracao), vetor, corpo);
|
|
3859
|
-
}
|
|
3860
|
-
declaracaoParaTradicional(simboloPara) {
|
|
3861
|
-
let inicializador;
|
|
3862
|
-
if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.PONTO_E_VIRGULA)) {
|
|
3863
|
-
inicializador = null;
|
|
3864
|
-
}
|
|
3865
|
-
else if (this.verificarSeSimboloAtualEIgualA(pitugues_2.default.VARIAVEL)) {
|
|
3866
|
-
inicializador = this.declaracaoDeVariaveis();
|
|
3867
|
-
}
|
|
3868
|
-
else {
|
|
3869
|
-
inicializador = this.declaracaoExpressao();
|
|
3870
|
-
}
|
|
3871
|
-
let condicao = null;
|
|
3872
|
-
if (!this.verificarTipoSimboloAtual(pitugues_2.default.PONTO_E_VIRGULA)) {
|
|
3873
|
-
condicao = this.expressao();
|
|
3874
|
-
}
|
|
3875
|
-
let incrementar = null;
|
|
3876
|
-
if (this.simbolos[this.atual].tipo !== pitugues_2.default.DOIS_PONTOS) {
|
|
3877
|
-
incrementar = this.expressao();
|
|
3878
|
-
}
|
|
3879
|
-
const corpo = this.resolverDeclaracao();
|
|
3880
|
-
return new declaracoes_1.Para(this.hashArquivo, Number(simboloPara.linha), inicializador, condicao, incrementar, corpo);
|
|
3881
|
-
}
|
|
3882
3871
|
declaracaoPara() {
|
|
3883
3872
|
try {
|
|
3884
3873
|
const simboloPara = this.simboloAnterior();
|
|
3885
3874
|
this.blocos += 1;
|
|
3886
|
-
|
|
3887
|
-
|
|
3875
|
+
this.consumir(pitugues_2.default.CADA, `Esperado palavra reservada 'cada' após 'para'. Atual: ${this.simbolos[this.atual].lexema}.`);
|
|
3876
|
+
const nomeVariavelIteracao = this.consumir(pitugues_2.default.IDENTIFICADOR, "Esperado identificador de variável de iteração para instrução 'para cada'.");
|
|
3877
|
+
if (!this.verificarSeSimboloAtualEIgualA(pitugues_2.default.DE, pitugues_2.default.EM)) {
|
|
3878
|
+
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'.");
|
|
3888
3879
|
}
|
|
3889
|
-
|
|
3880
|
+
const vetor = this.expressao();
|
|
3881
|
+
if (!vetor.hasOwnProperty('tipo')) {
|
|
3882
|
+
throw this.erro(simboloPara, `Variável ou constante em 'para cada' não parece possuir um tipo iterável.`);
|
|
3883
|
+
}
|
|
3884
|
+
const tipoVetor = vetor.tipo;
|
|
3885
|
+
if (!tipoVetor.endsWith('[]') && !['qualquer', 'texto', 'vetor'].includes(tipoVetor)) {
|
|
3886
|
+
throw this.erro(simboloPara, `Variável ou constante em 'para cada' não é iterável. Tipo resolvido: ${tipoVetor}.`);
|
|
3887
|
+
}
|
|
3888
|
+
this.pilhaEscopos.definirInformacoesVariavel(nomeVariavelIteracao.lexema, new informacao_elemento_sintatico_1.InformacaoElementoSintatico(nomeVariavelIteracao.lexema, tipoVetor.slice(0, -2)));
|
|
3889
|
+
// TODO: Talvez não seja uma ideia melhor chamar o método de `Bloco` aqui?
|
|
3890
|
+
const corpo = this.resolverDeclaracao();
|
|
3891
|
+
return new declaracoes_1.ParaCada(this.hashArquivo, Number(simboloPara.linha), new construtos_1.Variavel(this.hashArquivo, nomeVariavelIteracao), vetor, corpo);
|
|
3890
3892
|
}
|
|
3891
3893
|
catch (erro) {
|
|
3892
3894
|
throw erro;
|
|
@@ -5618,7 +5620,7 @@ class MicroAvaliadorSintaticoBase {
|
|
|
5618
5620
|
let expressao = this.unario();
|
|
5619
5621
|
while (this.verificarSeSimboloAtualEIgualA(comum_1.default.EXPONENCIACAO)) {
|
|
5620
5622
|
const operador = this.simbolos[this.atual - 1];
|
|
5621
|
-
const direito = this.
|
|
5623
|
+
const direito = this.exponenciacao();
|
|
5622
5624
|
expressao = new construtos_1.Binario(-1, expressao, operador, direito);
|
|
5623
5625
|
}
|
|
5624
5626
|
return expressao;
|
|
@@ -5814,19 +5816,11 @@ class MicroAvaliadorSintatico extends micro_avaliador_sintatico_base_1.MicroAval
|
|
|
5814
5816
|
}
|
|
5815
5817
|
return this.chamar();
|
|
5816
5818
|
}
|
|
5817
|
-
elvis() {
|
|
5818
|
-
let expressao = this.unario();
|
|
5819
|
-
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.ELVIS)) {
|
|
5820
|
-
const direito = this.unario();
|
|
5821
|
-
return new construtos_1.Elvis(-1, expressao, direito);
|
|
5822
|
-
}
|
|
5823
|
-
return expressao;
|
|
5824
|
-
}
|
|
5825
5819
|
exponenciacao() {
|
|
5826
|
-
let expressao = this.
|
|
5820
|
+
let expressao = this.unario();
|
|
5827
5821
|
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.EXPONENCIACAO)) {
|
|
5828
5822
|
const operador = this.simbolos[this.atual - 1];
|
|
5829
|
-
const direito = this.
|
|
5823
|
+
const direito = this.exponenciacao();
|
|
5830
5824
|
expressao = new construtos_1.Binario(-1, expressao, operador, direito);
|
|
5831
5825
|
}
|
|
5832
5826
|
return expressao;
|
|
@@ -5885,6 +5879,17 @@ class MicroAvaliadorSintatico extends micro_avaliador_sintatico_base_1.MicroAval
|
|
|
5885
5879
|
}
|
|
5886
5880
|
return expressao;
|
|
5887
5881
|
}
|
|
5882
|
+
elvis() {
|
|
5883
|
+
let expressao = this.ou();
|
|
5884
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.ELVIS)) {
|
|
5885
|
+
const direito = this.ou();
|
|
5886
|
+
return new construtos_1.Elvis(-1, expressao, direito);
|
|
5887
|
+
}
|
|
5888
|
+
return expressao;
|
|
5889
|
+
}
|
|
5890
|
+
declaracao() {
|
|
5891
|
+
return this.elvis();
|
|
5892
|
+
}
|
|
5888
5893
|
analisar(retornoLexador, linha) {
|
|
5889
5894
|
this.erros = [];
|
|
5890
5895
|
this.atual = 0;
|
|
@@ -8654,6 +8659,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8654
8659
|
exports.Logico = void 0;
|
|
8655
8660
|
class Logico {
|
|
8656
8661
|
constructor(hashArquivo, esquerda, operador, direita) {
|
|
8662
|
+
this.negado = false;
|
|
8657
8663
|
this.linha = esquerda.linha;
|
|
8658
8664
|
this.hashArquivo = hashArquivo;
|
|
8659
8665
|
this.esquerda = esquerda;
|
|
@@ -12578,7 +12584,8 @@ class InterpretadorBase {
|
|
|
12578
12584
|
switch (expressao.operador.tipo) {
|
|
12579
12585
|
case delegua_1.default.EXPONENCIACAO:
|
|
12580
12586
|
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
12581
|
-
|
|
12587
|
+
const resultadoExponenciacao = Math.pow(valorEsquerdo, valorDireito);
|
|
12588
|
+
return resultadoExponenciacao;
|
|
12582
12589
|
case delegua_1.default.MAIOR:
|
|
12583
12590
|
if (this.tiposNumericos.includes(tipoEsquerdo) &&
|
|
12584
12591
|
this.tiposNumericos.includes(tipoDireito)) {
|
|
@@ -12827,18 +12834,31 @@ class InterpretadorBase {
|
|
|
12827
12834
|
async visitarDeclaracaoDeExpressao(declaracao) {
|
|
12828
12835
|
return await this.avaliar(declaracao.expressao);
|
|
12829
12836
|
}
|
|
12837
|
+
logicaContemOuEm(esquerda, direita, expressao) {
|
|
12838
|
+
const valorDireitoResolvido = this.resolverValor(direita);
|
|
12839
|
+
if (Array.isArray(valorDireitoResolvido) || typeof valorDireitoResolvido === primitivos_1.default.TEXTO) {
|
|
12840
|
+
const avaliacao = valorDireitoResolvido.includes(esquerda);
|
|
12841
|
+
return expressao.negado ? !avaliacao : avaliacao;
|
|
12842
|
+
}
|
|
12843
|
+
if (valorDireitoResolvido !== null && typeof valorDireitoResolvido === 'object') {
|
|
12844
|
+
const avaliacao = esquerda in valorDireitoResolvido;
|
|
12845
|
+
return expressao.negado ? !avaliacao : avaliacao;
|
|
12846
|
+
}
|
|
12847
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(esquerda, `Tipo de chamada inválida com '${expressao.operador.tipo}'.`, expressao.linha);
|
|
12848
|
+
}
|
|
12830
12849
|
async visitarExpressaoLogica(expressao) {
|
|
12831
12850
|
const esquerda = await this.avaliar(expressao.esquerda);
|
|
12832
|
-
if (
|
|
12851
|
+
if ([delegua_1.default.EM, delegua_1.default.CONTEM].includes(expressao.operador.tipo)) {
|
|
12833
12852
|
const direita = await this.avaliar(expressao.direita);
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
(
|
|
12853
|
+
// `3 em lista` é igual a `lista contém 3`.
|
|
12854
|
+
// Portanto, precisamos inverter os operandos de acordo com a
|
|
12855
|
+
// palavra reservada usada.
|
|
12856
|
+
switch (expressao.operador.tipo) {
|
|
12857
|
+
case delegua_1.default.EM:
|
|
12858
|
+
return this.logicaContemOuEm(esquerda, direita, expressao);
|
|
12859
|
+
case delegua_1.default.CONTEM:
|
|
12860
|
+
return this.logicaContemOuEm(direita, esquerda, expressao);
|
|
12840
12861
|
}
|
|
12841
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(esquerda, "Tipo de chamada inválida com 'em'.", expressao.linha);
|
|
12842
12862
|
}
|
|
12843
12863
|
// se um estado for verdadeiro, retorna verdadeiro
|
|
12844
12864
|
if (expressao.operador.tipo === delegua_1.default.OU) {
|
|
@@ -15787,9 +15807,9 @@ class LexadorPitugues {
|
|
|
15787
15807
|
this.analisarIndentacao();
|
|
15788
15808
|
}
|
|
15789
15809
|
}
|
|
15790
|
-
adicionarSimbolo(tipo, literal = null) {
|
|
15810
|
+
adicionarSimbolo(tipo, literal = null, linha = null) {
|
|
15791
15811
|
const texto = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
15792
|
-
this.simbolos.push(new simbolo_1.Simbolo(tipo, texto, literal, this.linha + 1, this.hashArquivo));
|
|
15812
|
+
this.simbolos.push(new simbolo_1.Simbolo(tipo, texto, literal, linha || this.linha + 1, this.hashArquivo));
|
|
15793
15813
|
}
|
|
15794
15814
|
simboloAtual() {
|
|
15795
15815
|
if (this.eFinalDaLinha())
|
|
@@ -15890,8 +15910,8 @@ class LexadorPitugues {
|
|
|
15890
15910
|
else {
|
|
15891
15911
|
textoPalavraChave = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
15892
15912
|
}
|
|
15893
|
-
const tipo = textoPalavraChave in pitugues_1.
|
|
15894
|
-
? pitugues_1.
|
|
15913
|
+
const tipo = textoPalavraChave in pitugues_1.palavrasReservadasPitugues
|
|
15914
|
+
? pitugues_1.palavrasReservadasPitugues[textoPalavraChave]
|
|
15895
15915
|
: pitugues_2.default.IDENTIFICADOR;
|
|
15896
15916
|
this.simbolos.push(new simbolo_1.Simbolo(tipo, textoPalavraChave, null, linhaPrimeiroCaracter + 1, this.hashArquivo));
|
|
15897
15917
|
}
|
|
@@ -15914,8 +15934,8 @@ class LexadorPitugues {
|
|
|
15914
15934
|
ultimoAtual = this.atual;
|
|
15915
15935
|
this.avancar();
|
|
15916
15936
|
}
|
|
15917
|
-
const conteudo = this.codigo[linhaAtual].substring(this.inicioSimbolo + 2, ultimoAtual);
|
|
15918
|
-
this.adicionarSimbolo(pitugues_2.default.COMENTARIO, conteudo.trim());
|
|
15937
|
+
const conteudo = this.codigo[linhaAtual].substring(this.inicioSimbolo + 2, ultimoAtual + 1);
|
|
15938
|
+
this.adicionarSimbolo(pitugues_2.default.COMENTARIO, conteudo.trim(), linhaAtual + 1);
|
|
15919
15939
|
}
|
|
15920
15940
|
avancarParaProximaLinha() {
|
|
15921
15941
|
this.linha++;
|
|
@@ -16867,14 +16887,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16867
16887
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16868
16888
|
};
|
|
16869
16889
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16870
|
-
exports.palavrasReservadasMicroGramatica = exports.
|
|
16890
|
+
exports.palavrasReservadasMicroGramatica = exports.palavrasReservadasPitugues = void 0;
|
|
16871
16891
|
const pitugues_1 = __importDefault(require("../../../tipos-de-simbolos/pitugues"));
|
|
16872
|
-
exports.
|
|
16892
|
+
exports.palavrasReservadasPitugues = {
|
|
16873
16893
|
cada: pitugues_1.default.CADA,
|
|
16874
16894
|
caso: pitugues_1.default.CASO,
|
|
16875
16895
|
classe: pitugues_1.default.CLASSE,
|
|
16876
16896
|
como: pitugues_1.default.COMO,
|
|
16877
16897
|
construtor: pitugues_1.default.CONSTRUTOR,
|
|
16898
|
+
contem: pitugues_1.default.CONTEM,
|
|
16899
|
+
contém: pitugues_1.default.CONTEM,
|
|
16878
16900
|
continua: pitugues_1.default.CONTINUA,
|
|
16879
16901
|
de: pitugues_1.default.DE,
|
|
16880
16902
|
e: pitugues_1.default.E,
|
|
@@ -16892,6 +16914,8 @@ exports.palavrasReservadas = {
|
|
|
16892
16914
|
imprima: pitugues_1.default.IMPRIMA,
|
|
16893
16915
|
isto: pitugues_1.default.ISTO,
|
|
16894
16916
|
leia: pitugues_1.default.LEIA,
|
|
16917
|
+
nao: pitugues_1.default.NAO,
|
|
16918
|
+
não: pitugues_1.default.NAO,
|
|
16895
16919
|
nulo: pitugues_1.default.NULO,
|
|
16896
16920
|
ou: pitugues_1.default.OU,
|
|
16897
16921
|
padrao: pitugues_1.default.PADRAO,
|
|
@@ -17409,8 +17433,8 @@ class Lexador {
|
|
|
17409
17433
|
this.avancar();
|
|
17410
17434
|
}
|
|
17411
17435
|
const codigo = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
17412
|
-
const tipo = codigo in palavras_reservadas_1.
|
|
17413
|
-
? palavras_reservadas_1.
|
|
17436
|
+
const tipo = codigo in palavras_reservadas_1.palavrasReservadasDelegua
|
|
17437
|
+
? palavras_reservadas_1.palavrasReservadasDelegua[codigo]
|
|
17414
17438
|
: delegua_1.default.IDENTIFICADOR;
|
|
17415
17439
|
this.adicionarSimbolo(tipo);
|
|
17416
17440
|
}
|
|
@@ -17933,17 +17957,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17933
17957
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17934
17958
|
};
|
|
17935
17959
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17936
|
-
exports.palavrasReservadasMicroGramatica = exports.
|
|
17960
|
+
exports.palavrasReservadasMicroGramatica = exports.palavrasReservadasDelegua = void 0;
|
|
17937
17961
|
const delegua_1 = __importDefault(require("../tipos-de-simbolos/delegua"));
|
|
17938
|
-
exports.
|
|
17962
|
+
exports.palavrasReservadasDelegua = {
|
|
17939
17963
|
cada: delegua_1.default.CADA,
|
|
17940
17964
|
caso: delegua_1.default.CASO,
|
|
17941
17965
|
classe: delegua_1.default.CLASSE,
|
|
17942
17966
|
como: delegua_1.default.COMO,
|
|
17943
17967
|
construtor: delegua_1.default.CONSTRUTOR,
|
|
17944
|
-
continua: delegua_1.default.CONTINUA,
|
|
17945
17968
|
constante: delegua_1.default.CONSTANTE,
|
|
17946
17969
|
const: delegua_1.default.CONSTANTE,
|
|
17970
|
+
contem: delegua_1.default.CONTEM,
|
|
17971
|
+
contém: delegua_1.default.CONTEM,
|
|
17972
|
+
continua: delegua_1.default.CONTINUA,
|
|
17947
17973
|
de: delegua_1.default.DE,
|
|
17948
17974
|
e: delegua_1.default.E,
|
|
17949
17975
|
em: delegua_1.default.EM,
|
|
@@ -17961,6 +17987,8 @@ exports.palavrasReservadas = {
|
|
|
17961
17987
|
importar: delegua_1.default.IMPORTAR,
|
|
17962
17988
|
isto: delegua_1.default.ISTO,
|
|
17963
17989
|
leia: delegua_1.default.LEIA,
|
|
17990
|
+
nao: delegua_1.default.NAO,
|
|
17991
|
+
não: delegua_1.default.NAO,
|
|
17964
17992
|
nulo: delegua_1.default.NULO,
|
|
17965
17993
|
ou: delegua_1.default.OU,
|
|
17966
17994
|
padrao: delegua_1.default.PADRAO,
|
|
@@ -18206,6 +18234,7 @@ exports.default = {
|
|
|
18206
18234
|
COMO: 'COMO',
|
|
18207
18235
|
CONSTANTE: 'CONSTANTE',
|
|
18208
18236
|
CONSTRUTOR: 'CONSTRUTOR',
|
|
18237
|
+
CONTEM: 'CONTEM',
|
|
18209
18238
|
CONTINUA: 'CONTINUA',
|
|
18210
18239
|
DE: 'DE',
|
|
18211
18240
|
DECREMENTAR: 'DECREMENTAR',
|
|
@@ -18252,6 +18281,7 @@ exports.default = {
|
|
|
18252
18281
|
MODULO_IGUAL: 'MODULO_IGUAL',
|
|
18253
18282
|
MULTIPLICACAO: 'MULTIPLICACAO',
|
|
18254
18283
|
MULTIPLICACAO_IGUAL: 'MULTIPLICACAO_IGUAL',
|
|
18284
|
+
NAO: 'NAO',
|
|
18255
18285
|
NEGACAO: 'NEGACAO',
|
|
18256
18286
|
NULO: 'NULO',
|
|
18257
18287
|
NUMERO: 'NUMERO',
|
|
@@ -18392,6 +18422,7 @@ exports.default = {
|
|
|
18392
18422
|
CHAVE_ESQUERDA: 'CHAVE_ESQUERDA',
|
|
18393
18423
|
COLCHETE_DIREITO: 'COLCHETE_DIREITO',
|
|
18394
18424
|
COLCHETE_ESQUERDO: 'COLCHETE_ESQUERDO',
|
|
18425
|
+
CONTEM: 'CONTEM',
|
|
18395
18426
|
DECREMENTAR: 'DECREMENTAR',
|
|
18396
18427
|
DIFERENTE: 'DIFERENTE',
|
|
18397
18428
|
DIVISAO: 'DIVISAO',
|
|
@@ -18416,6 +18447,7 @@ exports.default = {
|
|
|
18416
18447
|
MENOR_MENOR: 'MENOR_MENOR',
|
|
18417
18448
|
MODULO: 'MODULO',
|
|
18418
18449
|
MULTIPLICACAO: 'MULTIPLICACAO',
|
|
18450
|
+
NAO: 'NAO',
|
|
18419
18451
|
NEGACAO: 'NEGACAO',
|
|
18420
18452
|
NULO: 'NULO',
|
|
18421
18453
|
NUMERO: 'NUMERO',
|
|
@@ -18449,6 +18481,7 @@ exports.default = {
|
|
|
18449
18481
|
COMENTARIO: 'COMENTARIO',
|
|
18450
18482
|
COMO: 'COMO',
|
|
18451
18483
|
CONSTRUTOR: 'CONSTRUTOR',
|
|
18484
|
+
CONTEM: 'CONTEM',
|
|
18452
18485
|
CONTINUA: 'CONTINUA',
|
|
18453
18486
|
DE: 'DE',
|
|
18454
18487
|
DIFERENTE: 'DIFERENTE',
|
|
@@ -18485,6 +18518,7 @@ exports.default = {
|
|
|
18485
18518
|
MENOR_MENOR: 'MENOR_MENOR',
|
|
18486
18519
|
MODULO: 'MODULO',
|
|
18487
18520
|
MULTIPLICACAO: 'MULTIPLICACAO',
|
|
18521
|
+
NAO: 'NAO',
|
|
18488
18522
|
NEGACAO: 'NEGACAO',
|
|
18489
18523
|
NULO: 'NULO',
|
|
18490
18524
|
NUMERO: 'NUMERO',
|