@designliquido/delegua 0.2.3 → 0.2.4
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 +1 -1
- package/fontes/avaliador-sintatico/dialetos/egua-classico.js +146 -148
- package/fontes/avaliador-sintatico/dialetos/egua-classico.js.map +1 -1
- package/fontes/avaliador-sintatico/index.js +146 -148
- package/fontes/avaliador-sintatico/index.js.map +1 -1
- package/fontes/delegua.d.ts +2 -2
- package/fontes/delegua.js +9 -3
- package/fontes/delegua.js.map +1 -1
- package/fontes/interfaces/delegua-interface.d.ts +3 -0
- package/fontes/interfaces/delegua-interface.js +3 -0
- package/fontes/interfaces/delegua-interface.js.map +1 -0
- package/fontes/interfaces/index.d.ts +7 -6
- package/fontes/interfaces/index.js +1 -0
- package/fontes/interfaces/index.js.map +1 -1
- package/fontes/interfaces/interpretador-interface.d.ts +2 -1
- package/fontes/interpretador/dialetos/egua-classico.d.ts +5 -2
- package/fontes/interpretador/dialetos/egua-classico.js +30 -25
- package/fontes/interpretador/dialetos/egua-classico.js.map +1 -1
- package/fontes/interpretador/erro-interpretador.d.ts +5 -0
- package/fontes/interpretador/erro-interpretador.js +3 -0
- package/fontes/interpretador/erro-interpretador.js.map +1 -0
- package/fontes/interpretador/index.d.ts +4 -1
- package/fontes/interpretador/index.js +30 -25
- package/fontes/interpretador/index.js.map +1 -1
- package/fontes/interpretador/retorno-interpretador.d.ts +4 -0
- package/fontes/interpretador/retorno-interpretador.js +3 -0
- package/fontes/interpretador/retorno-interpretador.js.map +1 -0
- package/fontes/lexador/dialetos/egua-classico.js +64 -64
- package/fontes/lexador/dialetos/egua-classico.js.map +1 -1
- package/fontes/lexador/index.js +67 -67
- package/fontes/lexador/index.js.map +1 -1
- package/fontes/{tiposDeSimbolos.d.ts → tipos-de-simbolos.d.ts} +0 -0
- package/fontes/{tiposDeSimbolos.js → tipos-de-simbolos.js} +1 -1
- package/fontes/tipos-de-simbolos.js.map +1 -0
- package/package.json +1 -1
- package/testes/biblioteca-global.test.js +29 -29
- package/testes/biblioteca-global.test.js.map +1 -1
- package/testes/egua-classico/avaliador-sintatico.test.js +6 -15
- package/testes/egua-classico/avaliador-sintatico.test.js.map +1 -1
- package/testes/egua-classico/interpretador.test.js +41 -41
- package/testes/egua-classico/interpretador.test.js.map +1 -1
- package/testes/egua-classico/resolvedor.test.js +3 -3
- package/testes/egua-classico/resolvedor.test.js.map +1 -1
- package/testes/interpretador.test.js +41 -41
- package/testes/interpretador.test.js.map +1 -1
- package/fontes/tiposDeSimbolos.js.map +0 -1
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AvaliadorSintatico = void 0;
|
|
7
|
-
var
|
|
7
|
+
var tipos_de_simbolos_1 = __importDefault(require("../tipos-de-simbolos"));
|
|
8
8
|
var perf_hooks_1 = require("perf_hooks");
|
|
9
9
|
var construtos_1 = require("../construtos");
|
|
10
10
|
var erro_avaliador_sintatico_1 = require("./erro-avaliador-sintatico");
|
|
@@ -25,18 +25,18 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
25
25
|
AvaliadorSintatico.prototype.sincronizar = function () {
|
|
26
26
|
this.avancarEDevolverAnterior();
|
|
27
27
|
while (!this.estaNoFinal()) {
|
|
28
|
-
if (this.simboloAnterior().tipo ===
|
|
28
|
+
if (this.simboloAnterior().tipo === tipos_de_simbolos_1.default.PONTO_E_VIRGULA)
|
|
29
29
|
return;
|
|
30
30
|
switch (this.simboloAtual().tipo) {
|
|
31
|
-
case
|
|
32
|
-
case
|
|
33
|
-
case
|
|
34
|
-
case
|
|
35
|
-
case
|
|
36
|
-
case
|
|
37
|
-
case
|
|
38
|
-
case
|
|
39
|
-
case
|
|
31
|
+
case tipos_de_simbolos_1.default.CLASSE:
|
|
32
|
+
case tipos_de_simbolos_1.default.FUNCAO:
|
|
33
|
+
case tipos_de_simbolos_1.default.FUNÇÃO:
|
|
34
|
+
case tipos_de_simbolos_1.default.VARIAVEL:
|
|
35
|
+
case tipos_de_simbolos_1.default.PARA:
|
|
36
|
+
case tipos_de_simbolos_1.default.SE:
|
|
37
|
+
case tipos_de_simbolos_1.default.ENQUANTO:
|
|
38
|
+
case tipos_de_simbolos_1.default.ESCREVA:
|
|
39
|
+
case tipos_de_simbolos_1.default.RETORNA:
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
this.avancarEDevolverAnterior();
|
|
@@ -74,7 +74,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
74
74
|
AvaliadorSintatico.prototype.estaNoFinal = function () {
|
|
75
75
|
var simboloAtual = this.simboloAtual();
|
|
76
76
|
if (simboloAtual &&
|
|
77
|
-
simboloAtual.tipo ===
|
|
77
|
+
simboloAtual.tipo === tipos_de_simbolos_1.default.PONTO_E_VIRGULA) {
|
|
78
78
|
return true;
|
|
79
79
|
}
|
|
80
80
|
return this.atual === this.simbolos.length;
|
|
@@ -99,99 +99,99 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
99
99
|
return false;
|
|
100
100
|
};
|
|
101
101
|
AvaliadorSintatico.prototype.primario = function () {
|
|
102
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
102
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.SUPER)) {
|
|
103
103
|
var palavraChave = this.simboloAnterior();
|
|
104
|
-
this.consumir(
|
|
105
|
-
var metodo = this.consumir(
|
|
104
|
+
this.consumir(tipos_de_simbolos_1.default.PONTO, "Esperado '.' após 'super'.");
|
|
105
|
+
var metodo = this.consumir(tipos_de_simbolos_1.default.IDENTIFICADOR, 'Esperado nome do método da SuperClasse.');
|
|
106
106
|
return new construtos_1.Super(0, palavraChave, metodo);
|
|
107
107
|
}
|
|
108
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
108
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.COLCHETE_ESQUERDO)) {
|
|
109
109
|
var valores = [];
|
|
110
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
110
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.COLCHETE_DIREITO)) {
|
|
111
111
|
return new construtos_1.Vetor(0, []);
|
|
112
112
|
}
|
|
113
|
-
while (!this.verificarSeSimboloAtualEIgualA(
|
|
113
|
+
while (!this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.COLCHETE_DIREITO)) {
|
|
114
114
|
var valor = this.atribuir();
|
|
115
115
|
valores.push(valor);
|
|
116
116
|
if (this.simboloAtual().tipo !==
|
|
117
|
-
|
|
118
|
-
this.consumir(
|
|
117
|
+
tipos_de_simbolos_1.default.COLCHETE_DIREITO) {
|
|
118
|
+
this.consumir(tipos_de_simbolos_1.default.VIRGULA, 'Esperado vírgula antes da próxima expressão.');
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
return new construtos_1.Vetor(0, valores);
|
|
122
122
|
}
|
|
123
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
123
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.CHAVE_ESQUERDA)) {
|
|
124
124
|
var chaves = [];
|
|
125
125
|
var valores = [];
|
|
126
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
126
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.CHAVE_DIREITA)) {
|
|
127
127
|
return new construtos_1.Dicionario(0, [], []);
|
|
128
128
|
}
|
|
129
|
-
while (!this.verificarSeSimboloAtualEIgualA(
|
|
129
|
+
while (!this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.CHAVE_DIREITA)) {
|
|
130
130
|
var chave = this.atribuir();
|
|
131
|
-
this.consumir(
|
|
131
|
+
this.consumir(tipos_de_simbolos_1.default.DOIS_PONTOS, "Esperado ':' entre chave e valor.");
|
|
132
132
|
var valor = this.atribuir();
|
|
133
133
|
chaves.push(chave);
|
|
134
134
|
valores.push(valor);
|
|
135
|
-
if (this.simboloAtual().tipo !==
|
|
136
|
-
this.consumir(
|
|
135
|
+
if (this.simboloAtual().tipo !== tipos_de_simbolos_1.default.CHAVE_DIREITA) {
|
|
136
|
+
this.consumir(tipos_de_simbolos_1.default.VIRGULA, 'Esperado vírgula antes da próxima expressão.');
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
return new construtos_1.Dicionario(0, chaves, valores);
|
|
140
140
|
}
|
|
141
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
141
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.FUNÇÃO))
|
|
142
142
|
return this.corpoDaFuncao('função');
|
|
143
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
143
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.FUNCAO))
|
|
144
144
|
return this.corpoDaFuncao('funcao');
|
|
145
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
145
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.FALSO))
|
|
146
146
|
return new construtos_1.Literal(0, false);
|
|
147
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
147
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.VERDADEIRO))
|
|
148
148
|
return new construtos_1.Literal(0, true);
|
|
149
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
149
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.NULO))
|
|
150
150
|
return new construtos_1.Literal(0, null);
|
|
151
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
151
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.ISTO))
|
|
152
152
|
return new construtos_1.Isto(0, this.simboloAnterior());
|
|
153
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
153
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.NUMERO, tipos_de_simbolos_1.default.TEXTO)) {
|
|
154
154
|
var simboloAnterior = this.simboloAnterior();
|
|
155
155
|
return new construtos_1.Literal(Number(simboloAnterior.linha), simboloAnterior.literal);
|
|
156
156
|
}
|
|
157
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
157
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.IDENTIFICADOR)) {
|
|
158
158
|
return new construtos_1.Variavel(this.simboloAnterior());
|
|
159
159
|
}
|
|
160
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
160
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO)) {
|
|
161
161
|
var expr = this.expressao();
|
|
162
|
-
this.consumir(
|
|
162
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após a expressão.");
|
|
163
163
|
return new construtos_1.Agrupamento(0, expr);
|
|
164
164
|
}
|
|
165
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
165
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.IMPORTAR))
|
|
166
166
|
return this.declaracaoImportar();
|
|
167
167
|
throw this.erro(this.simboloAtual(), 'Esperado expressão.');
|
|
168
168
|
};
|
|
169
169
|
AvaliadorSintatico.prototype.finalizarChamada = function (entidadeChamada) {
|
|
170
170
|
var argumentos = [];
|
|
171
|
-
if (!this.verificarTipoSimboloAtual(
|
|
171
|
+
if (!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.PARENTESE_DIREITO)) {
|
|
172
172
|
do {
|
|
173
173
|
if (argumentos.length >= 255) {
|
|
174
174
|
throw this.erro(this.simboloAtual(), 'Não pode haver mais de 255 argumentos.');
|
|
175
175
|
}
|
|
176
176
|
argumentos.push(this.expressao());
|
|
177
|
-
} while (this.verificarSeSimboloAtualEIgualA(
|
|
177
|
+
} while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.VIRGULA));
|
|
178
178
|
}
|
|
179
|
-
var parenteseDireito = this.consumir(
|
|
179
|
+
var parenteseDireito = this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após os argumentos.");
|
|
180
180
|
return new construtos_1.Chamada(entidadeChamada, parenteseDireito, argumentos);
|
|
181
181
|
};
|
|
182
182
|
AvaliadorSintatico.prototype.chamar = function () {
|
|
183
183
|
var expressao = this.primario();
|
|
184
184
|
while (true) {
|
|
185
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
185
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO)) {
|
|
186
186
|
expressao = this.finalizarChamada(expressao);
|
|
187
187
|
}
|
|
188
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
189
|
-
var nome = this.consumir(
|
|
188
|
+
else if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.PONTO)) {
|
|
189
|
+
var nome = this.consumir(tipos_de_simbolos_1.default.IDENTIFICADOR, "Esperado nome do método após '.'.");
|
|
190
190
|
expressao = new construtos_1.AcessoMetodo(expressao, nome);
|
|
191
191
|
}
|
|
192
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
192
|
+
else if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.COLCHETE_ESQUERDO)) {
|
|
193
193
|
var indice = this.expressao();
|
|
194
|
-
var simboloFechamento = this.consumir(
|
|
194
|
+
var simboloFechamento = this.consumir(tipos_de_simbolos_1.default.COLCHETE_DIREITO, "Esperado ']' após escrita do indice.");
|
|
195
195
|
expressao = new construtos_1.AcessoIndiceVariavel(expressao, indice, simboloFechamento);
|
|
196
196
|
}
|
|
197
197
|
else {
|
|
@@ -201,7 +201,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
201
201
|
return expressao;
|
|
202
202
|
};
|
|
203
203
|
AvaliadorSintatico.prototype.unario = function () {
|
|
204
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
204
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.NEGACAO, tipos_de_simbolos_1.default.SUBTRACAO, tipos_de_simbolos_1.default.BIT_NOT)) {
|
|
205
205
|
var operador = this.simboloAnterior();
|
|
206
206
|
var direito = this.unario();
|
|
207
207
|
return new construtos_1.Unario(operador, direito);
|
|
@@ -210,7 +210,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
210
210
|
};
|
|
211
211
|
AvaliadorSintatico.prototype.exponenciacao = function () {
|
|
212
212
|
var expressao = this.unario();
|
|
213
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
213
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.EXPONENCIACAO)) {
|
|
214
214
|
var operador = this.simboloAnterior();
|
|
215
215
|
var direito = this.unario();
|
|
216
216
|
expressao = new construtos_1.Binario(expressao, operador, direito);
|
|
@@ -219,7 +219,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
219
219
|
};
|
|
220
220
|
AvaliadorSintatico.prototype.multiplicar = function () {
|
|
221
221
|
var expressao = this.exponenciacao();
|
|
222
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
222
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.DIVISAO, tipos_de_simbolos_1.default.MULTIPLICACAO, tipos_de_simbolos_1.default.MODULO)) {
|
|
223
223
|
var operador = this.simboloAnterior();
|
|
224
224
|
var direito = this.exponenciacao();
|
|
225
225
|
expressao = new construtos_1.Binario(expressao, operador, direito);
|
|
@@ -228,7 +228,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
228
228
|
};
|
|
229
229
|
AvaliadorSintatico.prototype.adicionar = function () {
|
|
230
230
|
var expressao = this.multiplicar();
|
|
231
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
231
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.SUBTRACAO, tipos_de_simbolos_1.default.ADICAO)) {
|
|
232
232
|
var operador = this.simboloAnterior();
|
|
233
233
|
var direito = this.multiplicar();
|
|
234
234
|
expressao = new construtos_1.Binario(expressao, operador, direito);
|
|
@@ -237,7 +237,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
237
237
|
};
|
|
238
238
|
AvaliadorSintatico.prototype.bitFill = function () {
|
|
239
239
|
var expressao = this.adicionar();
|
|
240
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
240
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.MENOR_MENOR, tipos_de_simbolos_1.default.MAIOR_MAIOR)) {
|
|
241
241
|
var operador = this.simboloAnterior();
|
|
242
242
|
var direito = this.adicionar();
|
|
243
243
|
expressao = new construtos_1.Binario(expressao, operador, direito);
|
|
@@ -246,7 +246,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
246
246
|
};
|
|
247
247
|
AvaliadorSintatico.prototype.bitE = function () {
|
|
248
248
|
var expressao = this.bitFill();
|
|
249
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
249
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.BIT_AND)) {
|
|
250
250
|
var operador = this.simboloAnterior();
|
|
251
251
|
var direito = this.bitFill();
|
|
252
252
|
expressao = new construtos_1.Binario(expressao, operador, direito);
|
|
@@ -255,7 +255,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
255
255
|
};
|
|
256
256
|
AvaliadorSintatico.prototype.bitOu = function () {
|
|
257
257
|
var expressao = this.bitE();
|
|
258
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
258
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.BIT_OR, tipos_de_simbolos_1.default.BIT_XOR)) {
|
|
259
259
|
var operador = this.simboloAnterior();
|
|
260
260
|
var direito = this.bitE();
|
|
261
261
|
expressao = new construtos_1.Binario(expressao, operador, direito);
|
|
@@ -264,7 +264,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
264
264
|
};
|
|
265
265
|
AvaliadorSintatico.prototype.comparar = function () {
|
|
266
266
|
var expressao = this.bitOu();
|
|
267
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
267
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.MAIOR, tipos_de_simbolos_1.default.MAIOR_IGUAL, tipos_de_simbolos_1.default.MENOR, tipos_de_simbolos_1.default.MENOR_IGUAL)) {
|
|
268
268
|
var operador = this.simboloAnterior();
|
|
269
269
|
var direito = this.bitOu();
|
|
270
270
|
expressao = new construtos_1.Binario(expressao, operador, direito);
|
|
@@ -273,7 +273,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
273
273
|
};
|
|
274
274
|
AvaliadorSintatico.prototype.comparacaoIgualdade = function () {
|
|
275
275
|
var expressao = this.comparar();
|
|
276
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
276
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.DIFERENTE, tipos_de_simbolos_1.default.IGUAL_IGUAL)) {
|
|
277
277
|
var operador = this.simboloAnterior();
|
|
278
278
|
var direito = this.comparar();
|
|
279
279
|
expressao = new construtos_1.Binario(expressao, operador, direito);
|
|
@@ -282,7 +282,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
282
282
|
};
|
|
283
283
|
AvaliadorSintatico.prototype.em = function () {
|
|
284
284
|
var expressao = this.comparacaoIgualdade();
|
|
285
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
285
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.EM)) {
|
|
286
286
|
var operador = this.simboloAnterior();
|
|
287
287
|
var direito = this.comparacaoIgualdade();
|
|
288
288
|
expressao = new construtos_1.Logico(expressao, operador, direito);
|
|
@@ -291,7 +291,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
291
291
|
};
|
|
292
292
|
AvaliadorSintatico.prototype.e = function () {
|
|
293
293
|
var expressao = this.em();
|
|
294
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
294
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.E)) {
|
|
295
295
|
var operador = this.simboloAnterior();
|
|
296
296
|
var direito = this.em();
|
|
297
297
|
expressao = new construtos_1.Logico(expressao, operador, direito);
|
|
@@ -300,7 +300,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
300
300
|
};
|
|
301
301
|
AvaliadorSintatico.prototype.ou = function () {
|
|
302
302
|
var expressao = this.e();
|
|
303
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
303
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.OU)) {
|
|
304
304
|
var operador = this.simboloAnterior();
|
|
305
305
|
var direito = this.e();
|
|
306
306
|
expressao = new construtos_1.Logico(expressao, operador, direito);
|
|
@@ -309,8 +309,8 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
309
309
|
};
|
|
310
310
|
AvaliadorSintatico.prototype.atribuir = function () {
|
|
311
311
|
var expressao = this.ou();
|
|
312
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
313
|
-
this.verificarSeSimboloAtualEIgualA(
|
|
312
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.IGUAL) ||
|
|
313
|
+
this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.MAIS_IGUAL)) {
|
|
314
314
|
var igual = this.simboloAnterior();
|
|
315
315
|
var valor = this.atribuir();
|
|
316
316
|
if (expressao instanceof construtos_1.Variavel) {
|
|
@@ -332,9 +332,9 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
332
332
|
return this.atribuir();
|
|
333
333
|
};
|
|
334
334
|
AvaliadorSintatico.prototype.declaracaoEscreva = function () {
|
|
335
|
-
this.consumir(
|
|
335
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' antes dos valores em escreva.");
|
|
336
336
|
var simbolo = this.expressao();
|
|
337
|
-
this.consumir(
|
|
337
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após os valores em escreva.");
|
|
338
338
|
return new declaracoes_1.Escreva(simbolo);
|
|
339
339
|
};
|
|
340
340
|
AvaliadorSintatico.prototype.declaracaoExpressao = function () {
|
|
@@ -343,24 +343,24 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
343
343
|
};
|
|
344
344
|
AvaliadorSintatico.prototype.blocoEscopo = function () {
|
|
345
345
|
var declaracoes = [];
|
|
346
|
-
while (!this.verificarTipoSimboloAtual(
|
|
346
|
+
while (!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.CHAVE_DIREITA) &&
|
|
347
347
|
!this.estaNoFinal()) {
|
|
348
348
|
declaracoes.push(this.declaracao());
|
|
349
349
|
}
|
|
350
|
-
this.consumir(
|
|
350
|
+
this.consumir(tipos_de_simbolos_1.default.CHAVE_DIREITA, "Esperado '}' após o bloco.");
|
|
351
351
|
return declaracoes;
|
|
352
352
|
};
|
|
353
353
|
AvaliadorSintatico.prototype.declaracaoSe = function () {
|
|
354
354
|
var simboloSe = this.simboloAnterior();
|
|
355
|
-
this.consumir(
|
|
355
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'se'.");
|
|
356
356
|
var condicao = this.expressao();
|
|
357
|
-
this.consumir(
|
|
357
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após condição do se.");
|
|
358
358
|
var caminhoEntao = this.resolverDeclaracao();
|
|
359
359
|
var caminhosSeSenao = [];
|
|
360
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
361
|
-
this.consumir(
|
|
360
|
+
while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.SENAOSE, tipos_de_simbolos_1.default.SENÃOSE)) {
|
|
361
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'senaose' ou 'senãose'.");
|
|
362
362
|
var condicaoSeSenao = this.expressao();
|
|
363
|
-
this.consumir(
|
|
363
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após codição do 'senaose' ou 'senãose'.");
|
|
364
364
|
var caminho = this.resolverDeclaracao();
|
|
365
365
|
caminhosSeSenao.push({
|
|
366
366
|
condicao: condicaoSeSenao,
|
|
@@ -368,7 +368,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
368
368
|
});
|
|
369
369
|
}
|
|
370
370
|
var caminhoSenao = null;
|
|
371
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
371
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.SENAO, tipos_de_simbolos_1.default.SENÃO)) {
|
|
372
372
|
caminhoSenao = this.resolverDeclaracao();
|
|
373
373
|
}
|
|
374
374
|
return new declaracoes_1.Se(Number(simboloSe.linha), condicao, caminhoEntao, caminhosSeSenao, caminhoSenao);
|
|
@@ -376,9 +376,9 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
376
376
|
AvaliadorSintatico.prototype.declaracaoEnquanto = function () {
|
|
377
377
|
try {
|
|
378
378
|
this.ciclos += 1;
|
|
379
|
-
this.consumir(
|
|
379
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'enquanto'.");
|
|
380
380
|
var condicao = this.expressao();
|
|
381
|
-
this.consumir(
|
|
381
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após condicional.");
|
|
382
382
|
var corpo = this.resolverDeclaracao();
|
|
383
383
|
return new declaracoes_1.Enquanto(condicao, corpo);
|
|
384
384
|
}
|
|
@@ -390,26 +390,26 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
390
390
|
try {
|
|
391
391
|
var simboloPara = this.simboloAnterior();
|
|
392
392
|
this.ciclos += 1;
|
|
393
|
-
this.consumir(
|
|
393
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'para'.");
|
|
394
394
|
var inicializador = void 0;
|
|
395
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
395
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.PONTO_E_VIRGULA)) {
|
|
396
396
|
inicializador = null;
|
|
397
397
|
}
|
|
398
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
398
|
+
else if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.VARIAVEL)) {
|
|
399
399
|
inicializador = this.declaracaoDeVariavel();
|
|
400
400
|
}
|
|
401
401
|
else {
|
|
402
402
|
inicializador = this.declaracaoExpressao();
|
|
403
403
|
}
|
|
404
404
|
var condicao = null;
|
|
405
|
-
if (!this.verificarTipoSimboloAtual(
|
|
405
|
+
if (!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.PONTO_E_VIRGULA)) {
|
|
406
406
|
condicao = this.expressao();
|
|
407
407
|
}
|
|
408
408
|
var incrementar = null;
|
|
409
|
-
if (!this.verificarTipoSimboloAtual(
|
|
409
|
+
if (!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.PARENTESE_DIREITO)) {
|
|
410
410
|
incrementar = this.expressao();
|
|
411
411
|
}
|
|
412
|
-
this.consumir(
|
|
412
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após cláusulas");
|
|
413
413
|
var corpo = this.resolverDeclaracao();
|
|
414
414
|
return new declaracoes_1.Para(Number(simboloPara.linha), inicializador, condicao, incrementar, corpo);
|
|
415
415
|
}
|
|
@@ -432,7 +432,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
432
432
|
AvaliadorSintatico.prototype.declaracaoRetorna = function () {
|
|
433
433
|
var palavraChave = this.simboloAnterior();
|
|
434
434
|
var valor = null;
|
|
435
|
-
if (!this.verificarTipoSimboloAtual(
|
|
435
|
+
if (!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.PONTO_E_VIRGULA)) {
|
|
436
436
|
valor = this.expressao();
|
|
437
437
|
}
|
|
438
438
|
return new declaracoes_1.Retorna(palavraChave, valor);
|
|
@@ -440,46 +440,46 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
440
440
|
AvaliadorSintatico.prototype.declaracaoEscolha = function () {
|
|
441
441
|
try {
|
|
442
442
|
this.ciclos += 1;
|
|
443
|
-
this.consumir(
|
|
443
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO, "Esperado '{' após 'escolha'.");
|
|
444
444
|
var condicao = this.expressao();
|
|
445
|
-
this.consumir(
|
|
446
|
-
this.consumir(
|
|
445
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado '}' após a condição de 'escolha'.");
|
|
446
|
+
this.consumir(tipos_de_simbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo do 'escolha'.");
|
|
447
447
|
var caminhos = [];
|
|
448
448
|
var caminhoPadrao = null;
|
|
449
|
-
while (!this.verificarSeSimboloAtualEIgualA(
|
|
449
|
+
while (!this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.CHAVE_DIREITA) &&
|
|
450
450
|
!this.estaNoFinal()) {
|
|
451
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
451
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.CASO)) {
|
|
452
452
|
var branchConditions = [this.expressao()];
|
|
453
|
-
this.consumir(
|
|
454
|
-
while (this.verificarTipoSimboloAtual(
|
|
455
|
-
this.consumir(
|
|
453
|
+
this.consumir(tipos_de_simbolos_1.default.DOIS_PONTOS, "Esperado ':' após o 'caso'.");
|
|
454
|
+
while (this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.CASO)) {
|
|
455
|
+
this.consumir(tipos_de_simbolos_1.default.CASO, null);
|
|
456
456
|
branchConditions.push(this.expressao());
|
|
457
|
-
this.consumir(
|
|
457
|
+
this.consumir(tipos_de_simbolos_1.default.DOIS_PONTOS, "Esperado ':' após declaração do 'caso'.");
|
|
458
458
|
}
|
|
459
459
|
var declaracoes = [];
|
|
460
460
|
do {
|
|
461
461
|
declaracoes.push(this.resolverDeclaracao());
|
|
462
|
-
} while (!this.verificarTipoSimboloAtual(
|
|
463
|
-
!this.verificarTipoSimboloAtual(
|
|
464
|
-
!this.verificarTipoSimboloAtual(
|
|
462
|
+
} while (!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.CASO) &&
|
|
463
|
+
!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.PADRAO) &&
|
|
464
|
+
!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.CHAVE_DIREITA));
|
|
465
465
|
caminhos.push({
|
|
466
466
|
conditions: branchConditions,
|
|
467
467
|
declaracoes: declaracoes,
|
|
468
468
|
});
|
|
469
469
|
}
|
|
470
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
470
|
+
else if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.PADRAO)) {
|
|
471
471
|
if (caminhoPadrao !== null) {
|
|
472
472
|
var excecao = new erro_avaliador_sintatico_1.ErroAvaliadorSintatico(this.simboloAtual(), "Você só pode ter um 'padrao' em cada declaração de 'escolha'.");
|
|
473
473
|
this.erros.push(excecao);
|
|
474
474
|
throw excecao;
|
|
475
475
|
}
|
|
476
|
-
this.consumir(
|
|
476
|
+
this.consumir(tipos_de_simbolos_1.default.DOIS_PONTOS, "Esperado ':' após declaração do 'padrao'.");
|
|
477
477
|
var declaracoes = [];
|
|
478
478
|
do {
|
|
479
479
|
declaracoes.push(this.resolverDeclaracao());
|
|
480
|
-
} while (!this.verificarTipoSimboloAtual(
|
|
481
|
-
!this.verificarTipoSimboloAtual(
|
|
482
|
-
!this.verificarTipoSimboloAtual(
|
|
480
|
+
} while (!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.CASO) &&
|
|
481
|
+
!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.PADRAO) &&
|
|
482
|
+
!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.CHAVE_DIREITA));
|
|
483
483
|
caminhoPadrao = {
|
|
484
484
|
declaracoes: declaracoes,
|
|
485
485
|
};
|
|
@@ -492,27 +492,27 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
492
492
|
}
|
|
493
493
|
};
|
|
494
494
|
AvaliadorSintatico.prototype.declaracaoImportar = function () {
|
|
495
|
-
this.consumir(
|
|
495
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração.");
|
|
496
496
|
var caminho = this.expressao();
|
|
497
|
-
var simboloFechamento = this.consumir(
|
|
497
|
+
var simboloFechamento = this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após declaração.");
|
|
498
498
|
return new declaracoes_1.Importar(caminho, simboloFechamento);
|
|
499
499
|
};
|
|
500
500
|
AvaliadorSintatico.prototype.declaracaoTente = function () {
|
|
501
|
-
this.consumir(
|
|
501
|
+
this.consumir(tipos_de_simbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'tente'.");
|
|
502
502
|
var blocoTente = this.blocoEscopo();
|
|
503
503
|
var blocoPegue = null;
|
|
504
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
505
|
-
this.consumir(
|
|
504
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.PEGUE)) {
|
|
505
|
+
this.consumir(tipos_de_simbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
|
|
506
506
|
blocoPegue = this.blocoEscopo();
|
|
507
507
|
}
|
|
508
508
|
var blocoSenao = null;
|
|
509
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
510
|
-
this.consumir(
|
|
509
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.SENAO, tipos_de_simbolos_1.default.SENÃO)) {
|
|
510
|
+
this.consumir(tipos_de_simbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
|
|
511
511
|
blocoSenao = this.blocoEscopo();
|
|
512
512
|
}
|
|
513
513
|
var blocoFinalmente = null;
|
|
514
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
515
|
-
this.consumir(
|
|
514
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.FINALMENTE)) {
|
|
515
|
+
this.consumir(tipos_de_simbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
|
|
516
516
|
blocoFinalmente = this.blocoEscopo();
|
|
517
517
|
}
|
|
518
518
|
return new declaracoes_1.Tente(blocoTente, blocoPegue, blocoSenao, blocoFinalmente);
|
|
@@ -521,10 +521,10 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
521
521
|
try {
|
|
522
522
|
this.ciclos += 1;
|
|
523
523
|
var caminhoFazer = this.resolverDeclaracao();
|
|
524
|
-
this.consumir(
|
|
525
|
-
this.consumir(
|
|
524
|
+
this.consumir(tipos_de_simbolos_1.default.ENQUANTO, "Esperado declaração do 'enquanto' após o escopo do 'fazer'.");
|
|
525
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração 'enquanto'.");
|
|
526
526
|
var condicaoEnquanto = this.expressao();
|
|
527
|
-
this.consumir(
|
|
527
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após declaração do 'enquanto'.");
|
|
528
528
|
return new declaracoes_1.Fazer(caminhoFazer, condicaoEnquanto);
|
|
529
529
|
}
|
|
530
530
|
finally {
|
|
@@ -532,104 +532,104 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
532
532
|
}
|
|
533
533
|
};
|
|
534
534
|
AvaliadorSintatico.prototype.resolverDeclaracao = function () {
|
|
535
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
535
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.FAZER))
|
|
536
536
|
return this.declaracaoFazer();
|
|
537
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
537
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.TENTE))
|
|
538
538
|
return this.declaracaoTente();
|
|
539
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
539
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.ESCOLHA))
|
|
540
540
|
return this.declaracaoEscolha();
|
|
541
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
541
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.RETORNA))
|
|
542
542
|
return this.declaracaoRetorna();
|
|
543
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
543
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.CONTINUA))
|
|
544
544
|
return this.declaracaoContinua();
|
|
545
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
545
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.PAUSA))
|
|
546
546
|
return this.declaracaoSustar();
|
|
547
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
547
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.PARA))
|
|
548
548
|
return this.declaracaoPara();
|
|
549
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
549
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.ENQUANTO))
|
|
550
550
|
return this.declaracaoEnquanto();
|
|
551
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
551
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.SE))
|
|
552
552
|
return this.declaracaoSe();
|
|
553
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
553
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.ESCREVA))
|
|
554
554
|
return this.declaracaoEscreva();
|
|
555
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
555
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.CHAVE_ESQUERDA))
|
|
556
556
|
return new declaracoes_1.Bloco(this.blocoEscopo());
|
|
557
557
|
return this.declaracaoExpressao();
|
|
558
558
|
};
|
|
559
559
|
AvaliadorSintatico.prototype.declaracaoDeVariavel = function () {
|
|
560
|
-
var simbolo = this.consumir(
|
|
560
|
+
var simbolo = this.consumir(tipos_de_simbolos_1.default.IDENTIFICADOR, 'Esperado nome de variável.');
|
|
561
561
|
var inicializador = null;
|
|
562
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
563
|
-
this.verificarSeSimboloAtualEIgualA(
|
|
562
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.IGUAL) ||
|
|
563
|
+
this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.MAIS_IGUAL)) {
|
|
564
564
|
inicializador = this.expressao();
|
|
565
565
|
}
|
|
566
566
|
return new declaracoes_1.Var(simbolo, inicializador);
|
|
567
567
|
};
|
|
568
568
|
AvaliadorSintatico.prototype.funcao = function (tipo) {
|
|
569
|
-
var simbolo = this.consumir(
|
|
569
|
+
var simbolo = this.consumir(tipos_de_simbolos_1.default.IDENTIFICADOR, "Esperado nome ".concat(tipo, "."));
|
|
570
570
|
return new declaracoes_1.Funcao(simbolo, this.corpoDaFuncao(tipo));
|
|
571
571
|
};
|
|
572
572
|
AvaliadorSintatico.prototype.corpoDaFuncao = function (tipo) {
|
|
573
|
-
this.consumir(
|
|
573
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' ap\u00F3s o nome ".concat(tipo, "."));
|
|
574
574
|
var parametros = [];
|
|
575
|
-
if (!this.verificarTipoSimboloAtual(
|
|
575
|
+
if (!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.PARENTESE_DIREITO)) {
|
|
576
576
|
do {
|
|
577
577
|
if (parametros.length >= 255) {
|
|
578
578
|
this.erro(this.simboloAtual(), 'Não pode haver mais de 255 parâmetros');
|
|
579
579
|
}
|
|
580
580
|
var paramObj = {};
|
|
581
|
-
if (this.simboloAtual().tipo ===
|
|
582
|
-
this.consumir(
|
|
581
|
+
if (this.simboloAtual().tipo === tipos_de_simbolos_1.default.MULTIPLICACAO) {
|
|
582
|
+
this.consumir(tipos_de_simbolos_1.default.MULTIPLICACAO, null);
|
|
583
583
|
paramObj['tipo'] = 'wildcard';
|
|
584
584
|
}
|
|
585
585
|
else {
|
|
586
586
|
paramObj['tipo'] = 'standard';
|
|
587
587
|
}
|
|
588
|
-
paramObj['nome'] = this.consumir(
|
|
589
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
588
|
+
paramObj['nome'] = this.consumir(tipos_de_simbolos_1.default.IDENTIFICADOR, 'Esperado nome do parâmetro.');
|
|
589
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.IGUAL)) {
|
|
590
590
|
paramObj['default'] = this.primario();
|
|
591
591
|
}
|
|
592
592
|
parametros.push(paramObj);
|
|
593
593
|
if (paramObj['tipo'] === 'wildcard')
|
|
594
594
|
break;
|
|
595
|
-
} while (this.verificarSeSimboloAtualEIgualA(
|
|
595
|
+
} while (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.VIRGULA));
|
|
596
596
|
}
|
|
597
|
-
this.consumir(
|
|
598
|
-
this.consumir(
|
|
597
|
+
this.consumir(tipos_de_simbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após parâmetros.");
|
|
598
|
+
this.consumir(tipos_de_simbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo do ".concat(tipo, "."));
|
|
599
599
|
var corpo = this.blocoEscopo();
|
|
600
600
|
return new construtos_1.Funcao(0, parametros, corpo);
|
|
601
601
|
};
|
|
602
602
|
AvaliadorSintatico.prototype.declaracaoDeClasse = function () {
|
|
603
|
-
var simbolo = this.consumir(
|
|
603
|
+
var simbolo = this.consumir(tipos_de_simbolos_1.default.IDENTIFICADOR, 'Esperado nome da classe.');
|
|
604
604
|
var superClasse = null;
|
|
605
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
606
|
-
this.consumir(
|
|
605
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.HERDA)) {
|
|
606
|
+
this.consumir(tipos_de_simbolos_1.default.IDENTIFICADOR, 'Esperado nome da SuperClasse.');
|
|
607
607
|
superClasse = new construtos_1.Variavel(this.simboloAnterior());
|
|
608
608
|
}
|
|
609
|
-
this.consumir(
|
|
609
|
+
this.consumir(tipos_de_simbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo da classe.");
|
|
610
610
|
var metodos = [];
|
|
611
|
-
while (!this.verificarTipoSimboloAtual(
|
|
611
|
+
while (!this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.CHAVE_DIREITA) &&
|
|
612
612
|
!this.estaNoFinal()) {
|
|
613
613
|
metodos.push(this.funcao('método'));
|
|
614
614
|
}
|
|
615
|
-
this.consumir(
|
|
615
|
+
this.consumir(tipos_de_simbolos_1.default.CHAVE_DIREITA, "Esperado '}' após o escopo da classe.");
|
|
616
616
|
return new declaracoes_1.Classe(simbolo, superClasse, metodos);
|
|
617
617
|
};
|
|
618
618
|
AvaliadorSintatico.prototype.declaracao = function () {
|
|
619
619
|
try {
|
|
620
|
-
if (this.verificarTipoSimboloAtual(
|
|
621
|
-
this.verificarTipoProximoSimbolo(
|
|
622
|
-
this.consumir(
|
|
620
|
+
if (this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.FUNÇÃO) &&
|
|
621
|
+
this.verificarTipoProximoSimbolo(tipos_de_simbolos_1.default.IDENTIFICADOR)) {
|
|
622
|
+
this.consumir(tipos_de_simbolos_1.default.FUNÇÃO, null);
|
|
623
623
|
return this.funcao('função');
|
|
624
624
|
}
|
|
625
|
-
if (this.verificarTipoSimboloAtual(
|
|
626
|
-
this.verificarTipoProximoSimbolo(
|
|
627
|
-
this.consumir(
|
|
625
|
+
if (this.verificarTipoSimboloAtual(tipos_de_simbolos_1.default.FUNCAO) &&
|
|
626
|
+
this.verificarTipoProximoSimbolo(tipos_de_simbolos_1.default.IDENTIFICADOR)) {
|
|
627
|
+
this.consumir(tipos_de_simbolos_1.default.FUNCAO, null);
|
|
628
628
|
return this.funcao('funcao');
|
|
629
629
|
}
|
|
630
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
630
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.VARIAVEL))
|
|
631
631
|
return this.declaracaoDeVariavel();
|
|
632
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
632
|
+
if (this.verificarSeSimboloAtualEIgualA(tipos_de_simbolos_1.default.CLASSE))
|
|
633
633
|
return this.declaracaoDeClasse();
|
|
634
634
|
return this.resolverDeclaracao();
|
|
635
635
|
}
|
|
@@ -643,9 +643,7 @@ var AvaliadorSintatico = /** @class */ (function () {
|
|
|
643
643
|
this.erros = [];
|
|
644
644
|
this.atual = 0;
|
|
645
645
|
this.ciclos = 0;
|
|
646
|
-
|
|
647
|
-
this.simbolos = simbolos;
|
|
648
|
-
}
|
|
646
|
+
this.simbolos = simbolos || [];
|
|
649
647
|
var declaracoes = [];
|
|
650
648
|
while (!this.estaNoFinal()) {
|
|
651
649
|
declaracoes.push(this.declaracao());
|