@designliquido/delegua 0.8.0 → 0.9.0-0
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/bin/package.json +10 -2
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.d.ts +2 -1
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.js +3 -0
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.js.map +1 -1
- package/fontes/avaliador-sintatico/avaliador-sintatico.d.ts +7 -5
- package/fontes/avaliador-sintatico/avaliador-sintatico.js +16 -1
- package/fontes/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts +5 -4
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js +3 -0
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.d.ts +10 -9
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.js +12 -0
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.d.ts +2 -2
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.js +17 -11
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.js.map +1 -1
- package/fontes/avaliador-sintatico/erro-avaliador-sintatico.d.ts +1 -1
- package/fontes/avaliador-sintatico/retornos/index.d.ts +3 -0
- package/fontes/avaliador-sintatico/retornos/index.js +20 -0
- package/fontes/avaliador-sintatico/retornos/index.js.map +1 -0
- package/fontes/avaliador-sintatico/retornos/retorno-declaracao.d.ts +3 -0
- package/fontes/avaliador-sintatico/retornos/retorno-declaracao.js +3 -0
- package/fontes/avaliador-sintatico/retornos/retorno-declaracao.js.map +1 -0
- package/fontes/avaliador-sintatico/retornos/retorno-primario.d.ts +3 -0
- package/fontes/avaliador-sintatico/retornos/retorno-primario.js +3 -0
- package/fontes/avaliador-sintatico/retornos/retorno-primario.js.map +1 -0
- package/fontes/avaliador-sintatico/retornos/retorno-resolver-declaracao.d.ts +2 -0
- package/fontes/avaliador-sintatico/retornos/retorno-resolver-declaracao.js +3 -0
- package/fontes/avaliador-sintatico/retornos/retorno-resolver-declaracao.js.map +1 -0
- package/fontes/bibliotecas/biblioteca-global.d.ts +2 -2
- package/fontes/bibliotecas/biblioteca-global.js +363 -134
- package/fontes/bibliotecas/biblioteca-global.js.map +1 -1
- package/fontes/bibliotecas/importar-biblioteca.d.ts +1 -1
- package/fontes/bibliotecas/importar-biblioteca.js +13 -14
- package/fontes/bibliotecas/importar-biblioteca.js.map +1 -1
- package/fontes/bibliotecas/primitivas-texto.js +13 -7
- package/fontes/bibliotecas/primitivas-texto.js.map +1 -1
- package/fontes/bibliotecas/primitivas-vetor.js +25 -11
- package/fontes/bibliotecas/primitivas-vetor.js.map +1 -1
- package/fontes/construtos/acesso-indice-variavel.d.ts +3 -3
- package/fontes/construtos/acesso-indice-variavel.js +41 -1
- package/fontes/construtos/acesso-indice-variavel.js.map +1 -1
- package/fontes/construtos/acesso-metodo.d.ts +3 -3
- package/fontes/construtos/acesso-metodo.js +41 -1
- package/fontes/construtos/acesso-metodo.js.map +1 -1
- package/fontes/construtos/agrupamento.d.ts +3 -3
- package/fontes/construtos/agrupamento.js +41 -1
- package/fontes/construtos/agrupamento.js.map +1 -1
- package/fontes/construtos/atribuicao-sobrescrita.d.ts +3 -2
- package/fontes/construtos/atribuicao-sobrescrita.js +41 -1
- package/fontes/construtos/atribuicao-sobrescrita.js.map +1 -1
- package/fontes/construtos/atribuir.d.ts +3 -3
- package/fontes/construtos/atribuir.js +41 -1
- package/fontes/construtos/atribuir.js.map +1 -1
- package/fontes/construtos/binario.d.ts +3 -3
- package/fontes/construtos/binario.js +41 -1
- package/fontes/construtos/binario.js.map +1 -1
- package/fontes/construtos/chamada.d.ts +3 -3
- package/fontes/construtos/chamada.js +41 -1
- package/fontes/construtos/chamada.js.map +1 -1
- package/fontes/construtos/conjunto.d.ts +3 -2
- package/fontes/construtos/conjunto.js +41 -1
- package/fontes/construtos/conjunto.js.map +1 -1
- package/fontes/construtos/construto.d.ts +1 -1
- package/fontes/construtos/dicionario.d.ts +3 -2
- package/fontes/construtos/dicionario.js +41 -1
- package/fontes/construtos/dicionario.js.map +1 -1
- package/fontes/construtos/funcao.d.ts +3 -3
- package/fontes/construtos/funcao.js +41 -1
- package/fontes/construtos/funcao.js.map +1 -1
- package/fontes/construtos/index.d.ts +18 -18
- package/fontes/construtos/isto.d.ts +3 -2
- package/fontes/construtos/isto.js +41 -1
- package/fontes/construtos/isto.js.map +1 -1
- package/fontes/construtos/literal.d.ts +4 -3
- package/fontes/construtos/literal.js +41 -1
- package/fontes/construtos/literal.js.map +1 -1
- package/fontes/construtos/logico.d.ts +3 -2
- package/fontes/construtos/logico.js +41 -1
- package/fontes/construtos/logico.js.map +1 -1
- package/fontes/construtos/super.d.ts +2 -2
- package/fontes/construtos/super.js +41 -1
- package/fontes/construtos/super.js.map +1 -1
- package/fontes/construtos/unario.d.ts +3 -2
- package/fontes/construtos/unario.js +41 -1
- package/fontes/construtos/unario.js.map +1 -1
- package/fontes/construtos/variavel.d.ts +3 -3
- package/fontes/construtos/variavel.js +41 -1
- package/fontes/construtos/variavel.js.map +1 -1
- package/fontes/construtos/vetor.d.ts +2 -1
- package/fontes/construtos/vetor.js +41 -1
- package/fontes/construtos/vetor.js.map +1 -1
- package/fontes/declaracoes/bloco.d.ts +3 -3
- package/fontes/declaracoes/bloco.js +41 -1
- package/fontes/declaracoes/bloco.js.map +1 -1
- package/fontes/declaracoes/classe.d.ts +3 -3
- package/fontes/declaracoes/classe.js +41 -1
- package/fontes/declaracoes/classe.js.map +1 -1
- package/fontes/declaracoes/continua.d.ts +3 -3
- package/fontes/declaracoes/continua.js +41 -1
- package/fontes/declaracoes/continua.js.map +1 -1
- package/fontes/declaracoes/declaracao.d.ts +2 -1
- package/fontes/declaracoes/declaracao.js +43 -3
- package/fontes/declaracoes/declaracao.js.map +1 -1
- package/fontes/declaracoes/enquanto.d.ts +4 -3
- package/fontes/declaracoes/enquanto.js +41 -1
- package/fontes/declaracoes/enquanto.js.map +1 -1
- package/fontes/declaracoes/escolha.d.ts +4 -3
- package/fontes/declaracoes/escolha.js +41 -1
- package/fontes/declaracoes/escolha.js.map +1 -1
- package/fontes/declaracoes/escreva.d.ts +1 -1
- package/fontes/declaracoes/escreva.js +41 -1
- package/fontes/declaracoes/escreva.js.map +1 -1
- package/fontes/declaracoes/expressao.d.ts +4 -4
- package/fontes/declaracoes/expressao.js +41 -1
- package/fontes/declaracoes/expressao.js.map +1 -1
- package/fontes/declaracoes/fazer.d.ts +3 -2
- package/fontes/declaracoes/fazer.js +41 -1
- package/fontes/declaracoes/fazer.js.map +1 -1
- package/fontes/declaracoes/funcao.d.ts +3 -3
- package/fontes/declaracoes/funcao.js +41 -1
- package/fontes/declaracoes/funcao.js.map +1 -1
- package/fontes/declaracoes/importar.d.ts +4 -3
- package/fontes/declaracoes/importar.js +41 -1
- package/fontes/declaracoes/importar.js.map +1 -1
- package/fontes/declaracoes/leia.d.ts +4 -4
- package/fontes/declaracoes/leia.js +44 -1
- package/fontes/declaracoes/leia.js.map +1 -1
- package/fontes/declaracoes/para.d.ts +3 -2
- package/fontes/declaracoes/para.js +41 -1
- package/fontes/declaracoes/para.js.map +1 -1
- package/fontes/declaracoes/retorna.d.ts +3 -3
- package/fontes/declaracoes/retorna.js +41 -1
- package/fontes/declaracoes/retorna.js.map +1 -1
- package/fontes/declaracoes/se.d.ts +3 -3
- package/fontes/declaracoes/se.js +41 -1
- package/fontes/declaracoes/se.js.map +1 -1
- package/fontes/declaracoes/sustar.d.ts +3 -3
- package/fontes/declaracoes/sustar.js +41 -1
- package/fontes/declaracoes/sustar.js.map +1 -1
- package/fontes/declaracoes/tente.d.ts +3 -3
- package/fontes/declaracoes/tente.js +41 -1
- package/fontes/declaracoes/tente.js.map +1 -1
- package/fontes/declaracoes/var.d.ts +4 -4
- package/fontes/declaracoes/var.js +41 -1
- package/fontes/declaracoes/var.js.map +1 -1
- package/fontes/delegua.d.ts +4 -4
- package/fontes/delegua.js +138 -63
- package/fontes/delegua.js.map +1 -1
- package/fontes/depuracao/cyrb53.js +6 -3
- package/fontes/depuracao/cyrb53.js.map +1 -1
- package/fontes/depuracao/servidor-depuracao.d.ts +4 -4
- package/fontes/depuracao/servidor-depuracao.js +199 -87
- package/fontes/depuracao/servidor-depuracao.js.map +1 -1
- package/fontes/espaco-variaveis.d.ts +1 -1
- package/fontes/espaco-variaveis.js +0 -1
- package/fontes/espaco-variaveis.js.map +1 -1
- package/fontes/estruturas/chamavel.js +1 -1
- package/fontes/estruturas/classe-padrao.d.ts +1 -1
- package/fontes/estruturas/classe-padrao.js.map +1 -1
- package/fontes/estruturas/delegua-classe.d.ts +4 -4
- package/fontes/estruturas/delegua-classe.js +5 -3
- package/fontes/estruturas/delegua-classe.js.map +1 -1
- package/fontes/estruturas/funcao-padrao.d.ts +2 -2
- package/fontes/estruturas/funcao-padrao.js +47 -3
- package/fontes/estruturas/funcao-padrao.js.map +1 -1
- package/fontes/estruturas/funcao.d.ts +5 -5
- package/fontes/estruturas/funcao.js +75 -24
- package/fontes/estruturas/funcao.js.map +1 -1
- package/fontes/estruturas/index.d.ts +9 -9
- package/fontes/estruturas/metodo-primitiva.d.ts +1 -1
- package/fontes/estruturas/modulo.d.ts +1 -1
- package/fontes/estruturas/modulo.js +1 -1
- package/fontes/estruturas/objeto-delegua-classe.d.ts +2 -2
- package/fontes/estruturas/objeto-delegua-classe.js +2 -2
- package/fontes/estruturas/objeto-delegua-classe.js.map +1 -1
- package/fontes/estruturas/objeto-padrao.js.map +1 -1
- package/fontes/excecoes/erro-em-tempo-de-execucao.d.ts +1 -1
- package/fontes/excecoes/erro-em-tempo-de-execucao.js.map +1 -1
- package/fontes/excecoes/index.d.ts +1 -1
- package/fontes/importador/importador.d.ts +1 -1
- package/fontes/importador/importador.js +3 -2
- package/fontes/importador/importador.js.map +1 -1
- package/fontes/importador/retorno-importador.d.ts +2 -2
- package/fontes/interfaces/avaliador-sintatico-interface.d.ts +5 -4
- package/fontes/interfaces/delegua-interface.d.ts +4 -4
- package/fontes/interfaces/escopo-execucao.d.ts +2 -2
- package/fontes/interfaces/importador-interface.d.ts +1 -1
- package/fontes/interfaces/interpretador-com-depuracao-interface.d.ts +6 -7
- package/fontes/interfaces/interpretador-interface.d.ts +6 -5
- package/fontes/interfaces/lexador-interface.d.ts +2 -2
- package/fontes/interfaces/parametro-interface.d.ts +1 -1
- package/fontes/interfaces/pilha-escopos-execucao-interface.d.ts +5 -5
- package/fontes/interfaces/resolvedor-interface.d.ts +5 -5
- package/fontes/interfaces/retornos/retorno-avaliador-sintatico.d.ts +2 -2
- package/fontes/interfaces/retornos/retorno-execucao-interface.d.ts +1 -1
- package/fontes/interfaces/retornos/retorno-interpretador.d.ts +1 -1
- package/fontes/interfaces/retornos/retorno-lexador.d.ts +3 -3
- package/fontes/interfaces/variavel-interface.d.ts +1 -1
- package/fontes/interpretador/dialetos/egua-classico.d.ts +31 -30
- package/fontes/interpretador/dialetos/egua-classico.js +922 -461
- package/fontes/interpretador/dialetos/egua-classico.js.map +1 -1
- package/fontes/interpretador/dialetos/index.js.map +1 -1
- package/fontes/interpretador/erro-interpretador.d.ts +1 -1
- package/fontes/interpretador/inferenciador.js.map +1 -1
- package/fontes/interpretador/interpretador-com-depuracao.d.ts +6 -6
- package/fontes/interpretador/interpretador-com-depuracao.js +280 -153
- package/fontes/interpretador/interpretador-com-depuracao.js.map +1 -1
- package/fontes/interpretador/interpretador.d.ts +44 -35
- package/fontes/interpretador/interpretador.js +1047 -535
- package/fontes/interpretador/interpretador.js.map +1 -1
- package/fontes/interpretador/pilha-escopos-execucao.js +16 -5
- package/fontes/interpretador/pilha-escopos-execucao.js.map +1 -1
- package/fontes/lexador/dialetos/index.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-birl.d.ts +25 -0
- package/fontes/lexador/dialetos/lexador-birl.js +75 -0
- package/fontes/lexador/dialetos/lexador-birl.js.map +1 -0
- package/fontes/lexador/dialetos/lexador-egua-classico.js +3 -3
- package/fontes/lexador/dialetos/lexador-egua-classico.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-eguap.d.ts +4 -4
- package/fontes/lexador/dialetos/lexador-eguap.js +15 -9
- package/fontes/lexador/dialetos/lexador-eguap.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-visualg.d.ts +2 -2
- package/fontes/lexador/dialetos/lexador-visualg.js +6 -4
- package/fontes/lexador/dialetos/lexador-visualg.js.map +1 -1
- package/fontes/lexador/dialetos/palavras-reservadas/birl.d.ts +2 -0
- package/fontes/lexador/dialetos/palavras-reservadas/birl.js +4 -0
- package/fontes/lexador/dialetos/palavras-reservadas/birl.js.map +1 -0
- package/fontes/lexador/dialetos/palavras-reservadas/visualg.js +1 -1
- package/fontes/lexador/dialetos/palavras-reservadas/visualg.js.map +1 -1
- package/fontes/lexador/lexador-base-linha-unica.d.ts +3 -3
- package/fontes/lexador/lexador-base-linha-unica.js.map +1 -1
- package/fontes/lexador/lexador.js +2 -2
- package/fontes/lexador/lexador.js.map +1 -1
- package/fontes/lexador/palavras-reservadas.d.ts +22 -21
- package/fontes/lexador/palavras-reservadas.js +22 -21
- package/fontes/lexador/palavras-reservadas.js.map +1 -1
- package/fontes/lexador/simbolo.d.ts +1 -1
- package/fontes/lexador/simbolo.js +1 -1
- package/fontes/lexador/simbolo.js.map +1 -1
- package/fontes/quebras/index.js.map +1 -1
- package/fontes/resolvedor/dialetos/egua-classico.d.ts +25 -3
- package/fontes/resolvedor/dialetos/egua-classico.js +41 -1
- package/fontes/resolvedor/dialetos/egua-classico.js.map +1 -1
- package/fontes/resolvedor/dialetos/index.js.map +1 -1
- package/fontes/resolvedor/erro-resolvedor.d.ts +1 -1
- package/fontes/resolvedor/pilha-escopos.d.ts +1 -1
- package/fontes/resolvedor/pilha-escopos.js +2 -2
- package/fontes/resolvedor/pilha-escopos.js.map +1 -1
- package/fontes/resolvedor/retorno-resolvedor.d.ts +2 -2
- package/fontes/tipos-de-simbolos/birl.d.ts +18 -0
- package/fontes/tipos-de-simbolos/birl.js +21 -0
- package/fontes/tipos-de-simbolos/birl.js.map +1 -0
- package/fontes/tipos-de-simbolos/comum.js +15 -15
- package/fontes/tipos-de-simbolos/comum.js.map +1 -1
- package/fontes/tipos-de-simbolos/delegua.d.ts +2 -1
- package/fontes/tipos-de-simbolos/delegua.js +74 -73
- package/fontes/tipos-de-simbolos/delegua.js.map +1 -1
- package/fontes/tipos-de-simbolos/eguap.d.ts +1 -0
- package/fontes/tipos-de-simbolos/eguap.js +70 -69
- package/fontes/tipos-de-simbolos/eguap.js.map +1 -1
- package/fontes/tipos-de-simbolos/visualg.js +44 -44
- package/fontes/tipos-de-simbolos/visualg.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/jest.config.js +2 -2
- package/jest.config.js.map +1 -1
- package/package.json +10 -2
- package/testes/avaliador-sintatico.test.js +5 -5
- package/testes/avaliador-sintatico.test.js.map +1 -1
- package/testes/biblioteca-global.test.js +424 -181
- package/testes/biblioteca-global.test.js.map +1 -1
- package/testes/egua-classico/delegua.test.js.map +1 -1
- package/testes/egua-classico/interpretador.test.js +379 -163
- package/testes/egua-classico/interpretador.test.js.map +1 -1
- package/testes/egua-classico/resolvedor.test.js.map +1 -1
- package/testes/eguap/avaliador-sintatico.test.js +1 -5
- package/testes/eguap/avaliador-sintatico.test.js.map +1 -1
- package/testes/eguap/interpretador.test.js +388 -172
- package/testes/eguap/interpretador.test.js.map +1 -1
- package/testes/eguap/lexador.test.js +1 -1
- package/testes/eguap/lexador.test.js.map +1 -1
- package/testes/interpretador.test.js +876 -351
- package/testes/interpretador.test.js.map +1 -1
- package/fontes/tipos/avaliador-sintatico-egua-e-eguap-classico-returno-tipo.d.ts +0 -5
- package/fontes/tipos/avaliador-sintatico-egua-e-eguap-classico-returno-tipo.js +0 -3
- package/fontes/tipos/avaliador-sintatico-egua-e-eguap-classico-returno-tipo.js.map +0 -1
|
@@ -22,6 +22,42 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (_) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
25
61
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
62
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
63
|
};
|
|
@@ -60,7 +96,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
60
96
|
var escopoExecucao = {
|
|
61
97
|
declaracoes: [],
|
|
62
98
|
declaracaoAtual: 0,
|
|
63
|
-
ambiente: new espaco_variaveis_1.EspacoVariaveis()
|
|
99
|
+
ambiente: new espaco_variaveis_1.EspacoVariaveis(),
|
|
64
100
|
};
|
|
65
101
|
this.pilhaEscoposExecucao.empilhar(escopoExecucao);
|
|
66
102
|
(0, biblioteca_global_1.default)(this, this.pilhaEscoposExecucao);
|
|
@@ -84,29 +120,43 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
84
120
|
return Boolean(objeto);
|
|
85
121
|
return true;
|
|
86
122
|
};
|
|
87
|
-
InterpretadorEguaClassico.prototype.verificarOperandoNumero = function (operador,
|
|
88
|
-
if (typeof
|
|
123
|
+
InterpretadorEguaClassico.prototype.verificarOperandoNumero = function (operador, operando) {
|
|
124
|
+
if (typeof operando === 'number' || operando.tipo === 'número')
|
|
89
125
|
return;
|
|
90
126
|
throw new excecoes_1.ErroEmTempoDeExecucao(operador, 'Operador precisa ser um número.', operador.linha);
|
|
91
127
|
};
|
|
92
128
|
InterpretadorEguaClassico.prototype.visitarExpressaoUnaria = function (expr) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
129
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
+
var direita, valor;
|
|
131
|
+
return __generator(this, function (_a) {
|
|
132
|
+
switch (_a.label) {
|
|
133
|
+
case 0: return [4 /*yield*/, this.avaliar(expr.direita)];
|
|
134
|
+
case 1:
|
|
135
|
+
direita = _a.sent();
|
|
136
|
+
valor = direita.hasOwnProperty('valor') ?
|
|
137
|
+
direita.valor :
|
|
138
|
+
direita;
|
|
139
|
+
switch (expr.operador.tipo) {
|
|
140
|
+
case delegua_1.default.SUBTRACAO:
|
|
141
|
+
this.verificarOperandoNumero(expr.operador, valor);
|
|
142
|
+
return [2 /*return*/, -valor];
|
|
143
|
+
case delegua_1.default.NEGACAO:
|
|
144
|
+
return [2 /*return*/, !this.eVerdadeiro(valor)];
|
|
145
|
+
case delegua_1.default.BIT_NOT:
|
|
146
|
+
return [2 /*return*/, ~valor];
|
|
147
|
+
}
|
|
148
|
+
return [2 /*return*/, null];
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
104
152
|
};
|
|
105
153
|
InterpretadorEguaClassico.prototype.eIgual = function (esquerda, direita) {
|
|
106
154
|
if (esquerda.tipo) {
|
|
107
|
-
if (esquerda.tipo ===
|
|
155
|
+
if (esquerda.tipo === 'nulo' &&
|
|
156
|
+
direita.tipo &&
|
|
157
|
+
direita.tipo === 'nulo')
|
|
108
158
|
return true;
|
|
109
|
-
if (esquerda.tipo ===
|
|
159
|
+
if (esquerda.tipo === 'nulo')
|
|
110
160
|
return false;
|
|
111
161
|
return esquerda.valor === direita.valor;
|
|
112
162
|
}
|
|
@@ -117,126 +167,187 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
117
167
|
return esquerda === direita;
|
|
118
168
|
};
|
|
119
169
|
InterpretadorEguaClassico.prototype.verificarOperandosNumeros = function (operador, direita, esquerda) {
|
|
120
|
-
var tipoDireita = direita.tipo
|
|
121
|
-
|
|
122
|
-
|
|
170
|
+
var tipoDireita = direita.tipo
|
|
171
|
+
? direita.tipo
|
|
172
|
+
: typeof direita === 'number'
|
|
173
|
+
? 'número'
|
|
174
|
+
: String(NaN);
|
|
175
|
+
var tipoEsquerda = esquerda.tipo
|
|
176
|
+
? esquerda.tipo
|
|
177
|
+
: typeof esquerda === 'number'
|
|
178
|
+
? 'número'
|
|
179
|
+
: String(NaN);
|
|
180
|
+
if (tipoDireita === 'número' && tipoEsquerda === 'número')
|
|
123
181
|
return;
|
|
124
182
|
throw new excecoes_1.ErroEmTempoDeExecucao(operador, 'Operadores precisam ser números.', operador.linha);
|
|
125
183
|
};
|
|
126
184
|
InterpretadorEguaClassico.prototype.visitarExpressaoBinaria = function (expressao) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
185
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
186
|
+
var esquerda, direita, valorEsquerdo, valorDireito, tipoEsquerdo, tipoDireito, erro_1;
|
|
187
|
+
return __generator(this, function (_a) {
|
|
188
|
+
switch (_a.label) {
|
|
189
|
+
case 0:
|
|
190
|
+
_a.trys.push([0, 3, , 4]);
|
|
191
|
+
return [4 /*yield*/, this.avaliar(expressao.esquerda)];
|
|
192
|
+
case 1:
|
|
193
|
+
esquerda = _a.sent();
|
|
194
|
+
return [4 /*yield*/, this.avaliar(expressao.direita)];
|
|
195
|
+
case 2:
|
|
196
|
+
direita = _a.sent();
|
|
197
|
+
valorEsquerdo = esquerda.hasOwnProperty('valor')
|
|
198
|
+
? esquerda.valor
|
|
199
|
+
: esquerda;
|
|
200
|
+
valorDireito = direita.hasOwnProperty('valor')
|
|
201
|
+
? direita.valor
|
|
202
|
+
: direita;
|
|
203
|
+
tipoEsquerdo = esquerda.hasOwnProperty('tipo')
|
|
204
|
+
? esquerda.tipo
|
|
205
|
+
: (0, inferenciador_1.inferirTipoVariavel)(esquerda);
|
|
206
|
+
tipoDireito = direita.hasOwnProperty('tipo')
|
|
207
|
+
? direita.tipo
|
|
208
|
+
: (0, inferenciador_1.inferirTipoVariavel)(direita);
|
|
209
|
+
switch (expressao.operador.tipo) {
|
|
210
|
+
case delegua_1.default.EXPONENCIACAO:
|
|
211
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
212
|
+
return [2 /*return*/, Math.pow(valorEsquerdo, valorDireito)];
|
|
213
|
+
case delegua_1.default.MAIOR:
|
|
214
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
215
|
+
return [2 /*return*/, Number(valorEsquerdo) > Number(valorDireito)];
|
|
216
|
+
case delegua_1.default.MAIOR_IGUAL:
|
|
217
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
218
|
+
return [2 /*return*/, Number(valorEsquerdo) >= Number(valorDireito)];
|
|
219
|
+
case delegua_1.default.MENOR:
|
|
220
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
221
|
+
return [2 /*return*/, Number(valorEsquerdo) < Number(valorDireito)];
|
|
222
|
+
case delegua_1.default.MENOR_IGUAL:
|
|
223
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
224
|
+
return [2 /*return*/, Number(valorEsquerdo) <= Number(valorDireito)];
|
|
225
|
+
case delegua_1.default.SUBTRACAO:
|
|
226
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
227
|
+
return [2 /*return*/, Number(valorEsquerdo) - Number(valorDireito)];
|
|
228
|
+
case delegua_1.default.ADICAO:
|
|
229
|
+
if (tipoEsquerdo === 'número' && tipoDireito === 'número') {
|
|
230
|
+
return [2 /*return*/, Number(esquerda) + Number(direita)];
|
|
231
|
+
}
|
|
232
|
+
else if (tipoEsquerdo === 'texto' &&
|
|
233
|
+
tipoDireito === 'texto') {
|
|
234
|
+
return [2 /*return*/, String(esquerda) + String(direita)];
|
|
235
|
+
}
|
|
236
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.operador, 'Operadores precisam ser dois números ou duas strings.');
|
|
237
|
+
case delegua_1.default.DIVISAO:
|
|
238
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
239
|
+
return [2 /*return*/, Number(valorEsquerdo) / Number(valorDireito)];
|
|
240
|
+
case delegua_1.default.MULTIPLICACAO:
|
|
241
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
242
|
+
return [2 /*return*/, Number(valorEsquerdo) * Number(valorDireito)];
|
|
243
|
+
case delegua_1.default.MODULO:
|
|
244
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
245
|
+
return [2 /*return*/, Number(valorEsquerdo) % Number(valorDireito)];
|
|
246
|
+
case delegua_1.default.BIT_AND:
|
|
247
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
248
|
+
return [2 /*return*/, Number(valorEsquerdo) & Number(valorDireito)];
|
|
249
|
+
case delegua_1.default.BIT_XOR:
|
|
250
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
251
|
+
return [2 /*return*/, Number(valorEsquerdo) ^ Number(valorDireito)];
|
|
252
|
+
case delegua_1.default.BIT_OR:
|
|
253
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
254
|
+
return [2 /*return*/, Number(valorEsquerdo) | Number(valorDireito)];
|
|
255
|
+
case delegua_1.default.MENOR_MENOR:
|
|
256
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
257
|
+
return [2 /*return*/, Number(valorEsquerdo) << Number(valorDireito)];
|
|
258
|
+
case delegua_1.default.MAIOR_MAIOR:
|
|
259
|
+
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
260
|
+
return [2 /*return*/, Number(valorEsquerdo) >> Number(valorDireito)];
|
|
261
|
+
case delegua_1.default.DIFERENTE:
|
|
262
|
+
return [2 /*return*/, !this.eIgual(valorEsquerdo, valorDireito)];
|
|
263
|
+
case delegua_1.default.IGUAL_IGUAL:
|
|
264
|
+
return [2 /*return*/, this.eIgual(valorEsquerdo, valorDireito)];
|
|
265
|
+
}
|
|
266
|
+
return [2 /*return*/, null];
|
|
267
|
+
case 3:
|
|
268
|
+
erro_1 = _a.sent();
|
|
269
|
+
return [2 /*return*/, Promise.reject(erro_1)];
|
|
270
|
+
case 4: return [2 /*return*/];
|
|
160
271
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
164
|
-
return Number(valorEsquerdo) / Number(valorDireito);
|
|
165
|
-
case delegua_1.default.MULTIPLICACAO:
|
|
166
|
-
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
167
|
-
return Number(valorEsquerdo) * Number(valorDireito);
|
|
168
|
-
case delegua_1.default.MODULO:
|
|
169
|
-
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
170
|
-
return Number(valorEsquerdo) % Number(valorDireito);
|
|
171
|
-
case delegua_1.default.BIT_AND:
|
|
172
|
-
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
173
|
-
return Number(valorEsquerdo) & Number(valorDireito);
|
|
174
|
-
case delegua_1.default.BIT_XOR:
|
|
175
|
-
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
176
|
-
return Number(valorEsquerdo) ^ Number(valorDireito);
|
|
177
|
-
case delegua_1.default.BIT_OR:
|
|
178
|
-
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
179
|
-
return Number(valorEsquerdo) | Number(valorDireito);
|
|
180
|
-
case delegua_1.default.MENOR_MENOR:
|
|
181
|
-
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
182
|
-
return Number(valorEsquerdo) << Number(valorDireito);
|
|
183
|
-
case delegua_1.default.MAIOR_MAIOR:
|
|
184
|
-
this.verificarOperandosNumeros(expressao.operador, esquerda, direita);
|
|
185
|
-
return Number(valorEsquerdo) >> Number(valorDireito);
|
|
186
|
-
case delegua_1.default.DIFERENTE:
|
|
187
|
-
return !this.eIgual(valorEsquerdo, valorDireito);
|
|
188
|
-
case delegua_1.default.IGUAL_IGUAL:
|
|
189
|
-
return this.eIgual(valorEsquerdo, valorDireito);
|
|
190
|
-
}
|
|
191
|
-
return null;
|
|
272
|
+
});
|
|
273
|
+
});
|
|
192
274
|
};
|
|
193
275
|
InterpretadorEguaClassico.prototype.visitarExpressaoDeChamada = function (expressao) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
+
var variavelEntidadeChamada, entidadeChamada, argumentos, i, _a, _b, parametros, diferenca, i, novosArgumentos;
|
|
278
|
+
return __generator(this, function (_c) {
|
|
279
|
+
switch (_c.label) {
|
|
280
|
+
case 0: return [4 /*yield*/, this.avaliar(expressao.entidadeChamada)];
|
|
281
|
+
case 1:
|
|
282
|
+
variavelEntidadeChamada = _c.sent();
|
|
283
|
+
entidadeChamada = variavelEntidadeChamada.hasOwnProperty('valor')
|
|
284
|
+
? variavelEntidadeChamada.valor
|
|
285
|
+
: variavelEntidadeChamada;
|
|
286
|
+
argumentos = [];
|
|
287
|
+
i = 0;
|
|
288
|
+
_c.label = 2;
|
|
289
|
+
case 2:
|
|
290
|
+
if (!(i < expressao.argumentos.length)) return [3 /*break*/, 5];
|
|
291
|
+
_b = (_a = argumentos).push;
|
|
292
|
+
return [4 /*yield*/, this.avaliar(expressao.argumentos[i])];
|
|
293
|
+
case 3:
|
|
294
|
+
_b.apply(_a, [_c.sent()]);
|
|
295
|
+
_c.label = 4;
|
|
296
|
+
case 4:
|
|
297
|
+
i++;
|
|
298
|
+
return [3 /*break*/, 2];
|
|
299
|
+
case 5:
|
|
300
|
+
if (!(entidadeChamada instanceof chamavel_1.Chamavel)) {
|
|
301
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.parentese, 'Só pode chamar função ou classe.', expressao.linha);
|
|
302
|
+
}
|
|
303
|
+
if (entidadeChamada instanceof funcao_1.DeleguaFuncao) {
|
|
304
|
+
parametros = entidadeChamada.declaracao.parametros;
|
|
305
|
+
}
|
|
306
|
+
else if (entidadeChamada instanceof delegua_classe_1.DeleguaClasse) {
|
|
307
|
+
parametros = entidadeChamada.metodos.inicializacao
|
|
308
|
+
? entidadeChamada.metodos.inicializacao.declaracao.parametros
|
|
309
|
+
: [];
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
parametros = [];
|
|
313
|
+
}
|
|
314
|
+
// Isso aqui completa os parâmetros não preenchidos com nulos.
|
|
315
|
+
if (argumentos.length < entidadeChamada.aridade()) {
|
|
316
|
+
diferenca = entidadeChamada.aridade() - argumentos.length;
|
|
317
|
+
for (i = 0; i < diferenca; i++) {
|
|
318
|
+
argumentos.push(null);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
if (parametros &&
|
|
323
|
+
parametros.length > 0 &&
|
|
324
|
+
parametros[parametros.length - 1]['tipo'] === 'estrela') {
|
|
325
|
+
novosArgumentos = argumentos.slice(0, parametros.length - 1);
|
|
326
|
+
novosArgumentos.push(argumentos.slice(parametros.length - 1, argumentos.length));
|
|
327
|
+
argumentos = novosArgumentos;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (entidadeChamada instanceof funcao_padrao_1.FuncaoPadrao) {
|
|
331
|
+
return [2 /*return*/, entidadeChamada.chamar(argumentos, expressao.entidadeChamada.nome)];
|
|
332
|
+
}
|
|
333
|
+
return [2 /*return*/, entidadeChamada.chamar(this, argumentos)];
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
});
|
|
235
337
|
};
|
|
236
338
|
InterpretadorEguaClassico.prototype.visitarExpressaoDeAtribuicao = function (expressao) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
339
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
340
|
+
var valor;
|
|
341
|
+
return __generator(this, function (_a) {
|
|
342
|
+
switch (_a.label) {
|
|
343
|
+
case 0: return [4 /*yield*/, this.avaliar(expressao.valor)];
|
|
344
|
+
case 1:
|
|
345
|
+
valor = _a.sent();
|
|
346
|
+
this.pilhaEscoposExecucao.atribuirVariavel(expressao.simbolo, valor);
|
|
347
|
+
return [2 /*return*/, valor];
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
});
|
|
240
351
|
};
|
|
241
352
|
InterpretadorEguaClassico.prototype.procurarVariavel = function (simbolo, expressao) {
|
|
242
353
|
return this.pilhaEscoposExecucao.obterVariavel(simbolo);
|
|
@@ -245,187 +356,360 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
245
356
|
return this.procurarVariavel(expressao.simbolo, expressao);
|
|
246
357
|
};
|
|
247
358
|
InterpretadorEguaClassico.prototype.visitarDeclaracaoDeExpressao = function (declaracao) {
|
|
248
|
-
return this
|
|
359
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
360
|
+
return __generator(this, function (_a) {
|
|
361
|
+
switch (_a.label) {
|
|
362
|
+
case 0: return [4 /*yield*/, this.avaliar(declaracao.expressao)];
|
|
363
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
});
|
|
249
367
|
};
|
|
250
368
|
InterpretadorEguaClassico.prototype.visitarExpressaoLogica = function (expressao) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
369
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
370
|
+
var esquerda, direita;
|
|
371
|
+
return __generator(this, function (_a) {
|
|
372
|
+
switch (_a.label) {
|
|
373
|
+
case 0: return [4 /*yield*/, this.avaliar(expressao.esquerda)];
|
|
374
|
+
case 1:
|
|
375
|
+
esquerda = _a.sent();
|
|
376
|
+
if (!(expressao.operador.tipo === delegua_1.default.EM)) return [3 /*break*/, 3];
|
|
377
|
+
return [4 /*yield*/, this.avaliar(expressao.direita)];
|
|
378
|
+
case 2:
|
|
379
|
+
direita = _a.sent();
|
|
380
|
+
if (Array.isArray(direita) || typeof direita === 'string') {
|
|
381
|
+
return [2 /*return*/, direita.includes(esquerda)];
|
|
382
|
+
}
|
|
383
|
+
else if (direita.constructor === Object) {
|
|
384
|
+
return [2 /*return*/, esquerda in direita];
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(esquerda, "Tipo de chamada inválida com 'em'.", expressao.linha);
|
|
388
|
+
}
|
|
389
|
+
_a.label = 3;
|
|
390
|
+
case 3:
|
|
391
|
+
// se um estado for verdadeiro, retorna verdadeiro
|
|
392
|
+
if (expressao.operador.tipo === delegua_1.default.OU) {
|
|
393
|
+
if (this.eVerdadeiro(esquerda))
|
|
394
|
+
return [2 /*return*/, esquerda];
|
|
395
|
+
}
|
|
396
|
+
// se um estado for falso, retorna falso
|
|
397
|
+
if (expressao.operador.tipo === delegua_1.default.E) {
|
|
398
|
+
if (!this.eVerdadeiro(esquerda))
|
|
399
|
+
return [2 /*return*/, esquerda];
|
|
400
|
+
}
|
|
401
|
+
return [4 /*yield*/, this.avaliar(expressao.direita)];
|
|
402
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
});
|
|
275
406
|
};
|
|
276
407
|
InterpretadorEguaClassico.prototype.visitarExpressaoSe = function (declaracao) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
408
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
409
|
+
var _a, i, atual, _b;
|
|
410
|
+
return __generator(this, function (_c) {
|
|
411
|
+
switch (_c.label) {
|
|
412
|
+
case 0:
|
|
413
|
+
_a = this.eVerdadeiro;
|
|
414
|
+
return [4 /*yield*/, this.avaliar(declaracao.condicao)];
|
|
415
|
+
case 1:
|
|
416
|
+
if (!_a.apply(this, [_c.sent()])) return [3 /*break*/, 3];
|
|
417
|
+
return [4 /*yield*/, this.executar(declaracao.caminhoEntao)];
|
|
418
|
+
case 2: return [2 /*return*/, _c.sent()];
|
|
419
|
+
case 3:
|
|
420
|
+
i = 0;
|
|
421
|
+
_c.label = 4;
|
|
422
|
+
case 4:
|
|
423
|
+
if (!(i < declaracao.caminhosSeSenao.length)) return [3 /*break*/, 8];
|
|
424
|
+
atual = declaracao.caminhosSeSenao[i];
|
|
425
|
+
_b = this.eVerdadeiro;
|
|
426
|
+
return [4 /*yield*/, this.avaliar(atual.condicao)];
|
|
427
|
+
case 5:
|
|
428
|
+
if (!_b.apply(this, [_c.sent()])) return [3 /*break*/, 7];
|
|
429
|
+
return [4 /*yield*/, this.executar(atual.caminho)];
|
|
430
|
+
case 6: return [2 /*return*/, _c.sent()];
|
|
431
|
+
case 7:
|
|
432
|
+
i++;
|
|
433
|
+
return [3 /*break*/, 4];
|
|
434
|
+
case 8:
|
|
435
|
+
if (!(declaracao.caminhoSenao !== null)) return [3 /*break*/, 10];
|
|
436
|
+
return [4 /*yield*/, this.executar(declaracao.caminhoSenao)];
|
|
437
|
+
case 9: return [2 /*return*/, _c.sent()];
|
|
438
|
+
case 10: return [2 /*return*/, null];
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
});
|
|
290
442
|
};
|
|
291
443
|
InterpretadorEguaClassico.prototype.visitarExpressaoPara = function (declaracao) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
444
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
445
|
+
var _a, erro_2;
|
|
446
|
+
return __generator(this, function (_b) {
|
|
447
|
+
switch (_b.label) {
|
|
448
|
+
case 0:
|
|
449
|
+
if (!(declaracao.inicializador !== null)) return [3 /*break*/, 2];
|
|
450
|
+
return [4 /*yield*/, this.avaliar(declaracao.inicializador)];
|
|
451
|
+
case 1:
|
|
452
|
+
_b.sent();
|
|
453
|
+
_b.label = 2;
|
|
454
|
+
case 2:
|
|
455
|
+
if (!true) return [3 /*break*/, 10];
|
|
456
|
+
if (!(declaracao.condicao !== null)) return [3 /*break*/, 4];
|
|
457
|
+
_a = this.eVerdadeiro;
|
|
458
|
+
return [4 /*yield*/, this.avaliar(declaracao.condicao)];
|
|
459
|
+
case 3:
|
|
460
|
+
if (!_a.apply(this, [_b.sent()])) {
|
|
461
|
+
return [3 /*break*/, 10];
|
|
462
|
+
}
|
|
463
|
+
_b.label = 4;
|
|
464
|
+
case 4:
|
|
465
|
+
_b.trys.push([4, 6, , 7]);
|
|
466
|
+
return [4 /*yield*/, this.executar(declaracao.corpo)];
|
|
467
|
+
case 5:
|
|
468
|
+
_b.sent();
|
|
469
|
+
return [3 /*break*/, 7];
|
|
470
|
+
case 6:
|
|
471
|
+
erro_2 = _b.sent();
|
|
472
|
+
throw erro_2;
|
|
473
|
+
case 7:
|
|
474
|
+
if (!(declaracao.incrementar !== null)) return [3 /*break*/, 9];
|
|
475
|
+
return [4 /*yield*/, this.avaliar(declaracao.incrementar)];
|
|
476
|
+
case 8:
|
|
477
|
+
_b.sent();
|
|
478
|
+
_b.label = 9;
|
|
479
|
+
case 9: return [3 /*break*/, 2];
|
|
480
|
+
case 10: return [2 /*return*/, null];
|
|
299
481
|
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
this.executar(declaracao.corpo);
|
|
303
|
-
}
|
|
304
|
-
catch (erro) {
|
|
305
|
-
throw erro;
|
|
306
|
-
}
|
|
307
|
-
if (declaracao.incrementar !== null) {
|
|
308
|
-
this.avaliar(declaracao.incrementar);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
return null;
|
|
482
|
+
});
|
|
483
|
+
});
|
|
312
484
|
};
|
|
313
485
|
InterpretadorEguaClassico.prototype.visitarExpressaoFazer = function (declaracao) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
486
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
487
|
+
var erro_3, _a;
|
|
488
|
+
return __generator(this, function (_b) {
|
|
489
|
+
switch (_b.label) {
|
|
490
|
+
case 0:
|
|
491
|
+
_b.trys.push([0, 2, , 3]);
|
|
492
|
+
return [4 /*yield*/, this.executar(declaracao.caminhoFazer)];
|
|
493
|
+
case 1:
|
|
494
|
+
_b.sent();
|
|
495
|
+
return [3 /*break*/, 3];
|
|
496
|
+
case 2:
|
|
497
|
+
erro_3 = _b.sent();
|
|
498
|
+
throw erro_3;
|
|
499
|
+
case 3:
|
|
500
|
+
_a = this.eVerdadeiro;
|
|
501
|
+
return [4 /*yield*/, this.avaliar(declaracao.condicaoEnquanto)];
|
|
502
|
+
case 4:
|
|
503
|
+
if (_a.apply(this, [_b.sent()])) return [3 /*break*/, 0];
|
|
504
|
+
_b.label = 5;
|
|
505
|
+
case 5: return [2 /*return*/];
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
});
|
|
322
509
|
};
|
|
323
510
|
InterpretadorEguaClassico.prototype.visitarExpressaoEscolha = function (declaracao) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
511
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
512
|
+
var condicaoEscolha, caminhos, caminhoPadrao, encontrado, i, caminho_1, j, k, erro_4, i, erro_5;
|
|
513
|
+
return __generator(this, function (_a) {
|
|
514
|
+
switch (_a.label) {
|
|
515
|
+
case 0: return [4 /*yield*/, this.avaliar(declaracao.identificadorOuLiteral)];
|
|
516
|
+
case 1:
|
|
517
|
+
condicaoEscolha = _a.sent();
|
|
518
|
+
caminhos = declaracao.caminhos;
|
|
519
|
+
caminhoPadrao = declaracao.caminhoPadrao;
|
|
520
|
+
encontrado = false;
|
|
521
|
+
_a.label = 2;
|
|
522
|
+
case 2:
|
|
523
|
+
_a.trys.push([2, 19, , 20]);
|
|
524
|
+
i = 0;
|
|
525
|
+
_a.label = 3;
|
|
526
|
+
case 3:
|
|
527
|
+
if (!(i < caminhos.length)) return [3 /*break*/, 14];
|
|
528
|
+
caminho_1 = caminhos[i];
|
|
529
|
+
j = 0;
|
|
530
|
+
_a.label = 4;
|
|
531
|
+
case 4:
|
|
532
|
+
if (!(j < caminho_1.condicoes.length)) return [3 /*break*/, 13];
|
|
533
|
+
return [4 /*yield*/, this.avaliar(caminho_1.condicoes[j])];
|
|
534
|
+
case 5:
|
|
535
|
+
if (!((_a.sent()) === condicaoEscolha)) return [3 /*break*/, 12];
|
|
333
536
|
encontrado = true;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
537
|
+
_a.label = 6;
|
|
538
|
+
case 6:
|
|
539
|
+
_a.trys.push([6, 11, , 12]);
|
|
540
|
+
k = 0;
|
|
541
|
+
_a.label = 7;
|
|
542
|
+
case 7:
|
|
543
|
+
if (!(k < caminho_1.declaracoes.length)) return [3 /*break*/, 10];
|
|
544
|
+
return [4 /*yield*/, this.executar(caminho_1.declaracoes[k])];
|
|
545
|
+
case 8:
|
|
546
|
+
_a.sent();
|
|
547
|
+
_a.label = 9;
|
|
548
|
+
case 9:
|
|
549
|
+
k++;
|
|
550
|
+
return [3 /*break*/, 7];
|
|
551
|
+
case 10: return [3 /*break*/, 12];
|
|
552
|
+
case 11:
|
|
553
|
+
erro_4 = _a.sent();
|
|
554
|
+
throw erro_4;
|
|
555
|
+
case 12:
|
|
556
|
+
j++;
|
|
557
|
+
return [3 /*break*/, 4];
|
|
558
|
+
case 13:
|
|
559
|
+
i++;
|
|
560
|
+
return [3 /*break*/, 3];
|
|
561
|
+
case 14:
|
|
562
|
+
if (!(caminhoPadrao !== null && encontrado === false)) return [3 /*break*/, 18];
|
|
563
|
+
i = 0;
|
|
564
|
+
_a.label = 15;
|
|
565
|
+
case 15:
|
|
566
|
+
if (!(i < caminhoPadrao.declaracoes.length)) return [3 /*break*/, 18];
|
|
567
|
+
return [4 /*yield*/, this.executar(caminhoPadrao['declaracoes'][i])];
|
|
568
|
+
case 16:
|
|
569
|
+
_a.sent();
|
|
570
|
+
_a.label = 17;
|
|
571
|
+
case 17:
|
|
572
|
+
i++;
|
|
573
|
+
return [3 /*break*/, 15];
|
|
574
|
+
case 18: return [3 /*break*/, 20];
|
|
575
|
+
case 19:
|
|
576
|
+
erro_5 = _a.sent();
|
|
577
|
+
throw erro_5;
|
|
578
|
+
case 20: return [2 /*return*/];
|
|
348
579
|
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
catch (erro) {
|
|
352
|
-
throw erro;
|
|
353
|
-
}
|
|
580
|
+
});
|
|
581
|
+
});
|
|
354
582
|
};
|
|
355
583
|
InterpretadorEguaClassico.prototype.visitarExpressaoTente = function (declaracao) {
|
|
356
|
-
|
|
357
|
-
var sucesso
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
584
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
585
|
+
var sucesso, erro_6;
|
|
586
|
+
return __generator(this, function (_a) {
|
|
587
|
+
switch (_a.label) {
|
|
588
|
+
case 0:
|
|
589
|
+
_a.trys.push([0, , 10, 13]);
|
|
590
|
+
sucesso = true;
|
|
591
|
+
_a.label = 1;
|
|
592
|
+
case 1:
|
|
593
|
+
_a.trys.push([1, 3, , 7]);
|
|
594
|
+
return [4 /*yield*/, this.executarBloco(declaracao.caminhoTente)];
|
|
595
|
+
case 2:
|
|
596
|
+
_a.sent();
|
|
597
|
+
return [3 /*break*/, 7];
|
|
598
|
+
case 3:
|
|
599
|
+
erro_6 = _a.sent();
|
|
600
|
+
sucesso = false;
|
|
601
|
+
if (!(declaracao.caminhoPegue !== null)) return [3 /*break*/, 5];
|
|
602
|
+
return [4 /*yield*/, this.executarBloco(declaracao.caminhoPegue)];
|
|
603
|
+
case 4:
|
|
604
|
+
_a.sent();
|
|
605
|
+
return [3 /*break*/, 6];
|
|
606
|
+
case 5:
|
|
607
|
+
this.erros.push(erro_6);
|
|
608
|
+
_a.label = 6;
|
|
609
|
+
case 6: return [3 /*break*/, 7];
|
|
610
|
+
case 7:
|
|
611
|
+
if (!(sucesso && declaracao.caminhoSenao !== null)) return [3 /*break*/, 9];
|
|
612
|
+
return [4 /*yield*/, this.executarBloco(declaracao.caminhoSenao)];
|
|
613
|
+
case 8:
|
|
614
|
+
_a.sent();
|
|
615
|
+
_a.label = 9;
|
|
616
|
+
case 9: return [3 /*break*/, 13];
|
|
617
|
+
case 10:
|
|
618
|
+
if (!(declaracao.caminhoFinalmente !== null)) return [3 /*break*/, 12];
|
|
619
|
+
return [4 /*yield*/, this.executarBloco(declaracao.caminhoFinalmente)];
|
|
620
|
+
case 11:
|
|
621
|
+
_a.sent();
|
|
622
|
+
_a.label = 12;
|
|
623
|
+
case 12: return [7 /*endfinally*/];
|
|
624
|
+
case 13: return [2 /*return*/];
|
|
365
625
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
if (sucesso && declaracao.caminhoSenao !== null) {
|
|
371
|
-
this.executarBloco(declaracao.caminhoSenao);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
finally {
|
|
375
|
-
if (declaracao.caminhoFinalmente !== null)
|
|
376
|
-
this.executarBloco(declaracao.caminhoFinalmente);
|
|
377
|
-
}
|
|
626
|
+
});
|
|
627
|
+
});
|
|
378
628
|
};
|
|
379
629
|
InterpretadorEguaClassico.prototype.visitarExpressaoEnquanto = function (declaracao) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
630
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
631
|
+
var _a, erro_7;
|
|
632
|
+
return __generator(this, function (_b) {
|
|
633
|
+
switch (_b.label) {
|
|
634
|
+
case 0:
|
|
635
|
+
_a = this.eVerdadeiro;
|
|
636
|
+
return [4 /*yield*/, this.avaliar(declaracao.condicao)];
|
|
637
|
+
case 1:
|
|
638
|
+
if (!_a.apply(this, [_b.sent()])) return [3 /*break*/, 6];
|
|
639
|
+
_b.label = 2;
|
|
640
|
+
case 2:
|
|
641
|
+
_b.trys.push([2, 4, , 5]);
|
|
642
|
+
return [4 /*yield*/, this.executar(declaracao.corpo)];
|
|
643
|
+
case 3:
|
|
644
|
+
_b.sent();
|
|
645
|
+
return [3 /*break*/, 5];
|
|
646
|
+
case 4:
|
|
647
|
+
erro_7 = _b.sent();
|
|
648
|
+
throw erro_7;
|
|
649
|
+
case 5: return [3 /*break*/, 0];
|
|
650
|
+
case 6: return [2 /*return*/, null];
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
});
|
|
389
654
|
};
|
|
390
655
|
InterpretadorEguaClassico.prototype.visitarExpressaoImportar = function (declaracao) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
656
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
657
|
+
var caminhoRelativo, caminhoTotal, dados, delegua, exportar, eDicionario, novoModulo, chaves, i;
|
|
658
|
+
return __generator(this, function (_a) {
|
|
659
|
+
switch (_a.label) {
|
|
660
|
+
case 0: return [4 /*yield*/, this.avaliar(declaracao.caminho)];
|
|
661
|
+
case 1:
|
|
662
|
+
caminhoRelativo = _a.sent();
|
|
663
|
+
caminhoTotal = caminho.join(this.diretorioBase, caminhoRelativo);
|
|
664
|
+
dados = (0, importar_biblioteca_1.default)(caminhoRelativo);
|
|
665
|
+
if (dados)
|
|
666
|
+
return [2 /*return*/, dados];
|
|
667
|
+
try {
|
|
668
|
+
if (!fs.existsSync(caminhoTotal)) {
|
|
669
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(declaracao.simboloFechamento, 'Não foi possível encontrar arquivo importado.', declaracao.linha);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
catch (erro) {
|
|
673
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(declaracao.simboloFechamento, 'Não foi possível ler o arquivo.', declaracao.linha);
|
|
674
|
+
}
|
|
675
|
+
dados = fs.readFileSync(caminhoTotal).toString();
|
|
676
|
+
delegua = new delegua_2.Delegua(this.Delegua.dialeto, false);
|
|
677
|
+
delegua.executar(dados);
|
|
678
|
+
exportar = this.pilhaEscoposExecucao.obterTodasDeleguaFuncao();
|
|
679
|
+
eDicionario = function (objeto) { return objeto.constructor === Object; };
|
|
680
|
+
if (eDicionario(exportar)) {
|
|
681
|
+
novoModulo = new modulo_1.DeleguaModulo();
|
|
682
|
+
chaves = Object.keys(exportar);
|
|
683
|
+
for (i = 0; i < chaves.length; i++) {
|
|
684
|
+
novoModulo[chaves[i]] = exportar[chaves[i]];
|
|
685
|
+
}
|
|
686
|
+
return [2 /*return*/, novoModulo];
|
|
687
|
+
}
|
|
688
|
+
return [2 /*return*/, exportar];
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
});
|
|
419
692
|
};
|
|
420
693
|
InterpretadorEguaClassico.prototype.visitarExpressaoEscreva = function (declaracao) {
|
|
421
|
-
|
|
422
|
-
var valor
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
694
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
695
|
+
var valor, erro_8;
|
|
696
|
+
return __generator(this, function (_a) {
|
|
697
|
+
switch (_a.label) {
|
|
698
|
+
case 0:
|
|
699
|
+
_a.trys.push([0, 2, , 3]);
|
|
700
|
+
return [4 /*yield*/, this.avaliar(declaracao.argumentos[0])];
|
|
701
|
+
case 1:
|
|
702
|
+
valor = _a.sent();
|
|
703
|
+
console.log(this.paraTexto(valor));
|
|
704
|
+
return [2 /*return*/, null];
|
|
705
|
+
case 2:
|
|
706
|
+
erro_8 = _a.sent();
|
|
707
|
+
this.erros.push(erro_8);
|
|
708
|
+
return [3 /*break*/, 3];
|
|
709
|
+
case 3: return [2 /*return*/];
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
});
|
|
429
713
|
};
|
|
430
714
|
/**
|
|
431
715
|
* Empilha declarações na pilha de escopos de execução, cria um novo ambiente e
|
|
@@ -438,20 +722,37 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
438
722
|
* @param ambiente O ambiente de execução quando houver, como parâmetros, argumentos, etc.
|
|
439
723
|
*/
|
|
440
724
|
InterpretadorEguaClassico.prototype.executarBloco = function (declaracoes, ambiente) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
725
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
726
|
+
var escopoExecucao, retornoUltimoEscopo;
|
|
727
|
+
return __generator(this, function (_a) {
|
|
728
|
+
switch (_a.label) {
|
|
729
|
+
case 0:
|
|
730
|
+
escopoExecucao = {
|
|
731
|
+
declaracoes: declaracoes,
|
|
732
|
+
declaracaoAtual: 0,
|
|
733
|
+
ambiente: ambiente || new espaco_variaveis_1.EspacoVariaveis(),
|
|
734
|
+
};
|
|
735
|
+
this.pilhaEscoposExecucao.empilhar(escopoExecucao);
|
|
736
|
+
return [4 /*yield*/, this.executarUltimoEscopo()];
|
|
737
|
+
case 1:
|
|
738
|
+
retornoUltimoEscopo = _a.sent();
|
|
739
|
+
if (retornoUltimoEscopo instanceof excecoes_1.ErroEmTempoDeExecucao) {
|
|
740
|
+
throw retornoUltimoEscopo;
|
|
741
|
+
}
|
|
742
|
+
return [2 /*return*/, retornoUltimoEscopo];
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
});
|
|
452
746
|
};
|
|
453
747
|
InterpretadorEguaClassico.prototype.visitarExpressaoBloco = function (declaracao) {
|
|
454
|
-
return this
|
|
748
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
749
|
+
return __generator(this, function (_a) {
|
|
750
|
+
switch (_a.label) {
|
|
751
|
+
case 0: return [4 /*yield*/, this.executarBloco(declaracao.declaracoes)];
|
|
752
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
});
|
|
455
756
|
};
|
|
456
757
|
/**
|
|
457
758
|
* Executa expressão de definição de variável.
|
|
@@ -459,12 +760,25 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
459
760
|
* @returns Sempre retorna nulo.
|
|
460
761
|
*/
|
|
461
762
|
InterpretadorEguaClassico.prototype.visitarExpressaoVar = function (declaracao) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
763
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
764
|
+
var valorOuOutraVariavel;
|
|
765
|
+
return __generator(this, function (_a) {
|
|
766
|
+
switch (_a.label) {
|
|
767
|
+
case 0:
|
|
768
|
+
valorOuOutraVariavel = null;
|
|
769
|
+
if (!(declaracao.inicializador !== null)) return [3 /*break*/, 2];
|
|
770
|
+
return [4 /*yield*/, this.avaliar(declaracao.inicializador)];
|
|
771
|
+
case 1:
|
|
772
|
+
valorOuOutraVariavel = _a.sent();
|
|
773
|
+
_a.label = 2;
|
|
774
|
+
case 2:
|
|
775
|
+
this.pilhaEscoposExecucao.definirVariavel(declaracao.simbolo.lexema, valorOuOutraVariavel.hasOwnProperty('valor')
|
|
776
|
+
? valorOuOutraVariavel.valor
|
|
777
|
+
: valorOuOutraVariavel);
|
|
778
|
+
return [2 /*return*/, null];
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
});
|
|
468
782
|
};
|
|
469
783
|
InterpretadorEguaClassico.prototype.visitarExpressaoContinua = function (declaracao) {
|
|
470
784
|
return new quebras_1.ContinuarQuebra();
|
|
@@ -473,161 +787,270 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
473
787
|
return new quebras_1.SustarQuebra();
|
|
474
788
|
};
|
|
475
789
|
InterpretadorEguaClassico.prototype.visitarExpressaoRetornar = function (declaracao) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
790
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
791
|
+
var valor;
|
|
792
|
+
return __generator(this, function (_a) {
|
|
793
|
+
switch (_a.label) {
|
|
794
|
+
case 0:
|
|
795
|
+
valor = null;
|
|
796
|
+
if (!(declaracao.valor != null)) return [3 /*break*/, 2];
|
|
797
|
+
return [4 /*yield*/, this.avaliar(declaracao.valor)];
|
|
798
|
+
case 1:
|
|
799
|
+
valor = _a.sent();
|
|
800
|
+
_a.label = 2;
|
|
801
|
+
case 2: return [2 /*return*/, new quebras_1.RetornoQuebra(valor)];
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
});
|
|
480
805
|
};
|
|
481
806
|
InterpretadorEguaClassico.prototype.visitarExpressaoDeleguaFuncao = function (expressao) {
|
|
482
807
|
return new funcao_1.DeleguaFuncao(null, expressao);
|
|
483
808
|
};
|
|
484
809
|
InterpretadorEguaClassico.prototype.visitarExpressaoAtribuicaoSobrescrita = function (expressao) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
810
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
811
|
+
var objeto, indice, valor;
|
|
812
|
+
return __generator(this, function (_a) {
|
|
813
|
+
switch (_a.label) {
|
|
814
|
+
case 0: return [4 /*yield*/, this.avaliar(expressao.objeto)];
|
|
815
|
+
case 1:
|
|
816
|
+
objeto = _a.sent();
|
|
817
|
+
return [4 /*yield*/, this.avaliar(expressao.indice)];
|
|
818
|
+
case 2:
|
|
819
|
+
indice = _a.sent();
|
|
820
|
+
return [4 /*yield*/, this.avaliar(expressao.valor)];
|
|
821
|
+
case 3:
|
|
822
|
+
valor = _a.sent();
|
|
823
|
+
if (Array.isArray(objeto)) {
|
|
824
|
+
if (indice < 0 && objeto.length !== 0) {
|
|
825
|
+
while (indice < 0) {
|
|
826
|
+
indice += objeto.length;
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
while (objeto.length < indice) {
|
|
830
|
+
objeto.push(null);
|
|
831
|
+
}
|
|
832
|
+
objeto[indice] = valor;
|
|
833
|
+
}
|
|
834
|
+
else if (objeto.constructor === Object ||
|
|
835
|
+
objeto instanceof objeto_delegua_classe_1.ObjetoDeleguaClasse ||
|
|
836
|
+
objeto instanceof funcao_1.DeleguaFuncao ||
|
|
837
|
+
objeto instanceof delegua_classe_1.DeleguaClasse ||
|
|
838
|
+
objeto instanceof modulo_1.DeleguaModulo) {
|
|
839
|
+
objeto[indice] = valor;
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.objeto.nome, 'Somente listas, dicionários, classes e objetos podem ser mudados por sobrescrita.', expressao.linha);
|
|
843
|
+
}
|
|
844
|
+
return [2 /*return*/];
|
|
492
845
|
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
objeto.push(null);
|
|
496
|
-
}
|
|
497
|
-
objeto[indice] = valor;
|
|
498
|
-
}
|
|
499
|
-
else if (objeto.constructor === Object ||
|
|
500
|
-
objeto instanceof objeto_delegua_classe_1.ObjetoDeleguaClasse ||
|
|
501
|
-
objeto instanceof funcao_1.DeleguaFuncao ||
|
|
502
|
-
objeto instanceof delegua_classe_1.DeleguaClasse ||
|
|
503
|
-
objeto instanceof modulo_1.DeleguaModulo) {
|
|
504
|
-
objeto[indice] = valor;
|
|
505
|
-
}
|
|
506
|
-
else {
|
|
507
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.objeto.nome, 'Somente listas, dicionários, classes e objetos podem ser mudados por sobrescrita.', expressao.linha);
|
|
508
|
-
}
|
|
846
|
+
});
|
|
847
|
+
});
|
|
509
848
|
};
|
|
510
849
|
InterpretadorEguaClassico.prototype.visitarExpressaoAcessoIndiceVariavel = function (expressao) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
850
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
851
|
+
var variavelObjeto, objeto, indice, valorIndice;
|
|
852
|
+
return __generator(this, function (_a) {
|
|
853
|
+
switch (_a.label) {
|
|
854
|
+
case 0: return [4 /*yield*/, this.avaliar(expressao.entidadeChamada)];
|
|
855
|
+
case 1:
|
|
856
|
+
variavelObjeto = _a.sent();
|
|
857
|
+
objeto = variavelObjeto.hasOwnProperty('valor')
|
|
858
|
+
? variavelObjeto.valor
|
|
859
|
+
: variavelObjeto;
|
|
860
|
+
return [4 /*yield*/, this.avaliar(expressao.indice)];
|
|
861
|
+
case 2:
|
|
862
|
+
indice = _a.sent();
|
|
863
|
+
valorIndice = indice.hasOwnProperty('valor') ? indice.valor : indice;
|
|
864
|
+
if (Array.isArray(objeto)) {
|
|
865
|
+
if (!Number.isInteger(valorIndice)) {
|
|
866
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simboloFechamento, 'Somente inteiros podem ser usados para indexar um vetor.', expressao.linha);
|
|
867
|
+
}
|
|
868
|
+
if (indice < 0 && objeto.length !== 0) {
|
|
869
|
+
while (indice < 0) {
|
|
870
|
+
indice += objeto.length;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
if (indice >= objeto.length) {
|
|
874
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simboloFechamento, 'Índice do vetor fora do intervalo.', expressao.linha);
|
|
875
|
+
}
|
|
876
|
+
return [2 /*return*/, objeto[indice]];
|
|
877
|
+
}
|
|
878
|
+
else if (objeto.constructor === Object ||
|
|
879
|
+
objeto instanceof objeto_delegua_classe_1.ObjetoDeleguaClasse ||
|
|
880
|
+
objeto instanceof funcao_1.DeleguaFuncao ||
|
|
881
|
+
objeto instanceof delegua_classe_1.DeleguaClasse ||
|
|
882
|
+
objeto instanceof modulo_1.DeleguaModulo) {
|
|
883
|
+
return [2 /*return*/, objeto[indice] || null];
|
|
884
|
+
}
|
|
885
|
+
else if (typeof objeto === 'string') {
|
|
886
|
+
if (!Number.isInteger(indice)) {
|
|
887
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simboloFechamento, 'Somente inteiros podem ser usados para indexar um vetor.', expressao.linha);
|
|
888
|
+
}
|
|
889
|
+
if (indice < 0 && objeto.length !== 0) {
|
|
890
|
+
while (indice < 0) {
|
|
891
|
+
indice += objeto.length;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
if (indice >= objeto.length) {
|
|
895
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simboloFechamento, 'Índice fora do tamanho.', expressao.linha);
|
|
896
|
+
}
|
|
897
|
+
return [2 /*return*/, objeto.charAt(indice)];
|
|
898
|
+
}
|
|
899
|
+
else {
|
|
900
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.entidadeChamada.nome, 'Somente listas, dicionários, classes e objetos podem ser mudados por sobrescrita.', expressao.linha);
|
|
901
|
+
}
|
|
902
|
+
return [2 /*return*/];
|
|
542
903
|
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simboloFechamento, 'Índice fora do tamanho.', expressao.linha);
|
|
546
|
-
}
|
|
547
|
-
return objeto.charAt(indice);
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.entidadeChamada.nome, 'Somente listas, dicionários, classes e objetos podem ser mudados por sobrescrita.', expressao.linha);
|
|
551
|
-
}
|
|
904
|
+
});
|
|
905
|
+
});
|
|
552
906
|
};
|
|
553
907
|
InterpretadorEguaClassico.prototype.visitarExpressaoDefinir = function (expressao) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
908
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
909
|
+
var objeto, valor;
|
|
910
|
+
return __generator(this, function (_a) {
|
|
911
|
+
switch (_a.label) {
|
|
912
|
+
case 0: return [4 /*yield*/, this.avaliar(expressao.objeto)];
|
|
913
|
+
case 1:
|
|
914
|
+
objeto = _a.sent();
|
|
915
|
+
if (!(objeto instanceof objeto_delegua_classe_1.ObjetoDeleguaClasse) &&
|
|
916
|
+
objeto.constructor !== Object) {
|
|
917
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.objeto.nome, 'Somente instâncias e dicionários podem possuir campos.', expressao.linha);
|
|
918
|
+
}
|
|
919
|
+
return [4 /*yield*/, this.avaliar(expressao.valor)];
|
|
920
|
+
case 2:
|
|
921
|
+
valor = _a.sent();
|
|
922
|
+
if (objeto instanceof objeto_delegua_classe_1.ObjetoDeleguaClasse) {
|
|
923
|
+
objeto.set(expressao.nome, valor);
|
|
924
|
+
return [2 /*return*/, valor];
|
|
925
|
+
}
|
|
926
|
+
else if (objeto.constructor === Object) {
|
|
927
|
+
objeto[expressao.simbolo.lexema] = valor;
|
|
928
|
+
}
|
|
929
|
+
return [2 /*return*/];
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
});
|
|
567
933
|
};
|
|
568
934
|
InterpretadorEguaClassico.prototype.visitarExpressaoFuncao = function (declaracao) {
|
|
569
935
|
var funcao = new funcao_1.DeleguaFuncao(declaracao.simbolo.lexema, declaracao.funcao);
|
|
570
936
|
this.pilhaEscoposExecucao.definirVariavel(declaracao.simbolo.lexema, funcao);
|
|
571
937
|
};
|
|
572
938
|
InterpretadorEguaClassico.prototype.visitarExpressaoClasse = function (declaracao) {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
939
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
940
|
+
var superClasse, variavelSuperClasse, metodos, definirMetodos, i, metodoAtual, eInicializador, funcao, deleguaClasse;
|
|
941
|
+
return __generator(this, function (_a) {
|
|
942
|
+
switch (_a.label) {
|
|
943
|
+
case 0:
|
|
944
|
+
superClasse = null;
|
|
945
|
+
if (!(declaracao.superClasse !== null)) return [3 /*break*/, 2];
|
|
946
|
+
return [4 /*yield*/, this.avaliar(declaracao.superClasse)];
|
|
947
|
+
case 1:
|
|
948
|
+
variavelSuperClasse = _a.sent();
|
|
949
|
+
superClasse = variavelSuperClasse.valor;
|
|
950
|
+
if (!(superClasse instanceof delegua_classe_1.DeleguaClasse)) {
|
|
951
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(declaracao.superClasse.nome, 'SuperClasse precisa ser uma classe.', declaracao.linha);
|
|
952
|
+
}
|
|
953
|
+
_a.label = 2;
|
|
954
|
+
case 2:
|
|
955
|
+
this.pilhaEscoposExecucao.definirVariavel(declaracao.simbolo.lexema, null);
|
|
956
|
+
if (declaracao.superClasse !== null) {
|
|
957
|
+
this.pilhaEscoposExecucao.definirVariavel('super', superClasse);
|
|
958
|
+
}
|
|
959
|
+
metodos = {};
|
|
960
|
+
definirMetodos = declaracao.metodos;
|
|
961
|
+
for (i = 0; i < declaracao.metodos.length; i++) {
|
|
962
|
+
metodoAtual = definirMetodos[i];
|
|
963
|
+
eInicializador = metodoAtual.simbolo.lexema === 'construtor';
|
|
964
|
+
funcao = new funcao_1.DeleguaFuncao(metodoAtual.simbolo.lexema, metodoAtual.funcao, undefined, eInicializador);
|
|
965
|
+
metodos[metodoAtual.simbolo.lexema] = funcao;
|
|
966
|
+
}
|
|
967
|
+
deleguaClasse = new delegua_classe_1.DeleguaClasse(declaracao.simbolo.lexema, superClasse, metodos);
|
|
968
|
+
// TODO: Recolocar isso se for necessário.
|
|
969
|
+
/* if (superClasse !== null) {
|
|
970
|
+
this.ambiente = this.ambiente.enclosing;
|
|
971
|
+
} */
|
|
972
|
+
this.pilhaEscoposExecucao.atribuirVariavel(declaracao.simbolo, deleguaClasse);
|
|
973
|
+
return [2 /*return*/, null];
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
});
|
|
600
977
|
};
|
|
601
978
|
InterpretadorEguaClassico.prototype.visitarExpressaoAcessoMetodo = function (expressao) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
979
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
980
|
+
var variavelObjeto, objeto;
|
|
981
|
+
return __generator(this, function (_a) {
|
|
982
|
+
switch (_a.label) {
|
|
983
|
+
case 0: return [4 /*yield*/, this.avaliar(expressao.objeto)];
|
|
984
|
+
case 1:
|
|
985
|
+
variavelObjeto = _a.sent();
|
|
986
|
+
objeto = variavelObjeto === null || variavelObjeto === void 0 ? void 0 : variavelObjeto.valor;
|
|
987
|
+
if (objeto instanceof objeto_delegua_classe_1.ObjetoDeleguaClasse) {
|
|
988
|
+
return [2 /*return*/, objeto.get(expressao.simbolo) || null];
|
|
989
|
+
}
|
|
990
|
+
else if (objeto.constructor === Object) {
|
|
991
|
+
return [2 /*return*/, objeto[expressao.simbolo.lexema] || null];
|
|
992
|
+
}
|
|
993
|
+
else if (objeto instanceof modulo_1.DeleguaModulo) {
|
|
994
|
+
return [2 /*return*/, objeto[expressao.simbolo.lexema] || null];
|
|
995
|
+
}
|
|
996
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.nome, 'Você só pode acessar métodos do objeto e dicionários.', expressao.linha);
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
});
|
|
614
1000
|
};
|
|
615
1001
|
InterpretadorEguaClassico.prototype.visitarExpressaoIsto = function (expressao) {
|
|
616
1002
|
return this.procurarVariavel(expressao.palavraChave, expressao);
|
|
617
1003
|
};
|
|
618
1004
|
InterpretadorEguaClassico.prototype.visitarExpressaoDicionario = function (expressao) {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
1005
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1006
|
+
var dicionario, i, _a, _b;
|
|
1007
|
+
return __generator(this, function (_c) {
|
|
1008
|
+
switch (_c.label) {
|
|
1009
|
+
case 0:
|
|
1010
|
+
dicionario = {};
|
|
1011
|
+
i = 0;
|
|
1012
|
+
_c.label = 1;
|
|
1013
|
+
case 1:
|
|
1014
|
+
if (!(i < expressao.chaves.length)) return [3 /*break*/, 5];
|
|
1015
|
+
_a = dicionario;
|
|
1016
|
+
return [4 /*yield*/, this.avaliar(expressao.chaves[i])];
|
|
1017
|
+
case 2:
|
|
1018
|
+
_b = _c.sent();
|
|
1019
|
+
return [4 /*yield*/, this.avaliar(expressao.valores[i])];
|
|
1020
|
+
case 3:
|
|
1021
|
+
_a[_b] = _c.sent();
|
|
1022
|
+
_c.label = 4;
|
|
1023
|
+
case 4:
|
|
1024
|
+
i++;
|
|
1025
|
+
return [3 /*break*/, 1];
|
|
1026
|
+
case 5: return [2 /*return*/, dicionario];
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
});
|
|
624
1030
|
};
|
|
625
1031
|
InterpretadorEguaClassico.prototype.visitarExpressaoVetor = function (expressao) {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
1032
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1033
|
+
var valores, i, _a, _b;
|
|
1034
|
+
return __generator(this, function (_c) {
|
|
1035
|
+
switch (_c.label) {
|
|
1036
|
+
case 0:
|
|
1037
|
+
valores = [];
|
|
1038
|
+
i = 0;
|
|
1039
|
+
_c.label = 1;
|
|
1040
|
+
case 1:
|
|
1041
|
+
if (!(i < expressao.valores.length)) return [3 /*break*/, 4];
|
|
1042
|
+
_b = (_a = valores).push;
|
|
1043
|
+
return [4 /*yield*/, this.avaliar(expressao.valores[i])];
|
|
1044
|
+
case 2:
|
|
1045
|
+
_b.apply(_a, [_c.sent()]);
|
|
1046
|
+
_c.label = 3;
|
|
1047
|
+
case 3:
|
|
1048
|
+
i++;
|
|
1049
|
+
return [3 /*break*/, 1];
|
|
1050
|
+
case 4: return [2 /*return*/, valores];
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
});
|
|
631
1054
|
};
|
|
632
1055
|
InterpretadorEguaClassico.prototype.visitarExpressaoSuper = function (expressao) {
|
|
633
1056
|
var distancia = this.locais.get(expressao);
|
|
@@ -663,7 +1086,14 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
663
1086
|
};
|
|
664
1087
|
InterpretadorEguaClassico.prototype.executar = function (declaracao, mostrarResultado) {
|
|
665
1088
|
if (mostrarResultado === void 0) { mostrarResultado = false; }
|
|
666
|
-
return
|
|
1089
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1090
|
+
return __generator(this, function (_a) {
|
|
1091
|
+
switch (_a.label) {
|
|
1092
|
+
case 0: return [4 /*yield*/, declaracao.aceitar(this)];
|
|
1093
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
});
|
|
667
1097
|
};
|
|
668
1098
|
/**
|
|
669
1099
|
* Executa o último escopo empilhado no topo na pilha de escopos do Interpretador.
|
|
@@ -679,35 +1109,66 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
679
1109
|
* @returns O resultado da execução do escopo, se houver.
|
|
680
1110
|
*/
|
|
681
1111
|
InterpretadorEguaClassico.prototype.executarUltimoEscopo = function () {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
1112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1113
|
+
var ultimoEscopo, retornoExecucao, erro_9;
|
|
1114
|
+
return __generator(this, function (_a) {
|
|
1115
|
+
switch (_a.label) {
|
|
1116
|
+
case 0:
|
|
1117
|
+
ultimoEscopo = this.pilhaEscoposExecucao.topoDaPilha();
|
|
1118
|
+
_a.label = 1;
|
|
1119
|
+
case 1:
|
|
1120
|
+
_a.trys.push([1, 6, 7, 8]);
|
|
1121
|
+
retornoExecucao = void 0;
|
|
1122
|
+
_a.label = 2;
|
|
1123
|
+
case 2:
|
|
1124
|
+
if (!(!(retornoExecucao instanceof quebras_1.Quebra) &&
|
|
1125
|
+
ultimoEscopo.declaracaoAtual < ultimoEscopo.declaracoes.length)) return [3 /*break*/, 5];
|
|
1126
|
+
return [4 /*yield*/, this.executar(ultimoEscopo.declaracoes[ultimoEscopo.declaracaoAtual])];
|
|
1127
|
+
case 3:
|
|
1128
|
+
retornoExecucao = _a.sent();
|
|
1129
|
+
_a.label = 4;
|
|
1130
|
+
case 4:
|
|
1131
|
+
ultimoEscopo.declaracaoAtual++;
|
|
1132
|
+
return [3 /*break*/, 2];
|
|
1133
|
+
case 5: return [2 /*return*/, retornoExecucao];
|
|
1134
|
+
case 6:
|
|
1135
|
+
erro_9 = _a.sent();
|
|
1136
|
+
return [2 /*return*/, erro_9];
|
|
1137
|
+
case 7:
|
|
1138
|
+
this.pilhaEscoposExecucao.removerUltimo();
|
|
1139
|
+
return [7 /*endfinally*/];
|
|
1140
|
+
case 8: return [2 /*return*/];
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
});
|
|
696
1144
|
};
|
|
697
1145
|
InterpretadorEguaClassico.prototype.interpretar = function (declaracoes) {
|
|
698
|
-
this
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
1146
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1147
|
+
var retornoResolvedor, escopoExecucao;
|
|
1148
|
+
return __generator(this, function (_a) {
|
|
1149
|
+
switch (_a.label) {
|
|
1150
|
+
case 0:
|
|
1151
|
+
this.erros = [];
|
|
1152
|
+
retornoResolvedor = this.resolvedor.resolver(declaracoes);
|
|
1153
|
+
this.locais = retornoResolvedor.locais;
|
|
1154
|
+
escopoExecucao = {
|
|
1155
|
+
declaracoes: declaracoes,
|
|
1156
|
+
declaracaoAtual: 0,
|
|
1157
|
+
ambiente: new espaco_variaveis_1.EspacoVariaveis(),
|
|
1158
|
+
};
|
|
1159
|
+
this.pilhaEscoposExecucao.empilhar(escopoExecucao);
|
|
1160
|
+
return [4 /*yield*/, this.executarUltimoEscopo()];
|
|
1161
|
+
case 1:
|
|
1162
|
+
_a.sent();
|
|
1163
|
+
return [2 /*return*/, {
|
|
1164
|
+
erros: this.erros,
|
|
1165
|
+
}];
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
});
|
|
1169
|
+
};
|
|
1170
|
+
InterpretadorEguaClassico.prototype.finalizacao = function () {
|
|
1171
|
+
this.funcaoDeRetorno();
|
|
711
1172
|
};
|
|
712
1173
|
return InterpretadorEguaClassico;
|
|
713
1174
|
}());
|