@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
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
var delegua_1 = require("../fontes/delegua");
|
|
4
40
|
describe('Interpretador', function () {
|
|
@@ -9,99 +45,216 @@ describe('Interpretador', function () {
|
|
|
9
45
|
});
|
|
10
46
|
describe('Cenários de sucesso', function () {
|
|
11
47
|
describe('Atribuições', function () {
|
|
12
|
-
it('Trivial', function () {
|
|
13
|
-
var retornoLexador
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
it('Trivial', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
switch (_a.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
retornoLexador = delegua.lexador.mapear(["var a = 1"], -1);
|
|
54
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
55
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
56
|
+
case 1:
|
|
57
|
+
retornoInterpretador = _a.sent();
|
|
58
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
59
|
+
return [2 /*return*/];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}); });
|
|
63
|
+
it('Vetor', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
switch (_a.label) {
|
|
67
|
+
case 0:
|
|
68
|
+
retornoLexador = delegua.lexador.mapear(["var a = [1, 2, 3]"], -1);
|
|
69
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
70
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
71
|
+
case 1:
|
|
72
|
+
retornoInterpretador = _a.sent();
|
|
73
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
74
|
+
return [2 /*return*/];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}); });
|
|
78
|
+
it('Dicionário', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
switch (_a.label) {
|
|
82
|
+
case 0:
|
|
83
|
+
retornoLexador = delegua.lexador.mapear(["var a = {'a': 1, 'b': 2}"], -1);
|
|
84
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
85
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
86
|
+
case 1:
|
|
87
|
+
retornoInterpretador = _a.sent();
|
|
88
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
89
|
+
return [2 /*return*/];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}); });
|
|
93
|
+
it('Concatenação', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
94
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
switch (_a.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
retornoLexador = delegua.lexador.mapear(["var a = 1 + '1'"], -1);
|
|
99
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
100
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
101
|
+
case 1:
|
|
102
|
+
retornoInterpretador = _a.sent();
|
|
103
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
104
|
+
return [2 /*return*/];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}); });
|
|
108
|
+
it('Interpolação de Texto', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
retornoLexador = delegua.lexador.mapear([
|
|
114
|
+
"var comidaFavorita = 'strogonoff'",
|
|
115
|
+
'escreva("Minha comida favorita é ${comidaFavorita}")'
|
|
116
|
+
], -1);
|
|
117
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
118
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
119
|
+
case 1:
|
|
120
|
+
retornoInterpretador = _a.sent();
|
|
121
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
122
|
+
return [2 /*return*/];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}); });
|
|
45
126
|
});
|
|
46
127
|
describe('Acesso a variáveis e objetos', function () {
|
|
47
|
-
it('Acesso a elementos de vetor', function () {
|
|
48
|
-
var retornoLexador
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
128
|
+
it('Acesso a elementos de vetor', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
129
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
switch (_a.label) {
|
|
132
|
+
case 0:
|
|
133
|
+
retornoLexador = delegua.lexador.mapear([
|
|
134
|
+
"var a = [1, 2, 3]",
|
|
135
|
+
"escreva(a[1])"
|
|
136
|
+
], -1);
|
|
137
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
138
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
139
|
+
case 1:
|
|
140
|
+
retornoInterpretador = _a.sent();
|
|
141
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
142
|
+
return [2 /*return*/];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); });
|
|
146
|
+
it('Acesso a elementos de dicionário', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
147
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
retornoLexador = delegua.lexador.mapear([
|
|
152
|
+
"var a = {'a': 1, 'b': 2}",
|
|
153
|
+
"escreva(a['b'])"
|
|
154
|
+
], -1);
|
|
155
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
156
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
157
|
+
case 1:
|
|
158
|
+
retornoInterpretador = _a.sent();
|
|
159
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
160
|
+
return [2 /*return*/];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}); });
|
|
65
164
|
});
|
|
66
165
|
describe('escreva()', function () {
|
|
67
|
-
it('Olá Mundo (escreva() e literal)', function () {
|
|
68
|
-
var retornoLexador
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
166
|
+
it('Olá Mundo (escreva() e literal)', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
167
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
switch (_a.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
retornoLexador = delegua.lexador.mapear(["escreva('Olá mundo')"], -1);
|
|
172
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
173
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
174
|
+
case 1:
|
|
175
|
+
retornoInterpretador = _a.sent();
|
|
176
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
177
|
+
return [2 /*return*/];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}); });
|
|
181
|
+
it('nulo', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
182
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
183
|
+
return __generator(this, function (_a) {
|
|
184
|
+
switch (_a.label) {
|
|
185
|
+
case 0:
|
|
186
|
+
retornoLexador = delegua.lexador.mapear(["escreva(nulo)"], -1);
|
|
187
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
188
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
189
|
+
case 1:
|
|
190
|
+
retornoInterpretador = _a.sent();
|
|
191
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
192
|
+
return [2 /*return*/];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}); });
|
|
196
|
+
it('nulo igual a nulo', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0:
|
|
201
|
+
retornoLexador = delegua.lexador.mapear(["escreva(nulo == nulo)"], -1);
|
|
202
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
203
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
204
|
+
case 1:
|
|
205
|
+
retornoInterpretador = _a.sent();
|
|
206
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
207
|
+
return [2 /*return*/];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}); });
|
|
211
|
+
it('verdadeiro', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
212
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
213
|
+
return __generator(this, function (_a) {
|
|
214
|
+
switch (_a.label) {
|
|
215
|
+
case 0:
|
|
216
|
+
retornoLexador = delegua.lexador.mapear(["escreva(verdadeiro)"], -1);
|
|
217
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
218
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
219
|
+
case 1:
|
|
220
|
+
retornoInterpretador = _a.sent();
|
|
221
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
222
|
+
return [2 /*return*/];
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}); });
|
|
226
|
+
it('falso', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
227
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
228
|
+
return __generator(this, function (_a) {
|
|
229
|
+
switch (_a.label) {
|
|
230
|
+
case 0:
|
|
231
|
+
retornoLexador = delegua.lexador.mapear(["escreva(falso)"], -1);
|
|
232
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
233
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
234
|
+
case 1:
|
|
235
|
+
retornoInterpretador = _a.sent();
|
|
236
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
237
|
+
return [2 /*return*/];
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}); });
|
|
97
241
|
});
|
|
98
242
|
describe('Importar', function () {
|
|
99
|
-
it('Importar biblioteca externa', function () {
|
|
100
|
-
var retornoLexador
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
243
|
+
it('Importar biblioteca externa', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
244
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
245
|
+
return __generator(this, function (_a) {
|
|
246
|
+
switch (_a.label) {
|
|
247
|
+
case 0:
|
|
248
|
+
retornoLexador = delegua.lexador.mapear(["var commander = importar('commander')"], -1);
|
|
249
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
250
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
251
|
+
case 1:
|
|
252
|
+
retornoInterpretador = _a.sent();
|
|
253
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
254
|
+
return [2 /*return*/];
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}); });
|
|
105
258
|
describe('Importar bibliotecas delegua', function () {
|
|
106
259
|
describe('testa importação da biblioteca de estatística', function () {
|
|
107
260
|
beforeEach(function () {
|
|
@@ -110,18 +263,36 @@ describe('Interpretador', function () {
|
|
|
110
263
|
afterAll(function () {
|
|
111
264
|
jest.unmock("./__mocks__/estatistica.ts");
|
|
112
265
|
});
|
|
113
|
-
it('estatística', function () {
|
|
114
|
-
var retornoLexador
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
266
|
+
it('estatística', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
267
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
268
|
+
return __generator(this, function (_a) {
|
|
269
|
+
switch (_a.label) {
|
|
270
|
+
case 0:
|
|
271
|
+
retornoLexador = delegua.lexador.mapear(["var estatística = importar('estatística')"], -1);
|
|
272
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
273
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
274
|
+
case 1:
|
|
275
|
+
retornoInterpretador = _a.sent();
|
|
276
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
277
|
+
return [2 /*return*/];
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}); });
|
|
281
|
+
it('estatistica', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
282
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
283
|
+
return __generator(this, function (_a) {
|
|
284
|
+
switch (_a.label) {
|
|
285
|
+
case 0:
|
|
286
|
+
retornoLexador = delegua.lexador.mapear(["var estatistica = importar('estatistica')"], -1);
|
|
287
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
288
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
289
|
+
case 1:
|
|
290
|
+
retornoInterpretador = _a.sent();
|
|
291
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
292
|
+
return [2 /*return*/];
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}); });
|
|
125
296
|
});
|
|
126
297
|
describe('testa importação da biblioteca de física', function () {
|
|
127
298
|
beforeEach(function () {
|
|
@@ -130,18 +301,36 @@ describe('Interpretador', function () {
|
|
|
130
301
|
afterEach(function () {
|
|
131
302
|
jest.unmock("./__mocks__/fisica.ts");
|
|
132
303
|
});
|
|
133
|
-
it('física', function () {
|
|
134
|
-
var retornoLexador
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
304
|
+
it('física', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
305
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
306
|
+
return __generator(this, function (_a) {
|
|
307
|
+
switch (_a.label) {
|
|
308
|
+
case 0:
|
|
309
|
+
retornoLexador = delegua.lexador.mapear(["var física = importar('física')"], -1);
|
|
310
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
311
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
312
|
+
case 1:
|
|
313
|
+
retornoInterpretador = _a.sent();
|
|
314
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
315
|
+
return [2 /*return*/];
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}); });
|
|
319
|
+
it('fisica', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
320
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
321
|
+
return __generator(this, function (_a) {
|
|
322
|
+
switch (_a.label) {
|
|
323
|
+
case 0:
|
|
324
|
+
retornoLexador = delegua.lexador.mapear(["var fisica = importar('fisica')"], -1);
|
|
325
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
326
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
327
|
+
case 1:
|
|
328
|
+
retornoInterpretador = _a.sent();
|
|
329
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
330
|
+
return [2 /*return*/];
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
}); });
|
|
145
334
|
});
|
|
146
335
|
describe('testa importação da biblioteca de matemática', function () {
|
|
147
336
|
beforeEach(function () {
|
|
@@ -150,272 +339,608 @@ describe('Interpretador', function () {
|
|
|
150
339
|
afterAll(function () {
|
|
151
340
|
jest.unmock("./__mocks__/matematica.ts");
|
|
152
341
|
});
|
|
153
|
-
it('matemática com acento', function () {
|
|
154
|
-
var retornoLexador
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
342
|
+
it('matemática com acento', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
343
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
344
|
+
return __generator(this, function (_a) {
|
|
345
|
+
switch (_a.label) {
|
|
346
|
+
case 0:
|
|
347
|
+
retornoLexador = delegua.lexador.mapear(["var matemática = importar('matemática')"], -1);
|
|
348
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
349
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
350
|
+
case 1:
|
|
351
|
+
retornoInterpretador = _a.sent();
|
|
352
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
353
|
+
return [2 /*return*/];
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}); });
|
|
357
|
+
it('matematica sem acento', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
358
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
359
|
+
return __generator(this, function (_a) {
|
|
360
|
+
switch (_a.label) {
|
|
361
|
+
case 0:
|
|
362
|
+
retornoLexador = delegua.lexador.mapear(["var matematica = importar('matematica')"], -1);
|
|
363
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
364
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
365
|
+
case 1:
|
|
366
|
+
retornoInterpretador = _a.sent();
|
|
367
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
368
|
+
return [2 /*return*/];
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}); });
|
|
165
372
|
});
|
|
166
373
|
});
|
|
167
374
|
});
|
|
168
375
|
describe('Delegua com parametro de performance', function () {
|
|
169
|
-
it('performance', function () {
|
|
170
|
-
var deleguaPerformance
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
376
|
+
it('performance', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
377
|
+
var deleguaPerformance, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
378
|
+
return __generator(this, function (_a) {
|
|
379
|
+
switch (_a.label) {
|
|
380
|
+
case 0:
|
|
381
|
+
deleguaPerformance = new delegua_1.Delegua('delegua', true);
|
|
382
|
+
retornoLexador = deleguaPerformance.lexador.mapear(["escreva(1 + 1)"], -1);
|
|
383
|
+
retornoAvaliadorSintatico = deleguaPerformance.avaliadorSintatico.analisar(retornoLexador);
|
|
384
|
+
return [4 /*yield*/, deleguaPerformance.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
385
|
+
case 1:
|
|
386
|
+
retornoInterpretador = _a.sent();
|
|
387
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
388
|
+
return [2 /*return*/];
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}); });
|
|
176
392
|
});
|
|
177
393
|
describe('Operações matemáticas', function () {
|
|
178
|
-
it('Operações matemáticas - Trivial', function () {
|
|
179
|
-
var retornoLexador
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
394
|
+
it('Operações matemáticas - Trivial', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
395
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
396
|
+
return __generator(this, function (_a) {
|
|
397
|
+
switch (_a.label) {
|
|
398
|
+
case 0:
|
|
399
|
+
retornoLexador = delegua.lexador.mapear(["escreva(5 + 4 * 3 - 2 ** 1 / 6 % 10)"], -1);
|
|
400
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
401
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
402
|
+
case 1:
|
|
403
|
+
retornoInterpretador = _a.sent();
|
|
404
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
405
|
+
return [2 /*return*/];
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}); });
|
|
409
|
+
it('Operações matemáticas - Subtração', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
410
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
411
|
+
return __generator(this, function (_a) {
|
|
412
|
+
switch (_a.label) {
|
|
413
|
+
case 0:
|
|
414
|
+
retornoLexador = delegua.lexador.mapear(["-1"], -1);
|
|
415
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
416
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
417
|
+
case 1:
|
|
418
|
+
retornoInterpretador = _a.sent();
|
|
419
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
420
|
+
return [2 /*return*/];
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
}); });
|
|
184
424
|
});
|
|
185
425
|
describe('Operações lógicas', function () {
|
|
186
|
-
it('Operações lógicas - ou', function () {
|
|
187
|
-
var retornoLexador
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
426
|
+
it('Operações lógicas - ou', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
427
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
428
|
+
return __generator(this, function (_a) {
|
|
429
|
+
switch (_a.label) {
|
|
430
|
+
case 0:
|
|
431
|
+
retornoLexador = delegua.lexador.mapear(["escreva(verdadeiro ou falso)"], -1);
|
|
432
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
433
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
434
|
+
case 1:
|
|
435
|
+
retornoInterpretador = _a.sent();
|
|
436
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
437
|
+
return [2 /*return*/];
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}); });
|
|
441
|
+
it('Operações lógicas - e', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
442
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
443
|
+
return __generator(this, function (_a) {
|
|
444
|
+
switch (_a.label) {
|
|
445
|
+
case 0:
|
|
446
|
+
retornoLexador = delegua.lexador.mapear(["escreva(verdadeiro e falso)"], -1);
|
|
447
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
448
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
449
|
+
case 1:
|
|
450
|
+
retornoInterpretador = _a.sent();
|
|
451
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
452
|
+
return [2 /*return*/];
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
}); });
|
|
456
|
+
it('Operações lógicas - negação', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
457
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
458
|
+
return __generator(this, function (_a) {
|
|
459
|
+
switch (_a.label) {
|
|
460
|
+
case 0:
|
|
461
|
+
retornoLexador = delegua.lexador.mapear(["!verdadeiro"], -1);
|
|
462
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
463
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
464
|
+
case 1:
|
|
465
|
+
retornoInterpretador = _a.sent();
|
|
466
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
467
|
+
return [2 /*return*/];
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}); });
|
|
471
|
+
it('Operações lógicas - em', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
472
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
473
|
+
return __generator(this, function (_a) {
|
|
474
|
+
switch (_a.label) {
|
|
475
|
+
case 0:
|
|
476
|
+
retornoLexador = delegua.lexador.mapear(["escreva(2 em [1, 2, 3])"], -1);
|
|
477
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
478
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
479
|
+
case 1:
|
|
480
|
+
retornoInterpretador = _a.sent();
|
|
481
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
482
|
+
return [2 /*return*/];
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
}); });
|
|
486
|
+
it('Operações lógicas - bit a bit não', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
487
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
488
|
+
return __generator(this, function (_a) {
|
|
489
|
+
switch (_a.label) {
|
|
490
|
+
case 0:
|
|
491
|
+
retornoLexador = delegua.lexador.mapear(["~1"], -1);
|
|
492
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
493
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
494
|
+
case 1:
|
|
495
|
+
retornoInterpretador = _a.sent();
|
|
496
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
497
|
+
return [2 /*return*/];
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}); });
|
|
501
|
+
it('Operações lógicas - menor menor', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
502
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
503
|
+
return __generator(this, function (_a) {
|
|
504
|
+
switch (_a.label) {
|
|
505
|
+
case 0:
|
|
506
|
+
retornoLexador = delegua.lexador.mapear(["1 << 2"], -1);
|
|
507
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
508
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
509
|
+
case 1:
|
|
510
|
+
retornoInterpretador = _a.sent();
|
|
511
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
512
|
+
return [2 /*return*/];
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
}); });
|
|
516
|
+
it('Operações lógicas - maior maior', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
517
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
518
|
+
return __generator(this, function (_a) {
|
|
519
|
+
switch (_a.label) {
|
|
520
|
+
case 0:
|
|
521
|
+
retornoLexador = delegua.lexador.mapear(["2 >> 1"], -1);
|
|
522
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
523
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
524
|
+
case 1:
|
|
525
|
+
retornoInterpretador = _a.sent();
|
|
526
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
527
|
+
return [2 /*return*/];
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}); });
|
|
531
|
+
it('Operações lógicas - bit ou', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
532
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
533
|
+
return __generator(this, function (_a) {
|
|
534
|
+
switch (_a.label) {
|
|
535
|
+
case 0:
|
|
536
|
+
retornoLexador = delegua.lexador.mapear(["1 | 2"], -1);
|
|
537
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
538
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
539
|
+
case 1:
|
|
540
|
+
retornoInterpretador = _a.sent();
|
|
541
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
542
|
+
return [2 /*return*/];
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
}); });
|
|
546
|
+
it('Operações lógicas - bit e', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
547
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
548
|
+
return __generator(this, function (_a) {
|
|
549
|
+
switch (_a.label) {
|
|
550
|
+
case 0:
|
|
551
|
+
retornoLexador = delegua.lexador.mapear(["1 & 1"], -1);
|
|
552
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
553
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
554
|
+
case 1:
|
|
555
|
+
retornoInterpretador = _a.sent();
|
|
556
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
557
|
+
return [2 /*return*/];
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
}); });
|
|
561
|
+
it('Operações lógicas - bit xor', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
562
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
563
|
+
return __generator(this, function (_a) {
|
|
564
|
+
switch (_a.label) {
|
|
565
|
+
case 0:
|
|
566
|
+
retornoLexador = delegua.lexador.mapear(["1 ^ 2"], -1);
|
|
567
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
568
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
569
|
+
case 1:
|
|
570
|
+
retornoInterpretador = _a.sent();
|
|
571
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
572
|
+
return [2 /*return*/];
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}); });
|
|
204
576
|
});
|
|
205
577
|
describe('Escolha - Caso', function () {
|
|
206
|
-
it('Escolha', function () {
|
|
207
|
-
var codigo
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
578
|
+
it('Escolha', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
579
|
+
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
580
|
+
return __generator(this, function (_a) {
|
|
581
|
+
switch (_a.label) {
|
|
582
|
+
case 0:
|
|
583
|
+
codigo = [
|
|
584
|
+
"escolha (1) {",
|
|
585
|
+
"caso 1:",
|
|
586
|
+
"escreva('correspondente à opção 1');",
|
|
587
|
+
"caso 2:",
|
|
588
|
+
"escreva('correspondente à opção 2');",
|
|
589
|
+
"padrao:",
|
|
590
|
+
"escreva('Sem opção correspondente');",
|
|
591
|
+
"}"
|
|
592
|
+
];
|
|
593
|
+
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
594
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
595
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
596
|
+
case 1:
|
|
597
|
+
retornoInterpretador = _a.sent();
|
|
598
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
599
|
+
return [2 /*return*/];
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}); });
|
|
222
603
|
});
|
|
223
604
|
describe('Tente - Pegue - Finalmente', function () {
|
|
224
|
-
it('Tente', function () {
|
|
225
|
-
var codigo
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
605
|
+
it('Tente', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
606
|
+
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
607
|
+
return __generator(this, function (_a) {
|
|
608
|
+
switch (_a.label) {
|
|
609
|
+
case 0:
|
|
610
|
+
codigo = [
|
|
611
|
+
"tente {",
|
|
612
|
+
"escreva('sucesso');",
|
|
613
|
+
"} pegue {",
|
|
614
|
+
"escreva('pegue');",
|
|
615
|
+
"} finalmente {",
|
|
616
|
+
"escreva('pronto');",
|
|
617
|
+
"}"
|
|
618
|
+
];
|
|
619
|
+
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
620
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
621
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
622
|
+
case 1:
|
|
623
|
+
retornoInterpretador = _a.sent();
|
|
624
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
625
|
+
return [2 /*return*/];
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
}); });
|
|
629
|
+
it('Tente com senão', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
630
|
+
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
631
|
+
return __generator(this, function (_a) {
|
|
632
|
+
switch (_a.label) {
|
|
633
|
+
case 0:
|
|
634
|
+
codigo = [
|
|
635
|
+
"tente {",
|
|
636
|
+
"se 1 != 1 {",
|
|
637
|
+
"escreva('sucesso');",
|
|
638
|
+
"}",
|
|
639
|
+
"senao {",
|
|
640
|
+
"escreva('é diferente');",
|
|
641
|
+
"}",
|
|
642
|
+
"} pegue {",
|
|
643
|
+
"escreva('pegue');",
|
|
644
|
+
"} finalmente {",
|
|
645
|
+
"escreva('pronto');",
|
|
646
|
+
"}"
|
|
647
|
+
];
|
|
648
|
+
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
649
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
650
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
651
|
+
case 1:
|
|
652
|
+
retornoInterpretador = _a.sent();
|
|
653
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
654
|
+
return [2 /*return*/];
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}); });
|
|
658
|
+
it('Pegue', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
659
|
+
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
660
|
+
return __generator(this, function (_a) {
|
|
661
|
+
switch (_a.label) {
|
|
662
|
+
case 0:
|
|
663
|
+
codigo = [
|
|
664
|
+
"tente {",
|
|
665
|
+
"1 > '1';",
|
|
666
|
+
"escreva('sucesso');",
|
|
667
|
+
"} pegue {",
|
|
668
|
+
"escreva('captura');",
|
|
669
|
+
"} finalmente {",
|
|
670
|
+
"escreva('pronto');",
|
|
671
|
+
"}"
|
|
672
|
+
];
|
|
673
|
+
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
674
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
675
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
676
|
+
case 1:
|
|
677
|
+
retornoInterpretador = _a.sent();
|
|
678
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
679
|
+
return [2 /*return*/];
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
}); });
|
|
275
683
|
}),
|
|
276
684
|
describe('Condicionais', function () {
|
|
277
|
-
it('Condicionais - condição verdadeira', function () {
|
|
278
|
-
var retornoLexador
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
});
|
|
685
|
+
it('Condicionais - condição verdadeira', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
686
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
687
|
+
return __generator(this, function (_a) {
|
|
688
|
+
switch (_a.label) {
|
|
689
|
+
case 0:
|
|
690
|
+
retornoLexador = delegua.lexador.mapear(["se (1 < 2) { escreva('Um menor que dois') } senão { escreva('Nunca será executado') }"], -1);
|
|
691
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
692
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
693
|
+
case 1:
|
|
694
|
+
retornoInterpretador = _a.sent();
|
|
695
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
696
|
+
return [2 /*return*/];
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
}); });
|
|
700
|
+
it('Condicionais - condição falsa', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
701
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
702
|
+
return __generator(this, function (_a) {
|
|
703
|
+
switch (_a.label) {
|
|
704
|
+
case 0:
|
|
705
|
+
retornoLexador = delegua.lexador.mapear(["se (1 > 2) { escreva('Nunca acontece') } senão { escreva('Um não é maior que dois') }"], -1);
|
|
706
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
707
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
708
|
+
case 1:
|
|
709
|
+
retornoInterpretador = _a.sent();
|
|
710
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
711
|
+
return [2 /*return*/];
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
}); });
|
|
715
|
+
it('Condicionais - condição menor igual', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
716
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
717
|
+
return __generator(this, function (_a) {
|
|
718
|
+
switch (_a.label) {
|
|
719
|
+
case 0:
|
|
720
|
+
retornoLexador = delegua.lexador.mapear(["se (1 <= 2) { escreva('Um é menor e igual a dois') } senão { escreva('Nunca será executado') }"], -1);
|
|
721
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
722
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
723
|
+
case 1:
|
|
724
|
+
retornoInterpretador = _a.sent();
|
|
725
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
726
|
+
return [2 /*return*/];
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
}); });
|
|
730
|
+
it('Condicionais - condição maior igual', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
731
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
732
|
+
return __generator(this, function (_a) {
|
|
733
|
+
switch (_a.label) {
|
|
734
|
+
case 0:
|
|
735
|
+
retornoLexador = delegua.lexador.mapear(["se (2 >= 1) { escreva('Dois é maior ou igual a um') } senão { escreva('Nunca será executado') }"], -1);
|
|
736
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
737
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
738
|
+
case 1:
|
|
739
|
+
retornoInterpretador = _a.sent();
|
|
740
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
741
|
+
return [2 /*return*/];
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
}); });
|
|
745
|
+
it('Condicionais - condição diferente', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
746
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
747
|
+
return __generator(this, function (_a) {
|
|
748
|
+
switch (_a.label) {
|
|
749
|
+
case 0:
|
|
750
|
+
retornoLexador = delegua.lexador.mapear(["se (2 != 1) { escreva('Dois é diferente de um') } senão { escreva('Nunca será executado') }"], -1);
|
|
751
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
752
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
753
|
+
case 1:
|
|
754
|
+
retornoInterpretador = _a.sent();
|
|
755
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
756
|
+
return [2 /*return*/];
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
}); });
|
|
307
760
|
});
|
|
308
761
|
describe('Laços de repetição', function () {
|
|
309
|
-
it('Laços de repetição - enquanto', function () {
|
|
310
|
-
var retornoLexador
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
});
|
|
324
|
-
it('Laços de repetição -
|
|
325
|
-
var retornoLexador
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
762
|
+
it('Laços de repetição - enquanto', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
763
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
764
|
+
return __generator(this, function (_a) {
|
|
765
|
+
switch (_a.label) {
|
|
766
|
+
case 0:
|
|
767
|
+
retornoLexador = delegua.lexador.mapear(["var a = 0;\nenquanto (a < 10) { a = a + 1 }"], -1);
|
|
768
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
769
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
770
|
+
case 1:
|
|
771
|
+
retornoInterpretador = _a.sent();
|
|
772
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
773
|
+
return [2 /*return*/];
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
}); });
|
|
777
|
+
it('Laços de repetição - fazer ... enquanto', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
778
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
779
|
+
return __generator(this, function (_a) {
|
|
780
|
+
switch (_a.label) {
|
|
781
|
+
case 0:
|
|
782
|
+
retornoLexador = delegua.lexador.mapear([
|
|
783
|
+
"var a = 0",
|
|
784
|
+
"fazer { a = a + 1 } enquanto (a < 10)"
|
|
785
|
+
], -1);
|
|
786
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
787
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
788
|
+
case 1:
|
|
789
|
+
retornoInterpretador = _a.sent();
|
|
790
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
791
|
+
return [2 /*return*/];
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
}); });
|
|
795
|
+
it('Laços de repetição - para', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
796
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
797
|
+
return __generator(this, function (_a) {
|
|
798
|
+
switch (_a.label) {
|
|
799
|
+
case 0:
|
|
800
|
+
retornoLexador = delegua.lexador.mapear(["para (var i = 0; i < 10; i = i + 1) { escreva(i) }"], -1);
|
|
801
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
802
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
803
|
+
case 1:
|
|
804
|
+
retornoInterpretador = _a.sent();
|
|
805
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
806
|
+
return [2 /*return*/];
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
}); });
|
|
330
810
|
});
|
|
331
811
|
describe('Classes', function () {
|
|
332
|
-
it('Trivial', function () {
|
|
333
|
-
var codigo
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
812
|
+
it('Trivial', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
813
|
+
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
814
|
+
return __generator(this, function (_a) {
|
|
815
|
+
switch (_a.label) {
|
|
816
|
+
case 0:
|
|
817
|
+
codigo = [
|
|
818
|
+
"classe Animal {",
|
|
819
|
+
" correr() {",
|
|
820
|
+
" escreva('Correndo Loucamente')",
|
|
821
|
+
" }",
|
|
822
|
+
"}",
|
|
823
|
+
"classe Cachorro herda Animal {",
|
|
824
|
+
" latir() {",
|
|
825
|
+
" escreva('Au Au Au Au')",
|
|
826
|
+
" }",
|
|
827
|
+
"}",
|
|
828
|
+
"var nomeDoCachorro = Cachorro()",
|
|
829
|
+
"nomeDoCachorro.correr()",
|
|
830
|
+
"nomeDoCachorro.latir()",
|
|
831
|
+
"escreva('Classe: OK!')"
|
|
832
|
+
];
|
|
833
|
+
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
834
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
835
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
836
|
+
case 1:
|
|
837
|
+
retornoInterpretador = _a.sent();
|
|
838
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
839
|
+
return [2 /*return*/];
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
}); });
|
|
354
843
|
});
|
|
355
844
|
describe('Declaração e chamada de funções', function () {
|
|
356
|
-
it('Fibonacci', function () {
|
|
357
|
-
var codigo
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
845
|
+
it('Fibonacci', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
846
|
+
var codigo, retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
847
|
+
return __generator(this, function (_a) {
|
|
848
|
+
switch (_a.label) {
|
|
849
|
+
case 0:
|
|
850
|
+
codigo = [
|
|
851
|
+
"função fibonacci(n) {",
|
|
852
|
+
" se (n == 0) {",
|
|
853
|
+
" retorna(0);",
|
|
854
|
+
" }",
|
|
855
|
+
" se (n == 1) {",
|
|
856
|
+
" retorna(1);",
|
|
857
|
+
" }",
|
|
858
|
+
" var n1 = n - 1;",
|
|
859
|
+
" var n2 = n - 2;",
|
|
860
|
+
" var f1 = fibonacci(n1);",
|
|
861
|
+
" var f2 = fibonacci(n2);",
|
|
862
|
+
" retorna(f1 + f2);",
|
|
863
|
+
"}",
|
|
864
|
+
"var a = fibonacci(0);",
|
|
865
|
+
"escreva(a);",
|
|
866
|
+
"a = fibonacci(1);",
|
|
867
|
+
"escreva(a);",
|
|
868
|
+
"a = fibonacci(2);",
|
|
869
|
+
"escreva(a);",
|
|
870
|
+
"a = fibonacci(3);",
|
|
871
|
+
"escreva(a);",
|
|
872
|
+
"a = fibonacci(4);",
|
|
873
|
+
"escreva(a);",
|
|
874
|
+
"a = fibonacci(5);",
|
|
875
|
+
"escreva(a);"
|
|
876
|
+
];
|
|
877
|
+
retornoLexador = delegua.lexador.mapear(codigo, -1);
|
|
878
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
879
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
880
|
+
case 1:
|
|
881
|
+
retornoInterpretador = _a.sent();
|
|
882
|
+
expect(retornoInterpretador.erros).toHaveLength(0);
|
|
883
|
+
return [2 /*return*/];
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
}); });
|
|
389
887
|
});
|
|
390
888
|
});
|
|
391
889
|
describe('Cenários de falha', function () {
|
|
392
890
|
describe('Acesso a variáveis e objetos', function () {
|
|
393
|
-
it('Acesso a elementos de vetor', function () {
|
|
394
|
-
var retornoLexador
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
});
|
|
891
|
+
it('Acesso a elementos de vetor', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
892
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
893
|
+
return __generator(this, function (_a) {
|
|
894
|
+
switch (_a.label) {
|
|
895
|
+
case 0:
|
|
896
|
+
retornoLexador = delegua.lexador.mapear([
|
|
897
|
+
"var a = [1, 2, 3];",
|
|
898
|
+
"escreva(a[4]);"
|
|
899
|
+
], -1);
|
|
900
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
901
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
902
|
+
case 1:
|
|
903
|
+
retornoInterpretador = _a.sent();
|
|
904
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
905
|
+
return [2 /*return*/];
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
}); });
|
|
909
|
+
it('Acesso a elementos de dicionário', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
910
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
911
|
+
return __generator(this, function (_a) {
|
|
912
|
+
switch (_a.label) {
|
|
913
|
+
case 0:
|
|
914
|
+
retornoLexador = delegua.lexador.mapear([
|
|
915
|
+
"var a = {'a': 1, 'b': 2};",
|
|
916
|
+
"escreva(a['c']);"
|
|
917
|
+
], -1);
|
|
918
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
919
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
920
|
+
case 1:
|
|
921
|
+
retornoInterpretador = _a.sent();
|
|
922
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThanOrEqual(0);
|
|
923
|
+
return [2 /*return*/];
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
}); });
|
|
411
927
|
});
|
|
412
928
|
describe('Importar', function () {
|
|
413
|
-
it('Importar biblioteca externa que não existe', function () {
|
|
414
|
-
var retornoLexador
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
929
|
+
it('Importar biblioteca externa que não existe', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
930
|
+
var retornoLexador, retornoAvaliadorSintatico, retornoInterpretador;
|
|
931
|
+
return __generator(this, function (_a) {
|
|
932
|
+
switch (_a.label) {
|
|
933
|
+
case 0:
|
|
934
|
+
retornoLexador = delegua.lexador.mapear(["var naoexiste = importar('naoexiste')"], -1);
|
|
935
|
+
retornoAvaliadorSintatico = delegua.avaliadorSintatico.analisar(retornoLexador);
|
|
936
|
+
return [4 /*yield*/, delegua.interpretador.interpretar(retornoAvaliadorSintatico.declaracoes)];
|
|
937
|
+
case 1:
|
|
938
|
+
retornoInterpretador = _a.sent();
|
|
939
|
+
expect(retornoInterpretador.erros.length).toBeGreaterThan(0);
|
|
940
|
+
return [2 /*return*/];
|
|
941
|
+
}
|
|
942
|
+
});
|
|
943
|
+
}); });
|
|
419
944
|
});
|
|
420
945
|
});
|
|
421
946
|
});
|