@designliquido/delegua 0.24.1 → 0.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/bin/package.json +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-birl.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-mapler.js +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-mapler.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/potigol/avaliador-sintatico-potigol.js +1 -1
- package/fontes/avaliador-sintatico/dialetos/potigol/avaliador-sintatico-potigol.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/visualg/avaliador-sintatico-visualg.js +3 -1
- package/fontes/avaliador-sintatico/dialetos/visualg/avaliador-sintatico-visualg.js.map +1 -1
- package/fontes/bibliotecas/biblioteca-global.js +5 -4
- package/fontes/bibliotecas/biblioteca-global.js.map +1 -1
- package/fontes/bibliotecas/dialetos/visualg/caracteres.js +15 -5
- package/fontes/bibliotecas/dialetos/visualg/caracteres.js.map +1 -1
- package/fontes/bibliotecas/dialetos/visualg/numerica.js +13 -4
- package/fontes/bibliotecas/dialetos/visualg/numerica.js.map +1 -1
- package/fontes/estruturas/delegua-funcao.js +3 -1
- package/fontes/estruturas/delegua-funcao.js.map +1 -1
- package/fontes/interfaces/dialeto/interpretador-birl-interface.d.ts +11 -0
- package/fontes/interfaces/dialeto/interpretador-birl-interface.js +3 -0
- package/fontes/interfaces/dialeto/interpretador-birl-interface.js.map +1 -0
- package/fontes/interfaces/interpretador-interface-birl.d.ts +22 -0
- package/fontes/interfaces/interpretador-interface-birl.js +3 -0
- package/fontes/interfaces/interpretador-interface-birl.js.map +1 -0
- package/fontes/interfaces/interpretador-interface.d.ts +4 -1
- package/fontes/interpretador/dialetos/birl/comum.d.ts +16 -3
- package/fontes/interpretador/dialetos/birl/comum.js +206 -1
- package/fontes/interpretador/dialetos/birl/comum.js.map +1 -1
- package/fontes/interpretador/dialetos/birl/interpretador-birl-com-depuracao.d.ts +26 -0
- package/fontes/interpretador/dialetos/birl/interpretador-birl-com-depuracao.js +68 -0
- package/fontes/interpretador/dialetos/birl/interpretador-birl-com-depuracao.js.map +1 -0
- package/fontes/interpretador/dialetos/birl/interpretador-birl.d.ts +25 -39
- package/fontes/interpretador/dialetos/birl/interpretador-birl.js +42 -235
- package/fontes/interpretador/dialetos/birl/interpretador-birl.js.map +1 -1
- package/fontes/interpretador/dialetos/egua-classico/interpretador-egua-classico.d.ts +4 -4
- package/fontes/interpretador/dialetos/egua-classico/interpretador-egua-classico.js +13 -6
- package/fontes/interpretador/dialetos/egua-classico/interpretador-egua-classico.js.map +1 -1
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/resolvedor.d.ts +6 -6
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/resolvedor.js +1 -1
- package/fontes/interpretador/dialetos/egua-classico/resolvedor/resolvedor.js.map +1 -1
- package/fontes/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.d.ts +9 -9
- package/fontes/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.js +33 -33
- package/fontes/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.js.map +1 -1
- package/fontes/interpretador/interpretador-base.d.ts +1 -1
- package/fontes/interpretador/interpretador-base.js +5 -2
- package/fontes/interpretador/interpretador-base.js.map +1 -1
- package/fontes/interpretador/interpretador-com-depuracao.d.ts +1 -1
- package/fontes/interpretador/interpretador-com-depuracao.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-birl.js +3 -2
- package/fontes/lexador/dialetos/lexador-birl.js.map +1 -1
- package/fontes/tradutores/index.d.ts +1 -0
- package/fontes/tradutores/index.js +1 -0
- package/fontes/tradutores/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.InterpretadorBirlComDepuracao = void 0;
|
|
27
|
+
const interpretador_com_depuracao_1 = require("../../interpretador-com-depuracao");
|
|
28
|
+
const comum = __importStar(require("./comum"));
|
|
29
|
+
class InterpretadorBirlComDepuracao extends interpretador_com_depuracao_1.InterpretadorComDepuracao {
|
|
30
|
+
constructor(diretorioBase, funcaoDeRetorno = null, funcaoDeRetornoMesmaLinha = null) {
|
|
31
|
+
super(diretorioBase, funcaoDeRetorno, funcaoDeRetornoMesmaLinha);
|
|
32
|
+
}
|
|
33
|
+
async atribuirVariavel(interpretador, expressao, valor, tipo) {
|
|
34
|
+
return comum.atribuirVariavel(interpretador, expressao, valor, tipo);
|
|
35
|
+
}
|
|
36
|
+
async resolveQuantidadeDeInterpolacoes(expressao) {
|
|
37
|
+
return comum.resolveQuantidadeDeInterpolacoes(expressao);
|
|
38
|
+
}
|
|
39
|
+
async verificaTipoDaInterpolação(dados) {
|
|
40
|
+
return comum.verificaTipoDaInterpolação(dados);
|
|
41
|
+
}
|
|
42
|
+
async substituirValor(stringOriginal, novoValor, simboloTipo) {
|
|
43
|
+
return comum.substituirValor(stringOriginal, novoValor, simboloTipo);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Execução da leitura de valores da entrada configurada no
|
|
47
|
+
* início da aplicação.
|
|
48
|
+
* @param expressao Expressão do tipo Leia
|
|
49
|
+
* @returns Promise com o resultado da leitura.
|
|
50
|
+
*/
|
|
51
|
+
async visitarExpressaoLeia(expressao) {
|
|
52
|
+
await comum.visitarExpressaoLeia(this, expressao);
|
|
53
|
+
}
|
|
54
|
+
async visitarExpressaoLiteral(expressao) {
|
|
55
|
+
return comum.visitarExpressaoLiteral(expressao);
|
|
56
|
+
}
|
|
57
|
+
async visitarDeclaracaoPara(declaracao) {
|
|
58
|
+
return comum.visitarDeclaracaoPara(this, declaracao);
|
|
59
|
+
}
|
|
60
|
+
async avaliarArgumentosEscreva(argumentos) {
|
|
61
|
+
return comum.avaliarArgumentosEscreva(this, argumentos);
|
|
62
|
+
}
|
|
63
|
+
async interpretar(declaracoes, manterAmbiente) {
|
|
64
|
+
return comum.interpretar(this, declaracoes, manterAmbiente);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.InterpretadorBirlComDepuracao = InterpretadorBirlComDepuracao;
|
|
68
|
+
//# sourceMappingURL=interpretador-birl-com-depuracao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpretador-birl-com-depuracao.js","sourceRoot":"","sources":["../../../../../fontes/interpretador/dialetos/birl/interpretador-birl-com-depuracao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mFAA8E;AAC9E,+CAAiC;AAEjC,MAAa,6BAA8B,SAAQ,uDAAyB;IACxE,YAAY,aAAqB,EAAE,kBAA4B,IAAI,EAAE,4BAAsC,IAAI;QAC3G,KAAK,CAAC,aAAa,EAAE,eAAe,EAAE,yBAAyB,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,gBAAgB,CAClB,aAAyC,EACzC,SAAoB,EACpB,KAAU,EACV,IAAY;QAEZ,OAAO,KAAK,CAAC,gBAAgB,CAAC,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,gCAAgC,CAAC,SAAkB;QACrD,OAAO,KAAK,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IACD,KAAK,CAAC,0BAA0B,CAAC,KAAmC;QAChE,OAAO,KAAK,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,cAAsB,EAAE,SAAc,EAAE,WAAmB;QAC7E,OAAO,KAAK,CAAC,eAAe,CAAC,cAAc,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IACzE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,oBAAoB,CAAC,SAAe;QACtC,MAAM,KAAK,CAAC,oBAAoB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,SAAkB;QAC5C,OAAO,KAAK,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,UAAgB;QACxC,OAAO,KAAK,CAAC,qBAAqB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,wBAAwB,CAAC,UAAuB;QAClD,OAAO,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,WAAyB,EAAE,cAAwB;QACjE,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;IAChE,CAAC;CACJ;AAjDD,sEAiDC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { Atribuir, Construto, FimPara,
|
|
2
|
-
import { Bloco, Classe, Const, Continua, Declaracao, Enquanto, Escolha, Escreva, EscrevaMesmaLinha, Expressao, Fazer, FuncaoDeclaracao,
|
|
1
|
+
import { Atribuir, Binario, Construto, FimPara, Literal, Logico, Super, TipoDe, Unario, Variavel } from '../../../construtos';
|
|
2
|
+
import { Bloco, Classe, Const, Continua, Declaracao, Enquanto, Escolha, Escreva, EscrevaMesmaLinha, Expressao, Fazer, FuncaoDeclaracao, Leia, Para, ParaCada, Retorna, Se, Tente, Var } from '../../../declaracoes';
|
|
3
3
|
import { EspacoVariaveis } from '../../../espaco-variaveis';
|
|
4
|
-
import {
|
|
4
|
+
import { SimboloInterface, VariavelInterface } from '../../../interfaces';
|
|
5
5
|
import { ErroInterpretador } from '../../../interfaces/erros/erro-interpretador';
|
|
6
|
+
import { InterpretadorInterfaceBirl } from '../../../interfaces/interpretador-interface-birl';
|
|
6
7
|
import { PilhaEscoposExecucaoInterface } from '../../../interfaces/pilha-escopos-execucao-interface';
|
|
7
8
|
import { RetornoInterpretador } from '../../../interfaces/retornos';
|
|
8
9
|
import { ContinuarQuebra, RetornoQuebra, SustarQuebra } from '../../../quebras';
|
|
9
|
-
|
|
10
|
+
import { InterpretadorBase } from '../../interpretador-base';
|
|
11
|
+
export declare class InterpretadorBirl extends InterpretadorBase implements InterpretadorInterfaceBirl {
|
|
10
12
|
diretorioBase: any;
|
|
11
13
|
funcaoDeRetorno: Function;
|
|
12
14
|
funcaoDeRetornoMesmaLinha: Function;
|
|
@@ -60,17 +62,17 @@ export declare class InterpretadorBirl implements InterpretadorInterface {
|
|
|
60
62
|
* @returns Se ambos os operandos são números ou não.
|
|
61
63
|
*/
|
|
62
64
|
protected verificarOperandosNumeros(operador: SimboloInterface, direita: VariavelInterface | any, esquerda: VariavelInterface | any): void;
|
|
63
|
-
visitarExpressaoBinaria(expressao:
|
|
65
|
+
visitarExpressaoBinaria(expressao: Binario): Promise<any>;
|
|
64
66
|
/**
|
|
65
67
|
* Executa uma chamada de função, método ou classe.
|
|
66
68
|
* @param expressao A expressão chamada.
|
|
67
69
|
* @returns O resultado da chamada.
|
|
68
70
|
*/
|
|
69
71
|
visitarExpressaoDeChamada(expressao: any): Promise<any>;
|
|
70
|
-
visitarDeclaracaoDeAtribuicao(expressao: Atribuir): void
|
|
72
|
+
visitarDeclaracaoDeAtribuicao(expressao: Atribuir): Promise<void>;
|
|
71
73
|
protected procurarVariavel(simbolo: SimboloInterface): any;
|
|
72
74
|
visitarExpressaoDeVariavel(expressao: Variavel): any;
|
|
73
|
-
visitarDeclaracaoDeExpressao(declaracao: Expressao): void
|
|
75
|
+
visitarDeclaracaoDeExpressao(declaracao: Expressao): Promise<void>;
|
|
74
76
|
/**
|
|
75
77
|
* Execução da leitura de valores da entrada configurada no
|
|
76
78
|
* início da aplicação.
|
|
@@ -78,24 +80,11 @@ export declare class InterpretadorBirl implements InterpretadorInterface {
|
|
|
78
80
|
* @returns Promise com o resultado da leitura.
|
|
79
81
|
*/
|
|
80
82
|
visitarExpressaoLeia(expressao: Leia): Promise<any>;
|
|
81
|
-
|
|
82
|
-
* Busca variáveis interpoladas.
|
|
83
|
-
* @param {texto} textoOriginal O texto original com as variáveis interpoladas.
|
|
84
|
-
* @returns Uma lista de variáveis interpoladas.
|
|
85
|
-
*/
|
|
86
|
-
private buscarVariaveisInterpolacao;
|
|
87
|
-
/**
|
|
88
|
-
* Retira a interpolação de um texto.
|
|
89
|
-
* @param {texto} texto O texto
|
|
90
|
-
* @param {any[]} variaveis A lista de variaveis interpoladas
|
|
91
|
-
* @returns O texto com o valor das variaveis.
|
|
92
|
-
*/
|
|
93
|
-
private retirarInterpolacao;
|
|
94
|
-
visitarExpressaoLiteral(expressao: Literal): any;
|
|
83
|
+
visitarExpressaoLiteral(expressao: Literal): Promise<any>;
|
|
95
84
|
visitarExpressaoLogica(expressao: Logico): Promise<any>;
|
|
96
85
|
visitarDeclaracaoPara(declaracao: Para): Promise<any>;
|
|
97
86
|
visitarDeclaracaoParaCada(declaracao: ParaCada): Promise<any>;
|
|
98
|
-
|
|
87
|
+
eVerdadeiro(objeto: any): boolean;
|
|
99
88
|
/**
|
|
100
89
|
* Executa uma expressão Se, que tem uma condição, pode ter um bloco
|
|
101
90
|
* Senão, e múltiplos blocos Senão-se.
|
|
@@ -103,20 +92,18 @@ export declare class InterpretadorBirl implements InterpretadorInterface {
|
|
|
103
92
|
* @returns O resultado da avaliação do bloco cuja condição é verdadeira.
|
|
104
93
|
*/
|
|
105
94
|
visitarDeclaracaoSe(declaracao: Se): Promise<any>;
|
|
106
|
-
visitarExpressaoFimPara(declaracao: FimPara): void
|
|
107
|
-
visitarDeclaracaoFazer(declaracao: Fazer): void
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
visitarDeclaracaoTente(declaracao: Tente): void;
|
|
95
|
+
visitarExpressaoFimPara(declaracao: FimPara): Promise<void>;
|
|
96
|
+
visitarDeclaracaoFazer(declaracao: Fazer): Promise<void>;
|
|
97
|
+
visitarDeclaracaoEscolha(declaracao: Escolha): Promise<void>;
|
|
98
|
+
visitarDeclaracaoTente(declaracao: Tente): Promise<void>;
|
|
111
99
|
visitarDeclaracaoEnquanto(declaracao: Enquanto): Promise<any>;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
protected resolveQuantidadeDeInterpolacoes(texto: Literal): Promise<RegExpMatchArray>;
|
|
100
|
+
substituirValor(stringOriginal: string, novoValor: number | string | any, simboloTipo: string): Promise<string>;
|
|
101
|
+
resolveQuantidadeDeInterpolacoes(texto: Literal): Promise<RegExpMatchArray>;
|
|
115
102
|
verificaTipoDaInterpolação(dados: {
|
|
116
103
|
tipo: string;
|
|
117
104
|
valor: any;
|
|
118
105
|
}): Promise<boolean>;
|
|
119
|
-
|
|
106
|
+
avaliarArgumentosEscreva(argumentos: Construto[]): Promise<string>;
|
|
120
107
|
/**
|
|
121
108
|
* Execução de uma escrita na saída configurada, que pode ser `console` (padrão) ou
|
|
122
109
|
* alguma função para escrever numa página Web.
|
|
@@ -124,7 +111,7 @@ export declare class InterpretadorBirl implements InterpretadorInterface {
|
|
|
124
111
|
* @returns Sempre nulo, por convenção de visita.
|
|
125
112
|
*/
|
|
126
113
|
visitarDeclaracaoEscreva(declaracao: Escreva): Promise<any>;
|
|
127
|
-
visitarExpressaoEscrevaMesmaLinha(declaracao: EscrevaMesmaLinha): void
|
|
114
|
+
visitarExpressaoEscrevaMesmaLinha(declaracao: EscrevaMesmaLinha): Promise<void>;
|
|
128
115
|
visitarExpressaoBloco(declaracao: Bloco): Promise<any>;
|
|
129
116
|
protected avaliacaoDeclaracaoVar(declaracao: Var): Promise<any>;
|
|
130
117
|
/**
|
|
@@ -137,16 +124,15 @@ export declare class InterpretadorBirl implements InterpretadorInterface {
|
|
|
137
124
|
visitarExpressaoContinua(declaracao?: Continua): ContinuarQuebra;
|
|
138
125
|
visitarExpressaoSustar(declaracao?: any): SustarQuebra;
|
|
139
126
|
visitarExpressaoRetornar(declaracao: Retorna): Promise<RetornoQuebra>;
|
|
140
|
-
visitarExpressaoDeleguaFuncao(expressao: any): void;
|
|
141
127
|
visitarExpressaoAtribuicaoPorIndice(expressao: any): Promise<any>;
|
|
142
|
-
visitarExpressaoAcessoIndiceVariavel(expressao: any): void
|
|
143
|
-
visitarExpressaoDefinirValor(expressao: any): void
|
|
128
|
+
visitarExpressaoAcessoIndiceVariavel(expressao: any): Promise<void>;
|
|
129
|
+
visitarExpressaoDefinirValor(expressao: any): Promise<void>;
|
|
144
130
|
visitarDeclaracaoDefinicaoFuncao(declaracao: FuncaoDeclaracao): void;
|
|
145
|
-
visitarDeclaracaoClasse(declaracao: Classe): void
|
|
146
|
-
visitarExpressaoAcessoMetodo(expressao: any): void
|
|
131
|
+
visitarDeclaracaoClasse(declaracao: Classe): Promise<void>;
|
|
132
|
+
visitarExpressaoAcessoMetodo(expressao: any): Promise<void>;
|
|
147
133
|
visitarExpressaoIsto(expressao: any): void;
|
|
148
|
-
visitarExpressaoDicionario(expressao: any): void
|
|
149
|
-
visitarExpressaoVetor(expressao: any): void
|
|
134
|
+
visitarExpressaoDicionario(expressao: any): Promise<void>;
|
|
135
|
+
visitarExpressaoVetor(expressao: any): Promise<void>;
|
|
150
136
|
visitarExpressaoSuper(expressao: Super): void;
|
|
151
137
|
paraTexto(objeto: any): any;
|
|
152
138
|
/**
|
|
@@ -34,10 +34,12 @@ const excecoes_1 = require("../../../excecoes");
|
|
|
34
34
|
const quebras_1 = require("../../../quebras");
|
|
35
35
|
const birl_1 = __importDefault(require("../../../tipos-de-simbolos/birl"));
|
|
36
36
|
const inferenciador_1 = require("../../inferenciador");
|
|
37
|
+
const interpretador_base_1 = require("../../interpretador-base");
|
|
37
38
|
const pilha_escopos_execucao_1 = require("../../pilha-escopos-execucao");
|
|
38
39
|
const comum = __importStar(require("./comum"));
|
|
39
|
-
class InterpretadorBirl {
|
|
40
|
+
class InterpretadorBirl extends interpretador_base_1.InterpretadorBase {
|
|
40
41
|
constructor(diretorioBase, funcaoDeRetorno = null, funcaoDeRetornoMesmaLinha = null) {
|
|
42
|
+
super(diretorioBase, false, funcaoDeRetorno, funcaoDeRetornoMesmaLinha);
|
|
41
43
|
this.funcaoDeRetorno = null;
|
|
42
44
|
this.funcaoDeRetornoMesmaLinha = null;
|
|
43
45
|
this.resultadoInterpretador = [];
|
|
@@ -301,10 +303,17 @@ class InterpretadorBirl {
|
|
|
301
303
|
: variavelEntidadeChamada;
|
|
302
304
|
let argumentos = [];
|
|
303
305
|
for (let i = 0; i < expressao.argumentos.length; i++) {
|
|
304
|
-
|
|
306
|
+
const variavelArgumento = expressao.argumentos[i];
|
|
307
|
+
const nomeArgumento = variavelArgumento.hasOwnProperty('simbolo') ?
|
|
308
|
+
variavelArgumento.simbolo.lexema :
|
|
309
|
+
undefined;
|
|
310
|
+
argumentos.push({
|
|
311
|
+
nome: nomeArgumento,
|
|
312
|
+
valor: await this.avaliar(variavelArgumento)
|
|
313
|
+
});
|
|
305
314
|
}
|
|
306
315
|
if (entidadeChamada instanceof estruturas_1.DeleguaModulo) {
|
|
307
|
-
return Promise.reject(new excecoes_1.ErroEmTempoDeExecucao(expressao.parentese, 'Entidade chamada é um módulo de
|
|
316
|
+
return Promise.reject(new excecoes_1.ErroEmTempoDeExecucao(expressao.parentese, 'Entidade chamada é um módulo de Birl. Provavelmente você quer chamar um de seus componentes?', expressao.linha));
|
|
308
317
|
}
|
|
309
318
|
if (entidadeChamada instanceof estruturas_1.MetodoPrimitiva) {
|
|
310
319
|
const argumentosResolvidos = [];
|
|
@@ -338,8 +347,8 @@ class InterpretadorBirl {
|
|
|
338
347
|
if (parametros &&
|
|
339
348
|
parametros.length > 0 &&
|
|
340
349
|
parametros[parametros.length - 1].abrangencia === 'multiplo') {
|
|
341
|
-
|
|
342
|
-
novosArgumentos.
|
|
350
|
+
let novosArgumentos = argumentos.slice(0, parametros.length - 1);
|
|
351
|
+
novosArgumentos = novosArgumentos.concat(argumentos.slice(parametros.length - 1, argumentos.length));
|
|
343
352
|
argumentos = novosArgumentos;
|
|
344
353
|
}
|
|
345
354
|
}
|
|
@@ -380,7 +389,7 @@ class InterpretadorBirl {
|
|
|
380
389
|
this.erros.push(erro);
|
|
381
390
|
}
|
|
382
391
|
}
|
|
383
|
-
visitarDeclaracaoDeAtribuicao(expressao) {
|
|
392
|
+
async visitarDeclaracaoDeAtribuicao(expressao) {
|
|
384
393
|
throw new Error('Método não implementado.');
|
|
385
394
|
}
|
|
386
395
|
procurarVariavel(simbolo) {
|
|
@@ -389,7 +398,7 @@ class InterpretadorBirl {
|
|
|
389
398
|
visitarExpressaoDeVariavel(expressao) {
|
|
390
399
|
return this.procurarVariavel(expressao.simbolo);
|
|
391
400
|
}
|
|
392
|
-
visitarDeclaracaoDeExpressao(declaracao) {
|
|
401
|
+
async visitarDeclaracaoDeExpressao(declaracao) {
|
|
393
402
|
throw new Error('Método não implementado.');
|
|
394
403
|
}
|
|
395
404
|
/**
|
|
@@ -399,61 +408,10 @@ class InterpretadorBirl {
|
|
|
399
408
|
* @returns Promise com o resultado da leitura.
|
|
400
409
|
*/
|
|
401
410
|
async visitarExpressaoLeia(expressao) {
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Em Birl não se usa mensagem junto com o prompt, normalmente se usa um Escreva antes.
|
|
405
|
-
*/
|
|
406
|
-
const mensagem = '> ';
|
|
407
|
-
const promessaLeitura = () => new Promise((resolucao) => this.interfaceEntradaSaida.question(mensagem, (resposta) => {
|
|
408
|
-
resolucao(resposta);
|
|
409
|
-
}));
|
|
410
|
-
const valorLido = await promessaLeitura();
|
|
411
|
-
await comum.atribuirVariavel(this, expressao.argumentos[0], valorLido, expressao.argumentos[1].valor);
|
|
412
|
-
return;
|
|
411
|
+
await comum.visitarExpressaoLeia(this, expressao);
|
|
413
412
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
* @param {texto} textoOriginal O texto original com as variáveis interpoladas.
|
|
417
|
-
* @returns Uma lista de variáveis interpoladas.
|
|
418
|
-
*/
|
|
419
|
-
buscarVariaveisInterpolacao(textoOriginal) {
|
|
420
|
-
const variaveis = textoOriginal.match(this.regexInterpolacao);
|
|
421
|
-
return variaveis.map((s) => {
|
|
422
|
-
const nomeVariavel = s.replace(/[\$\{\}]*/g, '');
|
|
423
|
-
return {
|
|
424
|
-
variavel: nomeVariavel,
|
|
425
|
-
valor: this.pilhaEscoposExecucao.obterVariavelPorNome(nomeVariavel),
|
|
426
|
-
};
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Retira a interpolação de um texto.
|
|
431
|
-
* @param {texto} texto O texto
|
|
432
|
-
* @param {any[]} variaveis A lista de variaveis interpoladas
|
|
433
|
-
* @returns O texto com o valor das variaveis.
|
|
434
|
-
*/
|
|
435
|
-
retirarInterpolacao(texto, variaveis) {
|
|
436
|
-
const valoresVariaveis = variaveis.map((v) => ({
|
|
437
|
-
valorResolvido: this.pilhaEscoposExecucao.obterVariavelPorNome(v.variavel),
|
|
438
|
-
variavel: v.variavel,
|
|
439
|
-
}));
|
|
440
|
-
let textoFinal = texto;
|
|
441
|
-
valoresVariaveis.forEach((elemento) => {
|
|
442
|
-
const valorFinal = elemento.valorResolvido.hasOwnProperty('valor')
|
|
443
|
-
? elemento.valorResolvido.valor
|
|
444
|
-
: elemento.valorResolvido;
|
|
445
|
-
textoFinal = textoFinal.replace('${' + elemento.variavel + '}', valorFinal);
|
|
446
|
-
});
|
|
447
|
-
return textoFinal;
|
|
448
|
-
}
|
|
449
|
-
visitarExpressaoLiteral(expressao) {
|
|
450
|
-
if (expressao.valor === birl_1.default.ADICAO) {
|
|
451
|
-
return 1;
|
|
452
|
-
}
|
|
453
|
-
if (expressao.valor === birl_1.default.SUBTRACAO) {
|
|
454
|
-
return -1;
|
|
455
|
-
}
|
|
456
|
-
return expressao.valor;
|
|
413
|
+
async visitarExpressaoLiteral(expressao) {
|
|
414
|
+
return comum.visitarExpressaoLiteral(expressao);
|
|
457
415
|
}
|
|
458
416
|
async visitarExpressaoLogica(expressao) {
|
|
459
417
|
const esquerda = await this.avaliar(expressao.esquerda);
|
|
@@ -482,44 +440,7 @@ class InterpretadorBirl {
|
|
|
482
440
|
return await this.avaliar(expressao.direita);
|
|
483
441
|
}
|
|
484
442
|
async visitarDeclaracaoPara(declaracao) {
|
|
485
|
-
|
|
486
|
-
if (declaracao.inicializador instanceof Array) {
|
|
487
|
-
if (declaracao.inicializador[0] instanceof construtos_1.Variavel) {
|
|
488
|
-
const valor = await this.avaliar(declaracao.inicializador[1]);
|
|
489
|
-
this.pilhaEscoposExecucao.atribuirVariavel(declaracao.inicializador[0].simbolo, valor);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
await this.avaliar(declaracao.inicializador);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
let retornoExecucao;
|
|
497
|
-
while (!(retornoExecucao instanceof quebras_1.Quebra)) {
|
|
498
|
-
if (declaracao.condicao !== null && !this.eVerdadeiro(await this.avaliar(declaracao.condicao))) {
|
|
499
|
-
break;
|
|
500
|
-
}
|
|
501
|
-
try {
|
|
502
|
-
retornoExecucao = await this.executar(declaracao.corpo);
|
|
503
|
-
if (retornoExecucao instanceof quebras_1.SustarQuebra) {
|
|
504
|
-
return null;
|
|
505
|
-
}
|
|
506
|
-
if (retornoExecucao instanceof quebras_1.ContinuarQuebra) {
|
|
507
|
-
retornoExecucao = null;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
catch (erro) {
|
|
511
|
-
this.erros.push({
|
|
512
|
-
erroInterno: erro,
|
|
513
|
-
linha: declaracao.linha,
|
|
514
|
-
hashArquivo: declaracao.hashArquivo,
|
|
515
|
-
});
|
|
516
|
-
return Promise.reject(erro);
|
|
517
|
-
}
|
|
518
|
-
if (declaracao.incrementar !== null) {
|
|
519
|
-
await this.avaliar(declaracao.incrementar);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
return retornoExecucao;
|
|
443
|
+
return comum.visitarDeclaracaoPara(this, declaracao);
|
|
523
444
|
}
|
|
524
445
|
visitarDeclaracaoParaCada(declaracao) {
|
|
525
446
|
throw new Error('Método não implementado.');
|
|
@@ -556,19 +477,19 @@ class InterpretadorBirl {
|
|
|
556
477
|
}
|
|
557
478
|
return null;
|
|
558
479
|
}
|
|
559
|
-
visitarExpressaoFimPara(declaracao) {
|
|
560
|
-
throw new Error('Método não implementado.');
|
|
561
|
-
}
|
|
562
|
-
visitarDeclaracaoFazer(declaracao) {
|
|
480
|
+
async visitarExpressaoFimPara(declaracao) {
|
|
563
481
|
throw new Error('Método não implementado.');
|
|
564
482
|
}
|
|
565
|
-
|
|
483
|
+
async visitarDeclaracaoFazer(declaracao) {
|
|
566
484
|
throw new Error('Método não implementado.');
|
|
567
485
|
}
|
|
568
|
-
|
|
486
|
+
// async visitarExpressaoFormatacaoEscrita(declaracao: FormatacaoEscrita) {
|
|
487
|
+
// throw new Error('Método não implementado.');
|
|
488
|
+
// }
|
|
489
|
+
async visitarDeclaracaoEscolha(declaracao) {
|
|
569
490
|
throw new Error('Método não implementado.');
|
|
570
491
|
}
|
|
571
|
-
visitarDeclaracaoTente(declaracao) {
|
|
492
|
+
async visitarDeclaracaoTente(declaracao) {
|
|
572
493
|
throw new Error('Método não implementado.');
|
|
573
494
|
}
|
|
574
495
|
async visitarDeclaracaoEnquanto(declaracao) {
|
|
@@ -594,101 +515,17 @@ class InterpretadorBirl {
|
|
|
594
515
|
}
|
|
595
516
|
return retornoExecucao;
|
|
596
517
|
}
|
|
597
|
-
visitarDeclaracaoImportar(declaracao) {
|
|
598
|
-
throw new Error('Método não implementado.');
|
|
599
|
-
}
|
|
600
518
|
async substituirValor(stringOriginal, novoValor, simboloTipo) {
|
|
601
|
-
|
|
602
|
-
let resultado = '';
|
|
603
|
-
for (let i = 0; i < stringOriginal.length; i++) {
|
|
604
|
-
if (stringOriginal[i] === '%' && stringOriginal[i + 1] === simboloTipo && !substituida) {
|
|
605
|
-
switch (simboloTipo) {
|
|
606
|
-
case 'd':
|
|
607
|
-
case 'i':
|
|
608
|
-
case 'u':
|
|
609
|
-
case 'f':
|
|
610
|
-
case 'F':
|
|
611
|
-
case 'e':
|
|
612
|
-
case 'E':
|
|
613
|
-
case 'g':
|
|
614
|
-
case 'G':
|
|
615
|
-
case 'x':
|
|
616
|
-
case 'X':
|
|
617
|
-
case 'o':
|
|
618
|
-
case 'c':
|
|
619
|
-
case 's':
|
|
620
|
-
case 'p':
|
|
621
|
-
resultado += novoValor.hasOwnProperty('valor') ? novoValor.valor : novoValor;
|
|
622
|
-
break;
|
|
623
|
-
default:
|
|
624
|
-
resultado += stringOriginal[i];
|
|
625
|
-
break;
|
|
626
|
-
}
|
|
627
|
-
substituida = true;
|
|
628
|
-
i++;
|
|
629
|
-
}
|
|
630
|
-
else {
|
|
631
|
-
resultado += stringOriginal[i];
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
return resultado;
|
|
519
|
+
return comum.substituirValor(stringOriginal, novoValor, simboloTipo);
|
|
635
520
|
}
|
|
636
521
|
async resolveQuantidadeDeInterpolacoes(texto) {
|
|
637
|
-
|
|
638
|
-
const regex = /%[a-zA-Z]/g;
|
|
639
|
-
const matches = stringOriginal.match(regex);
|
|
640
|
-
return matches;
|
|
522
|
+
return comum.resolveQuantidadeDeInterpolacoes(texto);
|
|
641
523
|
}
|
|
642
524
|
async verificaTipoDaInterpolação(dados) {
|
|
643
|
-
|
|
644
|
-
case 'd':
|
|
645
|
-
case 'i':
|
|
646
|
-
case 'u':
|
|
647
|
-
const valor = dados.valor.hasOwnProperty('valor') ? dados.valor.valor : dados.valor;
|
|
648
|
-
if (typeof valor !== 'number') {
|
|
649
|
-
throw new Error('O valor interpolado não é um número.');
|
|
650
|
-
}
|
|
651
|
-
return true;
|
|
652
|
-
case 'c':
|
|
653
|
-
case 's':
|
|
654
|
-
const valorString = dados.valor.hasOwnProperty('valor') ? dados.valor.valor : dados.valor;
|
|
655
|
-
if (typeof valorString !== 'string') {
|
|
656
|
-
throw new Error('O valor interpolado não é um caractere.');
|
|
657
|
-
}
|
|
658
|
-
return true;
|
|
659
|
-
default:
|
|
660
|
-
throw new Error('Tipo de interpolação não suportado.');
|
|
661
|
-
}
|
|
525
|
+
return comum.verificaTipoDaInterpolação(dados);
|
|
662
526
|
}
|
|
663
527
|
async avaliarArgumentosEscreva(argumentos) {
|
|
664
|
-
|
|
665
|
-
let quantidadeInterpolacoes;
|
|
666
|
-
if (argumentos.length < 1) {
|
|
667
|
-
throw new Error('Escreva precisa de pelo menos um argumento.');
|
|
668
|
-
}
|
|
669
|
-
if (!(argumentos[0] instanceof construtos_1.Literal)) {
|
|
670
|
-
throw new Error('O primeiro argumento de Escreva precisa ser uma string.');
|
|
671
|
-
}
|
|
672
|
-
quantidadeInterpolacoes = await this.resolveQuantidadeDeInterpolacoes(argumentos[0]);
|
|
673
|
-
const resultadoAvaliacaoLiteral = await this.avaliar(argumentos[0]);
|
|
674
|
-
if (quantidadeInterpolacoes === null) {
|
|
675
|
-
formatoTexto = (resultadoAvaliacaoLiteral === null || resultadoAvaliacaoLiteral === void 0 ? void 0 : resultadoAvaliacaoLiteral.hasOwnProperty('valor')) ? resultadoAvaliacaoLiteral.valor : resultadoAvaliacaoLiteral;
|
|
676
|
-
return formatoTexto;
|
|
677
|
-
}
|
|
678
|
-
if (!(argumentos.length - 1 === quantidadeInterpolacoes.length)) {
|
|
679
|
-
throw new Error('Quantidade de argumentos não bate com quantidade de interpolacoes.');
|
|
680
|
-
}
|
|
681
|
-
formatoTexto = resultadoAvaliacaoLiteral;
|
|
682
|
-
for (let i = 0; i < quantidadeInterpolacoes.length; i++) {
|
|
683
|
-
const dados = {
|
|
684
|
-
tipo: quantidadeInterpolacoes[i].replace('%', ''),
|
|
685
|
-
valor: await this.avaliar(argumentos[i + 1])
|
|
686
|
-
};
|
|
687
|
-
if (this.verificaTipoDaInterpolação(dados)) {
|
|
688
|
-
formatoTexto = await this.substituirValor(formatoTexto, dados.valor, dados.tipo);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
return formatoTexto.trimEnd();
|
|
528
|
+
return comum.avaliarArgumentosEscreva(this, argumentos);
|
|
692
529
|
}
|
|
693
530
|
/**
|
|
694
531
|
* Execução de uma escrita na saída configurada, que pode ser `console` (padrão) ou
|
|
@@ -710,7 +547,7 @@ class InterpretadorBirl {
|
|
|
710
547
|
});
|
|
711
548
|
}
|
|
712
549
|
}
|
|
713
|
-
visitarExpressaoEscrevaMesmaLinha(declaracao) {
|
|
550
|
+
async visitarExpressaoEscrevaMesmaLinha(declaracao) {
|
|
714
551
|
throw new Error('Método não implementado.');
|
|
715
552
|
}
|
|
716
553
|
async visitarExpressaoBloco(declaracao) {
|
|
@@ -758,35 +595,35 @@ class InterpretadorBirl {
|
|
|
758
595
|
valor = await this.avaliar(declaracao.valor);
|
|
759
596
|
return new quebras_1.RetornoQuebra(valor);
|
|
760
597
|
}
|
|
761
|
-
visitarExpressaoDeleguaFuncao(expressao) {
|
|
762
|
-
|
|
763
|
-
}
|
|
598
|
+
// async visitarExpressaoDeleguaFuncao(expressao: any) {
|
|
599
|
+
// throw new Error('Método não implementado.');
|
|
600
|
+
// }
|
|
764
601
|
visitarExpressaoAtribuicaoPorIndice(expressao) {
|
|
765
602
|
throw new Error('Método não implementado.');
|
|
766
603
|
}
|
|
767
|
-
visitarExpressaoAcessoIndiceVariavel(expressao) {
|
|
604
|
+
async visitarExpressaoAcessoIndiceVariavel(expressao) {
|
|
768
605
|
throw new Error('Método não implementado.');
|
|
769
606
|
}
|
|
770
|
-
visitarExpressaoDefinirValor(expressao) {
|
|
607
|
+
async visitarExpressaoDefinirValor(expressao) {
|
|
771
608
|
throw new Error('Método não implementado.');
|
|
772
609
|
}
|
|
773
610
|
visitarDeclaracaoDefinicaoFuncao(declaracao) {
|
|
774
611
|
const funcao = new estruturas_1.DeleguaFuncao(declaracao.simbolo.lexema, declaracao.funcao);
|
|
775
612
|
this.pilhaEscoposExecucao.definirVariavel(declaracao.simbolo.lexema, funcao);
|
|
776
613
|
}
|
|
777
|
-
visitarDeclaracaoClasse(declaracao) {
|
|
614
|
+
async visitarDeclaracaoClasse(declaracao) {
|
|
778
615
|
throw new Error('Método não implementado.');
|
|
779
616
|
}
|
|
780
|
-
visitarExpressaoAcessoMetodo(expressao) {
|
|
617
|
+
async visitarExpressaoAcessoMetodo(expressao) {
|
|
781
618
|
throw new Error('Método não implementado.');
|
|
782
619
|
}
|
|
783
620
|
visitarExpressaoIsto(expressao) {
|
|
784
621
|
throw new Error('Método não implementado.');
|
|
785
622
|
}
|
|
786
|
-
visitarExpressaoDicionario(expressao) {
|
|
623
|
+
async visitarExpressaoDicionario(expressao) {
|
|
787
624
|
throw new Error('Método não implementado.');
|
|
788
625
|
}
|
|
789
|
-
visitarExpressaoVetor(expressao) {
|
|
626
|
+
async visitarExpressaoVetor(expressao) {
|
|
790
627
|
throw new Error('Método não implementado.');
|
|
791
628
|
}
|
|
792
629
|
visitarExpressaoSuper(expressao) {
|
|
@@ -867,37 +704,7 @@ class InterpretadorBirl {
|
|
|
867
704
|
}
|
|
868
705
|
}
|
|
869
706
|
async interpretar(declaracoes, manterAmbiente) {
|
|
870
|
-
this
|
|
871
|
-
const escopoExecucao = {
|
|
872
|
-
declaracoes: declaracoes,
|
|
873
|
-
declaracaoAtual: 0,
|
|
874
|
-
ambiente: new espaco_variaveis_1.EspacoVariaveis(),
|
|
875
|
-
finalizado: false,
|
|
876
|
-
tipo: 'outro',
|
|
877
|
-
emLacoRepeticao: false,
|
|
878
|
-
};
|
|
879
|
-
this.pilhaEscoposExecucao.empilhar(escopoExecucao);
|
|
880
|
-
try {
|
|
881
|
-
const retornoOuErro = await this.executarUltimoEscopo(manterAmbiente);
|
|
882
|
-
if (retornoOuErro instanceof excecoes_1.ErroEmTempoDeExecucao) {
|
|
883
|
-
this.erros.push(retornoOuErro);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
catch (erro) {
|
|
887
|
-
this.erros.push({
|
|
888
|
-
erroInterno: erro,
|
|
889
|
-
linha: -1,
|
|
890
|
-
hashArquivo: -1,
|
|
891
|
-
});
|
|
892
|
-
}
|
|
893
|
-
finally {
|
|
894
|
-
const retorno = {
|
|
895
|
-
erros: this.erros,
|
|
896
|
-
resultado: this.resultadoInterpretador,
|
|
897
|
-
};
|
|
898
|
-
this.resultadoInterpretador = [];
|
|
899
|
-
return retorno;
|
|
900
|
-
}
|
|
707
|
+
return comum.interpretar(this, declaracoes, manterAmbiente);
|
|
901
708
|
}
|
|
902
709
|
}
|
|
903
710
|
exports.InterpretadorBirl = InterpretadorBirl;
|