@designliquido/delegua 0.7.5 → 0.8.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 +70 -65
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.d.ts +63 -0
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.js +180 -0
- package/fontes/avaliador-sintatico/avaliador-sintatico-base.js.map +1 -0
- package/fontes/avaliador-sintatico/avaliador-sintatico.js +188 -188
- package/fontes/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts +34 -32
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js +154 -148
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.d.ts +7 -6
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.js +144 -142
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-eguap.js.map +1 -1
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.d.ts +48 -0
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.js +291 -0
- package/fontes/avaliador-sintatico/dialetos/avaliador-sintatico-visualg.js.map +1 -0
- package/fontes/construtos/construto.d.ts +1 -0
- package/fontes/construtos/literal.d.ts +2 -2
- package/fontes/construtos/literal.js.map +1 -1
- package/fontes/construtos/super.d.ts +4 -4
- package/fontes/construtos/super.js.map +1 -1
- package/fontes/construtos/vetor.d.ts +3 -3
- package/fontes/construtos/vetor.js.map +1 -1
- package/fontes/declaracoes/bloco.d.ts +2 -2
- package/fontes/declaracoes/bloco.js.map +1 -1
- package/fontes/declaracoes/escolha.d.ts +5 -2
- package/fontes/declaracoes/escolha.js +6 -3
- package/fontes/declaracoes/escolha.js.map +1 -1
- package/fontes/declaracoes/escreva.d.ts +3 -3
- package/fontes/declaracoes/escreva.js.map +1 -1
- package/fontes/declaracoes/index.d.ts +1 -0
- package/fontes/declaracoes/index.js +1 -0
- package/fontes/declaracoes/index.js.map +1 -1
- package/fontes/declaracoes/leia.d.ts +12 -0
- package/fontes/declaracoes/leia.js +37 -0
- package/fontes/declaracoes/leia.js.map +1 -0
- package/fontes/declaracoes/var.d.ts +3 -2
- package/fontes/declaracoes/var.js.map +1 -1
- package/fontes/delegua.d.ts +2 -2
- package/fontes/delegua.js +37 -21
- package/fontes/delegua.js.map +1 -1
- package/fontes/interfaces/avaliador-sintatico-interface.d.ts +3 -5
- package/fontes/interfaces/interpretador-interface.d.ts +8 -7
- package/fontes/interfaces/lexador-interface.d.ts +2 -2
- package/fontes/interpretador/dialetos/egua-classico.d.ts +7 -1
- package/fontes/interpretador/dialetos/egua-classico.js +38 -30
- package/fontes/interpretador/dialetos/egua-classico.js.map +1 -1
- package/fontes/interpretador/interpretador.d.ts +19 -3
- package/fontes/interpretador/interpretador.js +51 -33
- package/fontes/interpretador/interpretador.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-egua-classico.js +35 -35
- package/fontes/lexador/dialetos/lexador-egua-classico.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-eguap.js +35 -35
- package/fontes/lexador/dialetos/lexador-eguap.js.map +1 -1
- package/fontes/lexador/dialetos/lexador-visualg.d.ts +16 -0
- package/fontes/lexador/dialetos/lexador-visualg.js +225 -0
- package/fontes/lexador/dialetos/lexador-visualg.js.map +1 -0
- package/fontes/lexador/dialetos/palavras-reservadas/visualg.d.ts +26 -0
- package/fontes/lexador/dialetos/palavras-reservadas/visualg.js +32 -0
- package/fontes/lexador/dialetos/palavras-reservadas/visualg.js.map +1 -0
- package/fontes/lexador/lexador-base-linha-unica.d.ts +33 -0
- package/fontes/lexador/lexador-base-linha-unica.js +92 -0
- package/fontes/lexador/lexador-base-linha-unica.js.map +1 -0
- package/fontes/lexador/lexador.d.ts +3 -3
- package/fontes/lexador/lexador.js +43 -43
- package/fontes/lexador/lexador.js.map +1 -1
- package/fontes/lexador/palavras-reservadas.js +33 -33
- package/fontes/lexador/palavras-reservadas.js.map +1 -1
- package/fontes/tipos/avaliador-sintatico-egua-e-eguap-classico-returno-tipo.d.ts +5 -0
- package/fontes/tipos/avaliador-sintatico-egua-e-eguap-classico-returno-tipo.js +3 -0
- package/fontes/tipos/avaliador-sintatico-egua-e-eguap-classico-returno-tipo.js.map +1 -0
- package/fontes/tipos-de-simbolos/comum.d.ts +18 -0
- package/fontes/tipos-de-simbolos/comum.js +20 -0
- package/fontes/tipos-de-simbolos/comum.js.map +1 -0
- package/fontes/{tipos-de-simbolos.d.ts → tipos-de-simbolos/delegua.d.ts} +0 -0
- package/fontes/{tipos-de-simbolos.js → tipos-de-simbolos/delegua.js} +1 -1
- package/fontes/tipos-de-simbolos/delegua.js.map +1 -0
- package/fontes/{lexador/dialetos/tipos-de-simbolos-eguap.d.ts → tipos-de-simbolos/eguap.d.ts} +0 -0
- package/fontes/{lexador/dialetos/tipos-de-simbolos-eguap.js → tipos-de-simbolos/eguap.js} +1 -1
- package/fontes/tipos-de-simbolos/eguap.js.map +1 -0
- package/fontes/tipos-de-simbolos/visualg.d.ts +47 -0
- package/fontes/tipos-de-simbolos/visualg.js +49 -0
- package/fontes/tipos-de-simbolos/visualg.js.map +1 -0
- package/package.json +70 -65
- package/testes/avaliador-sintatico.test.js.map +1 -1
- package/testes/egua-classico/avaliador-sintatico.test.js +4 -1
- package/testes/egua-classico/avaliador-sintatico.test.js.map +1 -1
- package/testes/lexador.test.js +45 -45
- package/testes/lexador.test.js.map +1 -1
- package/testes/visualg/avaliador-sintatico.test.d.ts +1 -0
- package/testes/visualg/avaliador-sintatico.test.js +113 -0
- package/testes/visualg/avaliador-sintatico.test.js.map +1 -0
- package/testes/visualg/lexador.test.d.ts +1 -0
- package/testes/visualg/lexador.test.js +67 -0
- package/testes/visualg/lexador.test.js.map +1 -0
- package/fontes/lexador/dialetos/tipos-de-simbolos-eguap.js.map +0 -1
- package/fontes/tipos-de-simbolos.js.map +0 -1
|
@@ -7,7 +7,7 @@ exports.AvaliadorSintaticoEguaP = void 0;
|
|
|
7
7
|
var browser_process_hrtime_1 = __importDefault(require("browser-process-hrtime"));
|
|
8
8
|
var construtos_1 = require("../../construtos");
|
|
9
9
|
var declaracoes_1 = require("../../declaracoes");
|
|
10
|
-
var
|
|
10
|
+
var eguap_1 = __importDefault(require("../../tipos-de-simbolos/eguap"));
|
|
11
11
|
var erro_avaliador_sintatico_1 = require("../erro-avaliador-sintatico");
|
|
12
12
|
/**
|
|
13
13
|
* O avaliador sintático (Parser) é responsável por transformar os símbolos do Lexador em estruturas de alto nível.
|
|
@@ -29,15 +29,15 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
29
29
|
this.avancarEDevolverAnterior();
|
|
30
30
|
while (!this.estaNoFinal()) {
|
|
31
31
|
switch (this.simboloAtual().tipo) {
|
|
32
|
-
case
|
|
33
|
-
case
|
|
34
|
-
case
|
|
35
|
-
case
|
|
36
|
-
case
|
|
37
|
-
case
|
|
38
|
-
case
|
|
39
|
-
case
|
|
40
|
-
case
|
|
32
|
+
case eguap_1.default.CLASSE:
|
|
33
|
+
case eguap_1.default.FUNCAO:
|
|
34
|
+
case eguap_1.default.FUNÇÃO:
|
|
35
|
+
case eguap_1.default.VARIAVEL:
|
|
36
|
+
case eguap_1.default.PARA:
|
|
37
|
+
case eguap_1.default.SE:
|
|
38
|
+
case eguap_1.default.ENQUANTO:
|
|
39
|
+
case eguap_1.default.ESCREVA:
|
|
40
|
+
case eguap_1.default.RETORNA:
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
this.avancarEDevolverAnterior();
|
|
@@ -95,95 +95,95 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
95
95
|
return false;
|
|
96
96
|
};
|
|
97
97
|
AvaliadorSintaticoEguaP.prototype.primario = function () {
|
|
98
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
98
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.SUPER)) {
|
|
99
99
|
var simboloChave = this.simboloAnterior();
|
|
100
|
-
this.consumir(
|
|
101
|
-
var metodo = this.consumir(
|
|
100
|
+
this.consumir(eguap_1.default.PONTO, "Esperado '.' após 'super'.");
|
|
101
|
+
var metodo = this.consumir(eguap_1.default.IDENTIFICADOR, 'Esperado nome do método da SuperClasse.');
|
|
102
102
|
return new construtos_1.Super(this.hashArquivo, simboloChave, metodo);
|
|
103
103
|
}
|
|
104
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
104
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.COLCHETE_ESQUERDO)) {
|
|
105
105
|
var valores = [];
|
|
106
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
106
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.COLCHETE_DIREITO)) {
|
|
107
107
|
return new construtos_1.Vetor(this.hashArquivo, 0, []);
|
|
108
108
|
}
|
|
109
|
-
while (!this.verificarSeSimboloAtualEIgualA(
|
|
109
|
+
while (!this.verificarSeSimboloAtualEIgualA(eguap_1.default.COLCHETE_DIREITO)) {
|
|
110
110
|
var valor = this.atribuir();
|
|
111
111
|
valores.push(valor);
|
|
112
112
|
if (this.simboloAtual().tipo !==
|
|
113
|
-
|
|
114
|
-
this.consumir(
|
|
113
|
+
eguap_1.default.COLCHETE_DIREITO) {
|
|
114
|
+
this.consumir(eguap_1.default.VIRGULA, 'Esperado vírgula antes da próxima expressão.');
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
return new construtos_1.Vetor(this.hashArquivo, 0, valores);
|
|
118
118
|
}
|
|
119
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
119
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.CHAVE_ESQUERDA)) {
|
|
120
120
|
var chaves = [];
|
|
121
121
|
var valores = [];
|
|
122
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
122
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.CHAVE_DIREITA)) {
|
|
123
123
|
return new construtos_1.Dicionario(this.hashArquivo, 0, [], []);
|
|
124
124
|
}
|
|
125
|
-
while (!this.verificarSeSimboloAtualEIgualA(
|
|
125
|
+
while (!this.verificarSeSimboloAtualEIgualA(eguap_1.default.CHAVE_DIREITA)) {
|
|
126
126
|
var chave = this.atribuir();
|
|
127
|
-
this.consumir(
|
|
127
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' entre chave e valor.");
|
|
128
128
|
var valor = this.atribuir();
|
|
129
129
|
chaves.push(chave);
|
|
130
130
|
valores.push(valor);
|
|
131
|
-
if (this.simboloAtual().tipo !==
|
|
132
|
-
this.consumir(
|
|
131
|
+
if (this.simboloAtual().tipo !== eguap_1.default.CHAVE_DIREITA) {
|
|
132
|
+
this.consumir(eguap_1.default.VIRGULA, 'Esperado vírgula antes da próxima expressão.');
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
return new construtos_1.Dicionario(this.hashArquivo, 0, chaves, valores);
|
|
136
136
|
}
|
|
137
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
137
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.FALSO))
|
|
138
138
|
return new construtos_1.Literal(this.hashArquivo, 0, false);
|
|
139
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
139
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.VERDADEIRO))
|
|
140
140
|
return new construtos_1.Literal(this.hashArquivo, 0, true);
|
|
141
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
141
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.NULO))
|
|
142
142
|
return new construtos_1.Literal(this.hashArquivo, 0, null);
|
|
143
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
143
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.ISTO))
|
|
144
144
|
return new construtos_1.Isto(this.hashArquivo, 0, this.simboloAnterior());
|
|
145
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
145
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.NUMERO, eguap_1.default.TEXTO)) {
|
|
146
146
|
var simboloAnterior = this.simboloAnterior();
|
|
147
147
|
return new construtos_1.Literal(this.hashArquivo, Number(simboloAnterior.linha), simboloAnterior.literal);
|
|
148
148
|
}
|
|
149
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
149
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.IDENTIFICADOR)) {
|
|
150
150
|
return new construtos_1.Variavel(this.hashArquivo, this.simboloAnterior());
|
|
151
151
|
}
|
|
152
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
152
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.PARENTESE_ESQUERDO)) {
|
|
153
153
|
var expressao = this.expressao();
|
|
154
|
-
this.consumir(
|
|
154
|
+
this.consumir(eguap_1.default.PARENTESE_DIREITO, "Esperado ')' após a expressão.");
|
|
155
155
|
return new construtos_1.Agrupamento(this.hashArquivo, 0, expressao);
|
|
156
156
|
}
|
|
157
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
157
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.IMPORTAR))
|
|
158
158
|
return this.declaracaoImportar();
|
|
159
159
|
throw this.erro(this.simboloAtual(), 'Esperado expressão.');
|
|
160
160
|
};
|
|
161
161
|
AvaliadorSintaticoEguaP.prototype.finalizarChamada = function (entidadeChamada) {
|
|
162
162
|
var argumentos = [];
|
|
163
|
-
if (!this.verificarTipoSimboloAtual(
|
|
163
|
+
if (!this.verificarTipoSimboloAtual(eguap_1.default.PARENTESE_DIREITO)) {
|
|
164
164
|
do {
|
|
165
165
|
if (argumentos.length >= 255) {
|
|
166
166
|
throw this.erro(this.simboloAtual(), 'Não pode haver mais de 255 argumentos.');
|
|
167
167
|
}
|
|
168
168
|
argumentos.push(this.expressao());
|
|
169
|
-
} while (this.verificarSeSimboloAtualEIgualA(
|
|
169
|
+
} while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.VIRGULA));
|
|
170
170
|
}
|
|
171
|
-
var parenteseDireito = this.consumir(
|
|
171
|
+
var parenteseDireito = this.consumir(eguap_1.default.PARENTESE_DIREITO, "Esperado ')' após os argumentos.");
|
|
172
172
|
return new construtos_1.Chamada(this.hashArquivo, entidadeChamada, parenteseDireito, argumentos);
|
|
173
173
|
};
|
|
174
174
|
AvaliadorSintaticoEguaP.prototype.chamar = function () {
|
|
175
175
|
var expressao = this.primario();
|
|
176
176
|
while (true) {
|
|
177
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
177
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.PARENTESE_ESQUERDO)) {
|
|
178
178
|
expressao = this.finalizarChamada(expressao);
|
|
179
179
|
}
|
|
180
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
181
|
-
var nome = this.consumir(
|
|
180
|
+
else if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.PONTO)) {
|
|
181
|
+
var nome = this.consumir(eguap_1.default.IDENTIFICADOR, "Esperado nome do método após '.'.");
|
|
182
182
|
expressao = new construtos_1.AcessoMetodo(this.hashArquivo, expressao, nome);
|
|
183
183
|
}
|
|
184
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
184
|
+
else if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.COLCHETE_ESQUERDO)) {
|
|
185
185
|
var indice = this.expressao();
|
|
186
|
-
var simboloFechamento = this.consumir(
|
|
186
|
+
var simboloFechamento = this.consumir(eguap_1.default.COLCHETE_DIREITO, "Esperado ']' após escrita do indice.");
|
|
187
187
|
expressao = new construtos_1.AcessoIndiceVariavel(this.hashArquivo, expressao, indice, simboloFechamento);
|
|
188
188
|
}
|
|
189
189
|
else {
|
|
@@ -193,7 +193,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
193
193
|
return expressao;
|
|
194
194
|
};
|
|
195
195
|
AvaliadorSintaticoEguaP.prototype.unario = function () {
|
|
196
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
196
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.NEGACAO, eguap_1.default.SUBTRACAO, eguap_1.default.BIT_NOT)) {
|
|
197
197
|
var operador = this.simboloAnterior();
|
|
198
198
|
var direito = this.unario();
|
|
199
199
|
return new construtos_1.Unario(this.hashArquivo, operador, direito);
|
|
@@ -202,7 +202,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
202
202
|
};
|
|
203
203
|
AvaliadorSintaticoEguaP.prototype.exponenciacao = function () {
|
|
204
204
|
var expressao = this.unario();
|
|
205
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
205
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.EXPONENCIACAO)) {
|
|
206
206
|
var operador = this.simboloAnterior();
|
|
207
207
|
var direito = this.unario();
|
|
208
208
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -211,7 +211,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
211
211
|
};
|
|
212
212
|
AvaliadorSintaticoEguaP.prototype.multiplicar = function () {
|
|
213
213
|
var expressao = this.exponenciacao();
|
|
214
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
214
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.DIVISAO, eguap_1.default.MULTIPLICACAO, eguap_1.default.MODULO)) {
|
|
215
215
|
var operador = this.simboloAnterior();
|
|
216
216
|
var direito = this.exponenciacao();
|
|
217
217
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -220,7 +220,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
220
220
|
};
|
|
221
221
|
AvaliadorSintaticoEguaP.prototype.adicaoOuSubtracao = function () {
|
|
222
222
|
var expressao = this.multiplicar();
|
|
223
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
223
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.SUBTRACAO, eguap_1.default.ADICAO)) {
|
|
224
224
|
var operador = this.simboloAnterior();
|
|
225
225
|
var direito = this.multiplicar();
|
|
226
226
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -229,7 +229,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
229
229
|
};
|
|
230
230
|
AvaliadorSintaticoEguaP.prototype.bitFill = function () {
|
|
231
231
|
var expressao = this.adicaoOuSubtracao();
|
|
232
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
232
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.MENOR_MENOR, eguap_1.default.MAIOR_MAIOR)) {
|
|
233
233
|
var operador = this.simboloAnterior();
|
|
234
234
|
var direito = this.adicaoOuSubtracao();
|
|
235
235
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -238,7 +238,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
238
238
|
};
|
|
239
239
|
AvaliadorSintaticoEguaP.prototype.bitE = function () {
|
|
240
240
|
var expressao = this.bitFill();
|
|
241
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
241
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.BIT_AND)) {
|
|
242
242
|
var operador = this.simboloAnterior();
|
|
243
243
|
var direito = this.bitFill();
|
|
244
244
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -247,7 +247,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
247
247
|
};
|
|
248
248
|
AvaliadorSintaticoEguaP.prototype.bitOu = function () {
|
|
249
249
|
var expressao = this.bitE();
|
|
250
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
250
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.BIT_OR, eguap_1.default.BIT_XOR)) {
|
|
251
251
|
var operador = this.simboloAnterior();
|
|
252
252
|
var direito = this.bitE();
|
|
253
253
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -256,7 +256,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
256
256
|
};
|
|
257
257
|
AvaliadorSintaticoEguaP.prototype.comparar = function () {
|
|
258
258
|
var expressao = this.bitOu();
|
|
259
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
259
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.MAIOR, eguap_1.default.MAIOR_IGUAL, eguap_1.default.MENOR, eguap_1.default.MENOR_IGUAL)) {
|
|
260
260
|
var operador = this.simboloAnterior();
|
|
261
261
|
var direito = this.bitOu();
|
|
262
262
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -265,7 +265,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
265
265
|
};
|
|
266
266
|
AvaliadorSintaticoEguaP.prototype.comparacaoIgualdade = function () {
|
|
267
267
|
var expressao = this.comparar();
|
|
268
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
268
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.DIFERENTE, eguap_1.default.IGUAL_IGUAL)) {
|
|
269
269
|
var operador = this.simboloAnterior();
|
|
270
270
|
var direito = this.comparar();
|
|
271
271
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -274,7 +274,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
274
274
|
};
|
|
275
275
|
AvaliadorSintaticoEguaP.prototype.em = function () {
|
|
276
276
|
var expressao = this.comparacaoIgualdade();
|
|
277
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
277
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.EM)) {
|
|
278
278
|
var operador = this.simboloAnterior();
|
|
279
279
|
var direito = this.comparacaoIgualdade();
|
|
280
280
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
@@ -283,7 +283,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
283
283
|
};
|
|
284
284
|
AvaliadorSintaticoEguaP.prototype.e = function () {
|
|
285
285
|
var expressao = this.em();
|
|
286
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
286
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.E)) {
|
|
287
287
|
var operador = this.simboloAnterior();
|
|
288
288
|
var direito = this.em();
|
|
289
289
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
@@ -292,7 +292,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
292
292
|
};
|
|
293
293
|
AvaliadorSintaticoEguaP.prototype.ou = function () {
|
|
294
294
|
var expressao = this.e();
|
|
295
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
295
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.OU)) {
|
|
296
296
|
var operador = this.simboloAnterior();
|
|
297
297
|
var direito = this.e();
|
|
298
298
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
@@ -301,8 +301,8 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
301
301
|
};
|
|
302
302
|
AvaliadorSintaticoEguaP.prototype.atribuir = function () {
|
|
303
303
|
var expressao = this.ou();
|
|
304
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
305
|
-
this.verificarSeSimboloAtualEIgualA(
|
|
304
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.IGUAL) ||
|
|
305
|
+
this.verificarSeSimboloAtualEIgualA(eguap_1.default.MAIS_IGUAL)) {
|
|
306
306
|
var igual = this.simboloAnterior();
|
|
307
307
|
var valor = this.atribuir();
|
|
308
308
|
if (expressao instanceof construtos_1.Variavel) {
|
|
@@ -324,12 +324,12 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
324
324
|
};
|
|
325
325
|
AvaliadorSintaticoEguaP.prototype.declaracaoEscreva = function () {
|
|
326
326
|
var simboloAtual = this.simboloAtual();
|
|
327
|
-
this.consumir(
|
|
327
|
+
this.consumir(eguap_1.default.PARENTESE_ESQUERDO, "Esperado '(' antes dos valores em escreva.");
|
|
328
328
|
var argumentos = [];
|
|
329
329
|
do {
|
|
330
330
|
argumentos.push(this.expressao());
|
|
331
|
-
} while (this.verificarSeSimboloAtualEIgualA(
|
|
332
|
-
this.consumir(
|
|
331
|
+
} while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.VIRGULA));
|
|
332
|
+
this.consumir(eguap_1.default.PARENTESE_DIREITO, "Esperado ')' após os valores em escreva.");
|
|
333
333
|
return new declaracoes_1.Escreva(Number(simboloAtual.linha), simboloAtual.hashArquivo, argumentos);
|
|
334
334
|
};
|
|
335
335
|
AvaliadorSintaticoEguaP.prototype.declaracaoExpressao = function () {
|
|
@@ -341,7 +341,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
341
341
|
var simboloAtual = this.simboloAtual();
|
|
342
342
|
var simboloAnterior = this.simboloAnterior();
|
|
343
343
|
// Situação 1: não tem bloco de escopo.
|
|
344
|
-
//
|
|
344
|
+
//
|
|
345
345
|
// Exemplo: `se verdadeiro: escreva('Alguma coisa')`.
|
|
346
346
|
// Neste caso, linha do símbolo atual é igual à linha do símbolo anterior.
|
|
347
347
|
if (simboloAtual.linha === simboloAnterior.linha) {
|
|
@@ -349,10 +349,10 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
349
349
|
}
|
|
350
350
|
else {
|
|
351
351
|
// Situação 2: símbolo atual fica na próxima linha.
|
|
352
|
-
//
|
|
353
|
-
// Verifica-se o número de espaços à esquerda da linha através dos pragmas.
|
|
352
|
+
//
|
|
353
|
+
// Verifica-se o número de espaços à esquerda da linha através dos pragmas.
|
|
354
354
|
// Se número de espaços da linha do símbolo atual é menor ou igual ao número de espaços
|
|
355
|
-
// da linha anterior, e bloco ainda não começou, é uma situação de erro.
|
|
355
|
+
// da linha anterior, e bloco ainda não começou, é uma situação de erro.
|
|
356
356
|
var espacosIndentacaoLinhaAtual = this.pragmas[simboloAtual.linha].espacosIndentacao;
|
|
357
357
|
var espacosIndentacaoLinhaAnterior = this.pragmas[simboloAnterior.linha].espacosIndentacao;
|
|
358
358
|
if (espacosIndentacaoLinhaAtual <= espacosIndentacaoLinhaAnterior) {
|
|
@@ -361,7 +361,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
361
361
|
"Atual: ".concat(espacosIndentacaoLinhaAtual));
|
|
362
362
|
}
|
|
363
363
|
else {
|
|
364
|
-
// Indentação ok, é um bloco de escopo.
|
|
364
|
+
// Indentação ok, é um bloco de escopo.
|
|
365
365
|
// Inclui todas as declarações cujas linhas tenham o mesmo número de espaços
|
|
366
366
|
// de indentação do bloco.
|
|
367
367
|
// Se `simboloAtual` for definido em algum momento como indefinido,
|
|
@@ -372,35 +372,36 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
372
372
|
simboloAtual = this.simboloAtual();
|
|
373
373
|
if (!simboloAtual)
|
|
374
374
|
break;
|
|
375
|
-
espacosIndentacaoLinhaAtual =
|
|
375
|
+
espacosIndentacaoLinhaAtual =
|
|
376
|
+
this.pragmas[simboloAtual.linha].espacosIndentacao;
|
|
376
377
|
}
|
|
377
378
|
}
|
|
378
379
|
}
|
|
379
380
|
return declaracoes;
|
|
380
381
|
};
|
|
381
382
|
AvaliadorSintaticoEguaP.prototype.declaracaoSe = function () {
|
|
382
|
-
this.consumir(
|
|
383
|
+
this.consumir(eguap_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'se'.");
|
|
383
384
|
var condicao = this.expressao();
|
|
384
|
-
this.consumir(
|
|
385
|
+
this.consumir(eguap_1.default.PARENTESE_DIREITO, "Esperado ')' após condição do se.");
|
|
385
386
|
var caminhoEntao = this.resolverDeclaracao();
|
|
386
387
|
var caminhosSeSenao = [];
|
|
387
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
388
|
-
this.consumir(
|
|
388
|
+
while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.SENAOSE, eguap_1.default.SENÃOSE)) {
|
|
389
|
+
this.consumir(eguap_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'senaose' ou 'senãose'.");
|
|
389
390
|
var condicaoSeSenao = this.expressao();
|
|
390
|
-
this.consumir(
|
|
391
|
+
this.consumir(eguap_1.default.PARENTESE_DIREITO, "Esperado ')' após codição do 'senaose' ou 'senãose'.");
|
|
391
392
|
var caminho = this.resolverDeclaracao();
|
|
392
393
|
caminhosSeSenao.push({
|
|
393
394
|
condicao: condicaoSeSenao,
|
|
394
395
|
caminho: caminho,
|
|
395
396
|
});
|
|
396
397
|
}
|
|
397
|
-
// Se há algum escopo aberto, conferir antes do senão se símbolo
|
|
398
|
+
// Se há algum escopo aberto, conferir antes do senão se símbolo
|
|
398
399
|
// atual é um espaço de indentação
|
|
399
400
|
/* if (this.escopos.length > 0) {
|
|
400
401
|
this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos.ESPACO_INDENTACAO);
|
|
401
402
|
} */
|
|
402
403
|
var caminhoSenao = null;
|
|
403
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
404
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.SENAO, eguap_1.default.SENÃO)) {
|
|
404
405
|
caminhoSenao = this.resolverDeclaracao();
|
|
405
406
|
}
|
|
406
407
|
return new declaracoes_1.Se(condicao, caminhoEntao, caminhosSeSenao, caminhoSenao);
|
|
@@ -408,9 +409,9 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
408
409
|
AvaliadorSintaticoEguaP.prototype.declaracaoEnquanto = function () {
|
|
409
410
|
try {
|
|
410
411
|
this.ciclos += 1;
|
|
411
|
-
this.consumir(
|
|
412
|
+
this.consumir(eguap_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'enquanto'.");
|
|
412
413
|
var condicao = this.expressao();
|
|
413
|
-
this.consumir(
|
|
414
|
+
this.consumir(eguap_1.default.PARENTESE_DIREITO, "Esperado ')' após condicional.");
|
|
414
415
|
var corpo = this.resolverDeclaracao();
|
|
415
416
|
return new declaracoes_1.Enquanto(condicao, corpo);
|
|
416
417
|
}
|
|
@@ -422,26 +423,26 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
422
423
|
try {
|
|
423
424
|
var simboloPara = this.simboloAnterior();
|
|
424
425
|
this.ciclos += 1;
|
|
425
|
-
this.consumir(
|
|
426
|
+
this.consumir(eguap_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'para'.");
|
|
426
427
|
var inicializador = void 0;
|
|
427
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
428
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.PONTO_E_VIRGULA)) {
|
|
428
429
|
inicializador = null;
|
|
429
430
|
}
|
|
430
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
431
|
+
else if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.VARIAVEL)) {
|
|
431
432
|
inicializador = this.declaracaoDeVariavel();
|
|
432
433
|
}
|
|
433
434
|
else {
|
|
434
435
|
inicializador = this.declaracaoExpressao();
|
|
435
436
|
}
|
|
436
437
|
var condicao = null;
|
|
437
|
-
if (!this.verificarTipoSimboloAtual(
|
|
438
|
+
if (!this.verificarTipoSimboloAtual(eguap_1.default.PONTO_E_VIRGULA)) {
|
|
438
439
|
condicao = this.expressao();
|
|
439
440
|
}
|
|
440
441
|
var incrementar = null;
|
|
441
|
-
if (!this.verificarTipoSimboloAtual(
|
|
442
|
+
if (!this.verificarTipoSimboloAtual(eguap_1.default.PARENTESE_DIREITO)) {
|
|
442
443
|
incrementar = this.expressao();
|
|
443
444
|
}
|
|
444
|
-
this.consumir(
|
|
445
|
+
this.consumir(eguap_1.default.PARENTESE_DIREITO, "Esperado ')' após cláusulas");
|
|
445
446
|
var corpo = this.resolverDeclaracao();
|
|
446
447
|
return new declaracoes_1.Para(this.hashArquivo, Number(simboloPara.linha), inicializador, condicao, incrementar, corpo);
|
|
447
448
|
}
|
|
@@ -467,7 +468,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
467
468
|
AvaliadorSintaticoEguaP.prototype.declaracaoRetorna = function () {
|
|
468
469
|
var palavraChave = this.simboloAnterior();
|
|
469
470
|
var valor = null;
|
|
470
|
-
if (!this.verificarTipoSimboloAtual(
|
|
471
|
+
if (!this.verificarTipoSimboloAtual(eguap_1.default.PONTO_E_VIRGULA)) {
|
|
471
472
|
valor = this.expressao();
|
|
472
473
|
}
|
|
473
474
|
return new declaracoes_1.Retorna(palavraChave, valor);
|
|
@@ -475,44 +476,44 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
475
476
|
AvaliadorSintaticoEguaP.prototype.declaracaoEscolha = function () {
|
|
476
477
|
try {
|
|
477
478
|
this.ciclos += 1;
|
|
478
|
-
this.consumir(
|
|
479
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' após 'escolha'.");
|
|
479
480
|
var condicao = this.expressao();
|
|
480
481
|
var caminhos = [];
|
|
481
482
|
var caminhoPadrao = null;
|
|
482
|
-
while (!this.verificarSeSimboloAtualEIgualA(
|
|
483
|
+
while (!this.verificarSeSimboloAtualEIgualA(eguap_1.default.CHAVE_DIREITA) &&
|
|
483
484
|
!this.estaNoFinal()) {
|
|
484
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
485
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.CASO)) {
|
|
485
486
|
var caminhoCondicoes = [this.expressao()];
|
|
486
|
-
this.consumir(
|
|
487
|
-
while (this.verificarTipoSimboloAtual(
|
|
488
|
-
this.consumir(
|
|
487
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' após o 'caso'.");
|
|
488
|
+
while (this.verificarTipoSimboloAtual(eguap_1.default.CASO)) {
|
|
489
|
+
this.consumir(eguap_1.default.CASO, null);
|
|
489
490
|
caminhoCondicoes.push(this.expressao());
|
|
490
|
-
this.consumir(
|
|
491
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' após declaração do 'caso'.");
|
|
491
492
|
}
|
|
492
493
|
var declaracoes = [];
|
|
493
494
|
do {
|
|
494
495
|
declaracoes.push(this.resolverDeclaracao());
|
|
495
|
-
} while (!this.verificarTipoSimboloAtual(
|
|
496
|
-
!this.verificarTipoSimboloAtual(
|
|
497
|
-
!this.verificarTipoSimboloAtual(
|
|
496
|
+
} while (!this.verificarTipoSimboloAtual(eguap_1.default.CASO) &&
|
|
497
|
+
!this.verificarTipoSimboloAtual(eguap_1.default.PADRAO) &&
|
|
498
|
+
!this.verificarTipoSimboloAtual(eguap_1.default.CHAVE_DIREITA));
|
|
498
499
|
caminhos.push({
|
|
499
500
|
condicoes: caminhoCondicoes,
|
|
500
501
|
declaracoes: declaracoes,
|
|
501
502
|
});
|
|
502
503
|
}
|
|
503
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
504
|
+
else if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.PADRAO)) {
|
|
504
505
|
if (caminhoPadrao !== null) {
|
|
505
506
|
var excecao = new erro_avaliador_sintatico_1.ErroAvaliadorSintatico(this.simboloAtual(), "Você só pode ter um 'padrao' em cada declaração de 'escolha'.");
|
|
506
507
|
this.erros.push(excecao);
|
|
507
508
|
throw excecao;
|
|
508
509
|
}
|
|
509
|
-
this.consumir(
|
|
510
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' após declaração do 'padrao'.");
|
|
510
511
|
var declaracoes = [];
|
|
511
512
|
do {
|
|
512
513
|
declaracoes.push(this.resolverDeclaracao());
|
|
513
|
-
} while (!this.verificarTipoSimboloAtual(
|
|
514
|
-
!this.verificarTipoSimboloAtual(
|
|
515
|
-
!this.verificarTipoSimboloAtual(
|
|
514
|
+
} while (!this.verificarTipoSimboloAtual(eguap_1.default.CASO) &&
|
|
515
|
+
!this.verificarTipoSimboloAtual(eguap_1.default.PADRAO) &&
|
|
516
|
+
!this.verificarTipoSimboloAtual(eguap_1.default.CHAVE_DIREITA));
|
|
516
517
|
caminhoPadrao = {
|
|
517
518
|
declaracoes: declaracoes,
|
|
518
519
|
};
|
|
@@ -525,28 +526,28 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
525
526
|
}
|
|
526
527
|
};
|
|
527
528
|
AvaliadorSintaticoEguaP.prototype.declaracaoImportar = function () {
|
|
528
|
-
this.consumir(
|
|
529
|
+
this.consumir(eguap_1.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração.");
|
|
529
530
|
var caminho = this.expressao();
|
|
530
|
-
var simboloFechamento = this.consumir(
|
|
531
|
+
var simboloFechamento = this.consumir(eguap_1.default.PARENTESE_DIREITO, "Esperado ')' após declaração.");
|
|
531
532
|
return new declaracoes_1.Importar(caminho, simboloFechamento);
|
|
532
533
|
};
|
|
533
534
|
AvaliadorSintaticoEguaP.prototype.declaracaoTente = function () {
|
|
534
535
|
var simboloTente = this.simboloAnterior();
|
|
535
|
-
this.consumir(
|
|
536
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' após a declaração 'tente'.");
|
|
536
537
|
var blocoTente = this.blocoEscopo();
|
|
537
538
|
var blocoPegue = null;
|
|
538
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
539
|
-
this.consumir(
|
|
539
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.PEGUE)) {
|
|
540
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' após a declaração 'pegue'.");
|
|
540
541
|
blocoPegue = this.blocoEscopo();
|
|
541
542
|
}
|
|
542
543
|
var blocoSenao = null;
|
|
543
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
544
|
-
this.consumir(
|
|
544
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.SENAO, eguap_1.default.SENÃO)) {
|
|
545
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' após a declaração 'pegue'.");
|
|
545
546
|
blocoSenao = this.blocoEscopo();
|
|
546
547
|
}
|
|
547
548
|
var blocoFinalmente = null;
|
|
548
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
549
|
-
this.consumir(
|
|
549
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.FINALMENTE)) {
|
|
550
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' após a declaração 'pegue'.");
|
|
550
551
|
blocoFinalmente = this.blocoEscopo();
|
|
551
552
|
}
|
|
552
553
|
return new declaracoes_1.Tente(simboloTente.hashArquivo, Number(simboloTente.linha), blocoTente, blocoPegue, blocoSenao, blocoFinalmente);
|
|
@@ -556,10 +557,10 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
556
557
|
try {
|
|
557
558
|
this.ciclos += 1;
|
|
558
559
|
var caminhoFazer = this.resolverDeclaracao();
|
|
559
|
-
this.consumir(
|
|
560
|
-
this.consumir(
|
|
560
|
+
this.consumir(eguap_1.default.ENQUANTO, "Esperado declaração do 'enquanto' após o escopo do 'fazer'.");
|
|
561
|
+
this.consumir(eguap_1.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração 'enquanto'.");
|
|
561
562
|
var condicaoEnquanto = this.expressao();
|
|
562
|
-
this.consumir(
|
|
563
|
+
this.consumir(eguap_1.default.PARENTESE_DIREITO, "Esperado ')' após declaração do 'enquanto'.");
|
|
563
564
|
return new declaracoes_1.Fazer(simboloFazer.hashArquivo, Number(simboloFazer.linha), caminhoFazer, condicaoEnquanto);
|
|
564
565
|
}
|
|
565
566
|
finally {
|
|
@@ -567,43 +568,44 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
567
568
|
}
|
|
568
569
|
};
|
|
569
570
|
AvaliadorSintaticoEguaP.prototype.resolverDeclaracao = function () {
|
|
570
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
571
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.FAZER))
|
|
571
572
|
return this.declaracaoFazer();
|
|
572
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
573
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.TENTE))
|
|
573
574
|
return this.declaracaoTente();
|
|
574
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
575
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.ESCOLHA))
|
|
575
576
|
return this.declaracaoEscolha();
|
|
576
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
577
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.RETORNA))
|
|
577
578
|
return this.declaracaoRetorna();
|
|
578
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
579
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.CONTINUA))
|
|
579
580
|
return this.declaracaoContinua();
|
|
580
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
581
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.SUSTAR) ||
|
|
582
|
+
this.verificarSeSimboloAtualEIgualA(eguap_1.default.PAUSA))
|
|
581
583
|
return this.declaracaoSustar();
|
|
582
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
584
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.PARA))
|
|
583
585
|
return this.declaracaoPara();
|
|
584
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
586
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.ENQUANTO))
|
|
585
587
|
return this.declaracaoEnquanto();
|
|
586
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
588
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.SE))
|
|
587
589
|
return this.declaracaoSe();
|
|
588
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
590
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.ESCREVA))
|
|
589
591
|
return this.declaracaoEscreva();
|
|
590
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
592
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.DOIS_PONTOS)) {
|
|
591
593
|
var simboloInicioBloco = this.simboloAnterior();
|
|
592
594
|
return new declaracoes_1.Bloco(simboloInicioBloco.hashArquivo, Number(simboloInicioBloco.linha), this.blocoEscopo());
|
|
593
595
|
}
|
|
594
596
|
return this.declaracaoExpressao();
|
|
595
597
|
};
|
|
596
598
|
AvaliadorSintaticoEguaP.prototype.declaracaoDeVariavel = function () {
|
|
597
|
-
var simbolo = this.consumir(
|
|
599
|
+
var simbolo = this.consumir(eguap_1.default.IDENTIFICADOR, 'Esperado nome de variável.');
|
|
598
600
|
var inicializador = null;
|
|
599
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
600
|
-
this.verificarSeSimboloAtualEIgualA(
|
|
601
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.IGUAL) ||
|
|
602
|
+
this.verificarSeSimboloAtualEIgualA(eguap_1.default.MAIS_IGUAL)) {
|
|
601
603
|
inicializador = this.expressao();
|
|
602
604
|
}
|
|
603
605
|
return new declaracoes_1.Var(simbolo, inicializador);
|
|
604
606
|
};
|
|
605
607
|
AvaliadorSintaticoEguaP.prototype.funcao = function (tipo) {
|
|
606
|
-
var simbolo = this.consumir(
|
|
608
|
+
var simbolo = this.consumir(eguap_1.default.IDENTIFICADOR, "Esperado nome ".concat(tipo, "."));
|
|
607
609
|
return new declaracoes_1.Funcao(simbolo, this.corpoDaFuncao(tipo));
|
|
608
610
|
};
|
|
609
611
|
AvaliadorSintaticoEguaP.prototype.logicaComumParametros = function () {
|
|
@@ -613,44 +615,44 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
613
615
|
this.erro(this.simboloAtual(), 'Não pode haver mais de 255 parâmetros');
|
|
614
616
|
}
|
|
615
617
|
var parametro = {};
|
|
616
|
-
if (this.simboloAtual().tipo ===
|
|
617
|
-
this.consumir(
|
|
618
|
+
if (this.simboloAtual().tipo === eguap_1.default.MULTIPLICACAO) {
|
|
619
|
+
this.consumir(eguap_1.default.MULTIPLICACAO, null);
|
|
618
620
|
parametro['tipo'] = 'estrela';
|
|
619
621
|
}
|
|
620
622
|
else {
|
|
621
623
|
parametro['tipo'] = 'padrao';
|
|
622
624
|
}
|
|
623
|
-
parametro['nome'] = this.consumir(
|
|
624
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
625
|
+
parametro['nome'] = this.consumir(eguap_1.default.IDENTIFICADOR, 'Esperado nome do parâmetro.');
|
|
626
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.IGUAL)) {
|
|
625
627
|
parametro['valorPadrao'] = this.primario();
|
|
626
628
|
}
|
|
627
629
|
parametros.push(parametro);
|
|
628
630
|
if (parametro['tipo'] === 'estrela')
|
|
629
631
|
break;
|
|
630
|
-
} while (this.verificarSeSimboloAtualEIgualA(
|
|
632
|
+
} while (this.verificarSeSimboloAtualEIgualA(eguap_1.default.VIRGULA));
|
|
631
633
|
return parametros;
|
|
632
634
|
};
|
|
633
635
|
AvaliadorSintaticoEguaP.prototype.corpoDaFuncao = function (tipo) {
|
|
634
|
-
this.consumir(
|
|
636
|
+
this.consumir(eguap_1.default.PARENTESE_ESQUERDO, "Esperado '(' ap\u00F3s o nome ".concat(tipo, "."));
|
|
635
637
|
var parametros = [];
|
|
636
|
-
if (!this.verificarTipoSimboloAtual(
|
|
638
|
+
if (!this.verificarTipoSimboloAtual(eguap_1.default.PARENTESE_DIREITO)) {
|
|
637
639
|
parametros = this.logicaComumParametros();
|
|
638
640
|
}
|
|
639
|
-
this.consumir(
|
|
640
|
-
this.consumir(
|
|
641
|
+
this.consumir(eguap_1.default.PARENTESE_DIREITO, "Esperado ')' após parâmetros.");
|
|
642
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' antes do escopo do ".concat(tipo, "."));
|
|
641
643
|
var corpo = this.blocoEscopo();
|
|
642
644
|
return new construtos_1.Funcao(this.hashArquivo, 0, parametros, corpo);
|
|
643
645
|
};
|
|
644
646
|
AvaliadorSintaticoEguaP.prototype.declaracaoDeClasse = function () {
|
|
645
|
-
var simbolo = this.consumir(
|
|
647
|
+
var simbolo = this.consumir(eguap_1.default.IDENTIFICADOR, 'Esperado nome da classe.');
|
|
646
648
|
var superClasse = null;
|
|
647
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
648
|
-
this.consumir(
|
|
649
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.HERDA)) {
|
|
650
|
+
this.consumir(eguap_1.default.IDENTIFICADOR, 'Esperado nome da SuperClasse.');
|
|
649
651
|
superClasse = new construtos_1.Variavel(this.hashArquivo, this.simboloAnterior());
|
|
650
652
|
}
|
|
651
|
-
this.consumir(
|
|
653
|
+
this.consumir(eguap_1.default.DOIS_PONTOS, "Esperado ':' antes do escopo da classe.");
|
|
652
654
|
var metodos = [];
|
|
653
|
-
while (!this.verificarTipoSimboloAtual(
|
|
655
|
+
while (!this.verificarTipoSimboloAtual(eguap_1.default.CHAVE_DIREITA) &&
|
|
654
656
|
!this.estaNoFinal()) {
|
|
655
657
|
metodos.push(this.funcao('método'));
|
|
656
658
|
}
|
|
@@ -663,15 +665,15 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
663
665
|
*/
|
|
664
666
|
AvaliadorSintaticoEguaP.prototype.declaracao = function () {
|
|
665
667
|
try {
|
|
666
|
-
if ((this.verificarTipoSimboloAtual(
|
|
667
|
-
|
|
668
|
-
|
|
668
|
+
if ((this.verificarTipoSimboloAtual(eguap_1.default.FUNCAO) ||
|
|
669
|
+
this.verificarTipoSimboloAtual(eguap_1.default.FUNÇÃO)) &&
|
|
670
|
+
this.verificarTipoProximoSimbolo(eguap_1.default.IDENTIFICADOR)) {
|
|
669
671
|
this.avancarEDevolverAnterior();
|
|
670
672
|
return this.funcao('funcao');
|
|
671
673
|
}
|
|
672
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
674
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.VARIAVEL))
|
|
673
675
|
return this.declaracaoDeVariavel();
|
|
674
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
676
|
+
if (this.verificarSeSimboloAtualEIgualA(eguap_1.default.CLASSE))
|
|
675
677
|
return this.declaracaoDeClasse();
|
|
676
678
|
return this.resolverDeclaracao();
|
|
677
679
|
}
|
|
@@ -699,7 +701,7 @@ var AvaliadorSintaticoEguaP = /** @class */ (function () {
|
|
|
699
701
|
}
|
|
700
702
|
return {
|
|
701
703
|
declaracoes: declaracoes,
|
|
702
|
-
erros: this.erros
|
|
704
|
+
erros: this.erros,
|
|
703
705
|
};
|
|
704
706
|
};
|
|
705
707
|
return AvaliadorSintaticoEguaP;
|