@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
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AvaliadorSintaticoEguaClassico = void 0;
|
|
7
|
-
var
|
|
7
|
+
var delegua_1 = __importDefault(require("../../tipos-de-simbolos/delegua"));
|
|
8
8
|
var construtos_1 = require("../../construtos");
|
|
9
9
|
var erro_avaliador_sintatico_1 = require("../erro-avaliador-sintatico");
|
|
10
10
|
var declaracoes_1 = require("../../declaracoes");
|
|
@@ -21,17 +21,17 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
21
21
|
AvaliadorSintaticoEguaClassico.prototype.sincronizar = function () {
|
|
22
22
|
this.avancarEDevolverAnterior();
|
|
23
23
|
while (!this.estaNoFinal()) {
|
|
24
|
-
if (this.simboloAnterior().tipo ===
|
|
24
|
+
if (this.simboloAnterior().tipo === delegua_1.default.PONTO_E_VIRGULA)
|
|
25
25
|
return;
|
|
26
26
|
switch (this.simboloAtual().tipo) {
|
|
27
|
-
case
|
|
28
|
-
case
|
|
29
|
-
case
|
|
30
|
-
case
|
|
31
|
-
case
|
|
32
|
-
case
|
|
33
|
-
case
|
|
34
|
-
case
|
|
27
|
+
case delegua_1.default.CLASSE:
|
|
28
|
+
case delegua_1.default.FUNÇÃO:
|
|
29
|
+
case delegua_1.default.VARIAVEL:
|
|
30
|
+
case delegua_1.default.PARA:
|
|
31
|
+
case delegua_1.default.SE:
|
|
32
|
+
case delegua_1.default.ENQUANTO:
|
|
33
|
+
case delegua_1.default.ESCREVA:
|
|
34
|
+
case delegua_1.default.RETORNA:
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
this.avancarEDevolverAnterior();
|
|
@@ -68,7 +68,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
68
68
|
return this.simbolos[this.atual + posicao];
|
|
69
69
|
};
|
|
70
70
|
AvaliadorSintaticoEguaClassico.prototype.estaNoFinal = function () {
|
|
71
|
-
return this.simboloAtual().tipo ===
|
|
71
|
+
return this.simboloAtual().tipo === delegua_1.default.EOF;
|
|
72
72
|
};
|
|
73
73
|
AvaliadorSintaticoEguaClassico.prototype.avancarEDevolverAnterior = function () {
|
|
74
74
|
if (!this.estaNoFinal())
|
|
@@ -90,96 +90,96 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
90
90
|
return false;
|
|
91
91
|
};
|
|
92
92
|
AvaliadorSintaticoEguaClassico.prototype.primario = function () {
|
|
93
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
93
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.SUPER)) {
|
|
94
94
|
var simboloChave = this.simboloAnterior();
|
|
95
|
-
this.consumir(
|
|
96
|
-
var metodo = this.consumir(
|
|
95
|
+
this.consumir(delegua_1.default.PONTO, "Esperado '.' após 'super'.");
|
|
96
|
+
var metodo = this.consumir(delegua_1.default.IDENTIFICADOR, 'Esperado nome do método da SuperClasse.');
|
|
97
97
|
return new construtos_1.Super(this.hashArquivo, simboloChave, metodo);
|
|
98
98
|
}
|
|
99
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
99
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.COLCHETE_ESQUERDO)) {
|
|
100
100
|
var valores = [];
|
|
101
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
101
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.COLCHETE_DIREITO)) {
|
|
102
102
|
return new construtos_1.Vetor(this.hashArquivo, 0, []);
|
|
103
103
|
}
|
|
104
|
-
while (!this.verificarSeSimboloAtualEIgualA(
|
|
104
|
+
while (!this.verificarSeSimboloAtualEIgualA(delegua_1.default.COLCHETE_DIREITO)) {
|
|
105
105
|
var valor = this.atribuir();
|
|
106
106
|
valores.push(valor);
|
|
107
107
|
if (this.simboloAtual().tipo !==
|
|
108
|
-
|
|
109
|
-
this.consumir(
|
|
108
|
+
delegua_1.default.COLCHETE_DIREITO) {
|
|
109
|
+
this.consumir(delegua_1.default.VIRGULA, 'Esperado vírgula antes da próxima expressão.');
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
return new construtos_1.Vetor(this.hashArquivo, 0, valores);
|
|
113
113
|
}
|
|
114
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
114
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.CHAVE_ESQUERDA)) {
|
|
115
115
|
var chaves = [];
|
|
116
116
|
var valores = [];
|
|
117
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
117
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.CHAVE_DIREITA)) {
|
|
118
118
|
return new construtos_1.Dicionario(this.hashArquivo, 0, [], []);
|
|
119
119
|
}
|
|
120
|
-
while (!this.verificarSeSimboloAtualEIgualA(
|
|
120
|
+
while (!this.verificarSeSimboloAtualEIgualA(delegua_1.default.CHAVE_DIREITA)) {
|
|
121
121
|
var chave = this.atribuir();
|
|
122
|
-
this.consumir(
|
|
122
|
+
this.consumir(delegua_1.default.DOIS_PONTOS, "Esperado ':' entre chave e valor.");
|
|
123
123
|
var valor = this.atribuir();
|
|
124
124
|
chaves.push(chave);
|
|
125
125
|
valores.push(valor);
|
|
126
|
-
if (this.simboloAtual().tipo !==
|
|
127
|
-
this.consumir(
|
|
126
|
+
if (this.simboloAtual().tipo !== delegua_1.default.CHAVE_DIREITA) {
|
|
127
|
+
this.consumir(delegua_1.default.VIRGULA, 'Esperado vírgula antes da próxima expressão.');
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
return new construtos_1.Dicionario(this.hashArquivo, 0, chaves, valores);
|
|
131
131
|
}
|
|
132
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
132
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.FUNÇÃO))
|
|
133
133
|
return this.corpoDaFuncao('função');
|
|
134
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
134
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.FALSO))
|
|
135
135
|
return new construtos_1.Literal(this.hashArquivo, 0, false);
|
|
136
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
136
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.VERDADEIRO))
|
|
137
137
|
return new construtos_1.Literal(this.hashArquivo, 0, true);
|
|
138
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
138
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.NULO))
|
|
139
139
|
return new construtos_1.Literal(this.hashArquivo, 0, null);
|
|
140
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
141
|
-
return new construtos_1.Isto(this.hashArquivo, this.simboloAnterior());
|
|
142
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
140
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.ISTO))
|
|
141
|
+
return new construtos_1.Isto(this.hashArquivo, Number(this.simboloAnterior()));
|
|
142
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.NUMERO, delegua_1.default.TEXTO)) {
|
|
143
143
|
return new construtos_1.Literal(this.hashArquivo, 0, this.simboloAnterior().literal);
|
|
144
144
|
}
|
|
145
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
145
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.IDENTIFICADOR)) {
|
|
146
146
|
return new construtos_1.Variavel(this.hashArquivo, this.simboloAnterior());
|
|
147
147
|
}
|
|
148
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
148
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.PARENTESE_ESQUERDO)) {
|
|
149
149
|
var expressao = this.expressao();
|
|
150
|
-
this.consumir(
|
|
150
|
+
this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' após a expressão.");
|
|
151
151
|
return new construtos_1.Agrupamento(this.hashArquivo, 0, expressao);
|
|
152
152
|
}
|
|
153
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
153
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.IMPORTAR))
|
|
154
154
|
return this.declaracaoImportar();
|
|
155
155
|
throw this.erro(this.simboloAtual(), 'Esperado expressão.');
|
|
156
156
|
};
|
|
157
157
|
AvaliadorSintaticoEguaClassico.prototype.finalizarChamada = function (entidadeChamada) {
|
|
158
158
|
var argumentos = [];
|
|
159
|
-
if (!this.verificarTipoSimboloAtual(
|
|
159
|
+
if (!this.verificarTipoSimboloAtual(delegua_1.default.PARENTESE_DIREITO)) {
|
|
160
160
|
do {
|
|
161
161
|
if (argumentos.length >= 255) {
|
|
162
162
|
throw this.erro(this.simboloAtual(), 'Não pode haver mais de 255 argumentos.');
|
|
163
163
|
}
|
|
164
164
|
argumentos.push(this.expressao());
|
|
165
|
-
} while (this.verificarSeSimboloAtualEIgualA(
|
|
165
|
+
} while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.VIRGULA));
|
|
166
166
|
}
|
|
167
|
-
var parenteseDireito = this.consumir(
|
|
167
|
+
var parenteseDireito = this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' após os argumentos.");
|
|
168
168
|
return new construtos_1.Chamada(this.hashArquivo, entidadeChamada, parenteseDireito, argumentos);
|
|
169
169
|
};
|
|
170
170
|
AvaliadorSintaticoEguaClassico.prototype.chamar = function () {
|
|
171
171
|
var expressao = this.primario();
|
|
172
172
|
while (true) {
|
|
173
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
173
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.PARENTESE_ESQUERDO)) {
|
|
174
174
|
expressao = this.finalizarChamada(expressao);
|
|
175
175
|
}
|
|
176
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
177
|
-
var nome = this.consumir(
|
|
176
|
+
else if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.PONTO)) {
|
|
177
|
+
var nome = this.consumir(delegua_1.default.IDENTIFICADOR, "Esperado nome do método após '.'.");
|
|
178
178
|
expressao = new construtos_1.AcessoMetodo(this.hashArquivo, expressao, nome);
|
|
179
179
|
}
|
|
180
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
180
|
+
else if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.COLCHETE_ESQUERDO)) {
|
|
181
181
|
var indice = this.expressao();
|
|
182
|
-
var simboloFechamento = this.consumir(
|
|
182
|
+
var simboloFechamento = this.consumir(delegua_1.default.COLCHETE_DIREITO, "Esperado ']' após escrita do indice.");
|
|
183
183
|
expressao = new construtos_1.AcessoIndiceVariavel(this.hashArquivo, expressao, indice, simboloFechamento);
|
|
184
184
|
}
|
|
185
185
|
else {
|
|
@@ -189,7 +189,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
189
189
|
return expressao;
|
|
190
190
|
};
|
|
191
191
|
AvaliadorSintaticoEguaClassico.prototype.unario = function () {
|
|
192
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
192
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.NEGACAO, delegua_1.default.SUBTRACAO, delegua_1.default.BIT_NOT)) {
|
|
193
193
|
var operador = this.simboloAnterior();
|
|
194
194
|
var direito = this.unario();
|
|
195
195
|
return new construtos_1.Unario(this.hashArquivo, operador, direito);
|
|
@@ -198,7 +198,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
198
198
|
};
|
|
199
199
|
AvaliadorSintaticoEguaClassico.prototype.exponenciacao = function () {
|
|
200
200
|
var expressao = this.unario();
|
|
201
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
201
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.EXPONENCIACAO)) {
|
|
202
202
|
var operador = this.simboloAnterior();
|
|
203
203
|
var direito = this.unario();
|
|
204
204
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -207,7 +207,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
207
207
|
};
|
|
208
208
|
AvaliadorSintaticoEguaClassico.prototype.multiplicar = function () {
|
|
209
209
|
var expressao = this.exponenciacao();
|
|
210
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
210
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.DIVISAO, delegua_1.default.MULTIPLICACAO, delegua_1.default.MODULO)) {
|
|
211
211
|
var operador = this.simboloAnterior();
|
|
212
212
|
var direito = this.exponenciacao();
|
|
213
213
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -216,7 +216,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
216
216
|
};
|
|
217
217
|
AvaliadorSintaticoEguaClassico.prototype.adicionar = function () {
|
|
218
218
|
var expressao = this.multiplicar();
|
|
219
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
219
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.SUBTRACAO, delegua_1.default.ADICAO)) {
|
|
220
220
|
var operador = this.simboloAnterior();
|
|
221
221
|
var direito = this.multiplicar();
|
|
222
222
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -225,7 +225,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
225
225
|
};
|
|
226
226
|
AvaliadorSintaticoEguaClassico.prototype.bitFill = function () {
|
|
227
227
|
var expressao = this.adicionar();
|
|
228
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
228
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.MENOR_MENOR, delegua_1.default.MAIOR_MAIOR)) {
|
|
229
229
|
var operador = this.simboloAnterior();
|
|
230
230
|
var direito = this.adicionar();
|
|
231
231
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -234,7 +234,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
234
234
|
};
|
|
235
235
|
AvaliadorSintaticoEguaClassico.prototype.bitE = function () {
|
|
236
236
|
var expressao = this.bitFill();
|
|
237
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
237
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.BIT_AND)) {
|
|
238
238
|
var operador = this.simboloAnterior();
|
|
239
239
|
var direito = this.bitFill();
|
|
240
240
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -243,7 +243,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
243
243
|
};
|
|
244
244
|
AvaliadorSintaticoEguaClassico.prototype.bitOu = function () {
|
|
245
245
|
var expressao = this.bitE();
|
|
246
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
246
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.BIT_OR, delegua_1.default.BIT_XOR)) {
|
|
247
247
|
var operador = this.simboloAnterior();
|
|
248
248
|
var direito = this.bitE();
|
|
249
249
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -252,7 +252,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
252
252
|
};
|
|
253
253
|
AvaliadorSintaticoEguaClassico.prototype.comparar = function () {
|
|
254
254
|
var expressao = this.bitOu();
|
|
255
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
255
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.MAIOR, delegua_1.default.MAIOR_IGUAL, delegua_1.default.MENOR, delegua_1.default.MENOR_IGUAL)) {
|
|
256
256
|
var operador = this.simboloAnterior();
|
|
257
257
|
var direito = this.bitOu();
|
|
258
258
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -261,7 +261,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
261
261
|
};
|
|
262
262
|
AvaliadorSintaticoEguaClassico.prototype.comparacaoIgualdade = function () {
|
|
263
263
|
var expressao = this.comparar();
|
|
264
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
264
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.DIFERENTE, delegua_1.default.IGUAL_IGUAL)) {
|
|
265
265
|
var operador = this.simboloAnterior();
|
|
266
266
|
var direito = this.comparar();
|
|
267
267
|
expressao = new construtos_1.Binario(this.hashArquivo, expressao, operador, direito);
|
|
@@ -270,7 +270,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
270
270
|
};
|
|
271
271
|
AvaliadorSintaticoEguaClassico.prototype.em = function () {
|
|
272
272
|
var expressao = this.comparacaoIgualdade();
|
|
273
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
273
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.EM)) {
|
|
274
274
|
var operador = this.simboloAnterior();
|
|
275
275
|
var direito = this.comparacaoIgualdade();
|
|
276
276
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
@@ -279,7 +279,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
279
279
|
};
|
|
280
280
|
AvaliadorSintaticoEguaClassico.prototype.e = function () {
|
|
281
281
|
var expressao = this.em();
|
|
282
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
282
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.E)) {
|
|
283
283
|
var operador = this.simboloAnterior();
|
|
284
284
|
var direito = this.em();
|
|
285
285
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
@@ -288,7 +288,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
288
288
|
};
|
|
289
289
|
AvaliadorSintaticoEguaClassico.prototype.ou = function () {
|
|
290
290
|
var expressao = this.e();
|
|
291
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
291
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.OU)) {
|
|
292
292
|
var operador = this.simboloAnterior();
|
|
293
293
|
var direito = this.e();
|
|
294
294
|
expressao = new construtos_1.Logico(this.hashArquivo, expressao, operador, direito);
|
|
@@ -297,7 +297,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
297
297
|
};
|
|
298
298
|
AvaliadorSintaticoEguaClassico.prototype.atribuir = function () {
|
|
299
299
|
var expressao = this.ou();
|
|
300
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
300
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.IGUAL)) {
|
|
301
301
|
var igual = this.simboloAnterior();
|
|
302
302
|
var valor = this.atribuir();
|
|
303
303
|
if (expressao instanceof construtos_1.Variavel) {
|
|
@@ -320,36 +320,36 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
320
320
|
};
|
|
321
321
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoEscreva = function () {
|
|
322
322
|
var simboloAtual = this.simboloAtual();
|
|
323
|
-
this.consumir(
|
|
323
|
+
this.consumir(delegua_1.default.PARENTESE_ESQUERDO, "Esperado '(' antes dos valores em escreva.");
|
|
324
324
|
var valor = this.expressao();
|
|
325
|
-
this.consumir(
|
|
326
|
-
this.consumir(
|
|
327
|
-
return new declaracoes_1.Escreva(simboloAtual.linha, simboloAtual.hashArquivo, [valor]);
|
|
325
|
+
this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' após os valores em escreva.");
|
|
326
|
+
this.consumir(delegua_1.default.PONTO_E_VIRGULA, "Esperado ';' após o valor.");
|
|
327
|
+
return new declaracoes_1.Escreva(Number(simboloAtual.linha), simboloAtual.hashArquivo, [valor]);
|
|
328
328
|
};
|
|
329
329
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoExpressao = function () {
|
|
330
330
|
var expressao = this.expressao();
|
|
331
|
-
this.consumir(
|
|
331
|
+
this.consumir(delegua_1.default.PONTO_E_VIRGULA, "Esperado ';' após expressão.");
|
|
332
332
|
return new declaracoes_1.Expressao(expressao);
|
|
333
333
|
};
|
|
334
334
|
AvaliadorSintaticoEguaClassico.prototype.blocoEscopo = function () {
|
|
335
335
|
var declaracoes = [];
|
|
336
|
-
while (!this.verificarTipoSimboloAtual(
|
|
336
|
+
while (!this.verificarTipoSimboloAtual(delegua_1.default.CHAVE_DIREITA) &&
|
|
337
337
|
!this.estaNoFinal()) {
|
|
338
338
|
declaracoes.push(this.declaracao());
|
|
339
339
|
}
|
|
340
|
-
this.consumir(
|
|
340
|
+
this.consumir(delegua_1.default.CHAVE_DIREITA, "Esperado '}' após o bloco.");
|
|
341
341
|
return declaracoes;
|
|
342
342
|
};
|
|
343
343
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoSe = function () {
|
|
344
|
-
this.consumir(
|
|
344
|
+
this.consumir(delegua_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'se'.");
|
|
345
345
|
var condicao = this.expressao();
|
|
346
|
-
this.consumir(
|
|
346
|
+
this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' após condição do se.");
|
|
347
347
|
var caminhoEntao = this.resolverDeclaracao();
|
|
348
348
|
var caminhosSeSenao = [];
|
|
349
|
-
while (this.verificarSeSimboloAtualEIgualA(
|
|
350
|
-
this.consumir(
|
|
349
|
+
while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.SENÃOSE)) {
|
|
350
|
+
this.consumir(delegua_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'senãose'.");
|
|
351
351
|
var condicaoSeSenao = this.expressao();
|
|
352
|
-
this.consumir(
|
|
352
|
+
this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' apóes codição do 'senãose.");
|
|
353
353
|
var caminho = this.resolverDeclaracao();
|
|
354
354
|
caminhosSeSenao.push({
|
|
355
355
|
condicao: condicaoSeSenao,
|
|
@@ -357,7 +357,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
359
|
var caminhoSenao = null;
|
|
360
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
360
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.SENÃO)) {
|
|
361
361
|
caminhoSenao = this.resolverDeclaracao();
|
|
362
362
|
}
|
|
363
363
|
return new declaracoes_1.Se(condicao, caminhoEntao, caminhosSeSenao, caminhoSenao);
|
|
@@ -365,9 +365,9 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
365
365
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoEnquanto = function () {
|
|
366
366
|
try {
|
|
367
367
|
this.ciclos += 1;
|
|
368
|
-
this.consumir(
|
|
368
|
+
this.consumir(delegua_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'enquanto'.");
|
|
369
369
|
var condicao = this.expressao();
|
|
370
|
-
this.consumir(
|
|
370
|
+
this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' após condicional.");
|
|
371
371
|
var corpo = this.resolverDeclaracao();
|
|
372
372
|
return new declaracoes_1.Enquanto(condicao, corpo);
|
|
373
373
|
}
|
|
@@ -379,27 +379,27 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
379
379
|
try {
|
|
380
380
|
var simboloPara = this.simboloAnterior();
|
|
381
381
|
this.ciclos += 1;
|
|
382
|
-
this.consumir(
|
|
382
|
+
this.consumir(delegua_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'para'.");
|
|
383
383
|
var inicializador = void 0;
|
|
384
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
384
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.PONTO_E_VIRGULA)) {
|
|
385
385
|
inicializador = null;
|
|
386
386
|
}
|
|
387
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
387
|
+
else if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.VARIAVEL)) {
|
|
388
388
|
inicializador = this.declaracaoDeVariavel();
|
|
389
389
|
}
|
|
390
390
|
else {
|
|
391
391
|
inicializador = this.declaracaoExpressao();
|
|
392
392
|
}
|
|
393
393
|
var condicao = null;
|
|
394
|
-
if (!this.verificarTipoSimboloAtual(
|
|
394
|
+
if (!this.verificarTipoSimboloAtual(delegua_1.default.PONTO_E_VIRGULA)) {
|
|
395
395
|
condicao = this.expressao();
|
|
396
396
|
}
|
|
397
|
-
this.consumir(
|
|
397
|
+
this.consumir(delegua_1.default.PONTO_E_VIRGULA, "Esperado ';' após valores da condicional");
|
|
398
398
|
var incrementar = null;
|
|
399
|
-
if (!this.verificarTipoSimboloAtual(
|
|
399
|
+
if (!this.verificarTipoSimboloAtual(delegua_1.default.PARENTESE_DIREITO)) {
|
|
400
400
|
incrementar = this.expressao();
|
|
401
401
|
}
|
|
402
|
-
this.consumir(
|
|
402
|
+
this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' após cláusulas");
|
|
403
403
|
var corpo = this.resolverDeclaracao();
|
|
404
404
|
return new declaracoes_1.Para(this.hashArquivo, Number(simboloPara.linha), inicializador, condicao, incrementar, corpo);
|
|
405
405
|
}
|
|
@@ -411,68 +411,68 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
411
411
|
if (this.ciclos < 1) {
|
|
412
412
|
this.erro(this.simboloAnterior(), "'pausa' deve estar dentro de um loop.");
|
|
413
413
|
}
|
|
414
|
-
this.consumir(
|
|
414
|
+
this.consumir(delegua_1.default.PONTO_E_VIRGULA, "Esperado ';' após 'pausa'.");
|
|
415
415
|
return new declaracoes_1.Sustar(this.simboloAtual());
|
|
416
416
|
};
|
|
417
417
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoContinua = function () {
|
|
418
418
|
if (this.ciclos < 1) {
|
|
419
419
|
this.erro(this.simboloAnterior(), "'continua' precisa estar em um laço de repetição.");
|
|
420
420
|
}
|
|
421
|
-
this.consumir(
|
|
421
|
+
this.consumir(delegua_1.default.PONTO_E_VIRGULA, "Esperado ';' após 'continua'.");
|
|
422
422
|
return new declaracoes_1.Continua(this.simboloAtual());
|
|
423
423
|
};
|
|
424
424
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoRetorna = function () {
|
|
425
425
|
var palavraChave = this.simboloAnterior();
|
|
426
426
|
var valor = null;
|
|
427
|
-
if (!this.verificarTipoSimboloAtual(
|
|
427
|
+
if (!this.verificarTipoSimboloAtual(delegua_1.default.PONTO_E_VIRGULA)) {
|
|
428
428
|
valor = this.expressao();
|
|
429
429
|
}
|
|
430
|
-
this.consumir(
|
|
430
|
+
this.consumir(delegua_1.default.PONTO_E_VIRGULA, "Esperado ';' após o retorno.");
|
|
431
431
|
return new declaracoes_1.Retorna(palavraChave, valor);
|
|
432
432
|
};
|
|
433
433
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoEscolha = function () {
|
|
434
434
|
try {
|
|
435
435
|
this.ciclos += 1;
|
|
436
|
-
this.consumir(
|
|
436
|
+
this.consumir(delegua_1.default.PARENTESE_ESQUERDO, "Esperado '{' após 'escolha'.");
|
|
437
437
|
var condicao = this.expressao();
|
|
438
|
-
this.consumir(
|
|
439
|
-
this.consumir(
|
|
438
|
+
this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado '}' após a condição de 'escolha'.");
|
|
439
|
+
this.consumir(delegua_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo do 'escolha'.");
|
|
440
440
|
var caminhos = [];
|
|
441
441
|
var caminhoPadrao = null;
|
|
442
|
-
while (!this.verificarSeSimboloAtualEIgualA(
|
|
442
|
+
while (!this.verificarSeSimboloAtualEIgualA(delegua_1.default.CHAVE_DIREITA) &&
|
|
443
443
|
!this.estaNoFinal()) {
|
|
444
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
444
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.CASO)) {
|
|
445
445
|
var caminhoCondicoes = [this.expressao()];
|
|
446
|
-
this.consumir(
|
|
447
|
-
while (this.verificarTipoSimboloAtual(
|
|
448
|
-
this.consumir(
|
|
446
|
+
this.consumir(delegua_1.default.DOIS_PONTOS, "Esperado ':' após o 'caso'.");
|
|
447
|
+
while (this.verificarTipoSimboloAtual(delegua_1.default.CASO)) {
|
|
448
|
+
this.consumir(delegua_1.default.CASO, null);
|
|
449
449
|
caminhoCondicoes.push(this.expressao());
|
|
450
|
-
this.consumir(
|
|
450
|
+
this.consumir(delegua_1.default.DOIS_PONTOS, "Esperado ':' após declaração do 'caso'.");
|
|
451
451
|
}
|
|
452
452
|
var declaracoes = [];
|
|
453
453
|
do {
|
|
454
454
|
declaracoes.push(this.resolverDeclaracao());
|
|
455
|
-
} while (!this.verificarTipoSimboloAtual(
|
|
456
|
-
!this.verificarTipoSimboloAtual(
|
|
457
|
-
!this.verificarTipoSimboloAtual(
|
|
455
|
+
} while (!this.verificarTipoSimboloAtual(delegua_1.default.CASO) &&
|
|
456
|
+
!this.verificarTipoSimboloAtual(delegua_1.default.PADRAO) &&
|
|
457
|
+
!this.verificarTipoSimboloAtual(delegua_1.default.CHAVE_DIREITA));
|
|
458
458
|
caminhos.push({
|
|
459
459
|
condicoes: caminhoCondicoes,
|
|
460
460
|
declaracoes: declaracoes,
|
|
461
461
|
});
|
|
462
462
|
}
|
|
463
|
-
else if (this.verificarSeSimboloAtualEIgualA(
|
|
463
|
+
else if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.PADRAO)) {
|
|
464
464
|
if (caminhoPadrao !== null) {
|
|
465
465
|
var excecao = new erro_avaliador_sintatico_1.ErroAvaliadorSintatico(this.simboloAtual(), "Você só pode ter um 'padrao' em cada declaração de 'escolha'.");
|
|
466
466
|
this.erros.push(excecao);
|
|
467
467
|
throw excecao;
|
|
468
468
|
}
|
|
469
|
-
this.consumir(
|
|
469
|
+
this.consumir(delegua_1.default.DOIS_PONTOS, "Esperado ':' após declaração do 'padrao'.");
|
|
470
470
|
var declaracoes = [];
|
|
471
471
|
do {
|
|
472
472
|
declaracoes.push(this.resolverDeclaracao());
|
|
473
|
-
} while (!this.verificarTipoSimboloAtual(
|
|
474
|
-
!this.verificarTipoSimboloAtual(
|
|
475
|
-
!this.verificarTipoSimboloAtual(
|
|
473
|
+
} while (!this.verificarTipoSimboloAtual(delegua_1.default.CASO) &&
|
|
474
|
+
!this.verificarTipoSimboloAtual(delegua_1.default.PADRAO) &&
|
|
475
|
+
!this.verificarTipoSimboloAtual(delegua_1.default.CHAVE_DIREITA));
|
|
476
476
|
caminhoPadrao = {
|
|
477
477
|
declaracoes: declaracoes,
|
|
478
478
|
};
|
|
@@ -485,27 +485,33 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
487
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoImportar = function () {
|
|
488
|
-
this.consumir(
|
|
488
|
+
this.consumir(delegua_1.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração.");
|
|
489
489
|
var caminho = this.expressao();
|
|
490
|
-
var simboloFechamento = this.consumir(
|
|
490
|
+
var simboloFechamento = this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' após declaração.");
|
|
491
|
+
// tive que fazer isso para poder tipar a func expressão
|
|
492
|
+
// não sei isso e certo provavelmente não.
|
|
493
|
+
// o parametro valor no tipo literal esta como any
|
|
494
|
+
// ele esta dificultando a refatoração
|
|
495
|
+
// alguma ideia de qual tipo ele pode ser ?
|
|
496
|
+
caminho.valor = null;
|
|
491
497
|
return new declaracoes_1.Importar(caminho, simboloFechamento);
|
|
492
498
|
};
|
|
493
499
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoTente = function () {
|
|
494
|
-
this.consumir(
|
|
500
|
+
this.consumir(delegua_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'tente'.");
|
|
495
501
|
var tryBlock = this.blocoEscopo();
|
|
496
502
|
var catchBlock = null;
|
|
497
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
498
|
-
this.consumir(
|
|
503
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.PEGUE)) {
|
|
504
|
+
this.consumir(delegua_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
|
|
499
505
|
catchBlock = this.blocoEscopo();
|
|
500
506
|
}
|
|
501
507
|
var elseBlock = null;
|
|
502
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
503
|
-
this.consumir(
|
|
508
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.SENÃO)) {
|
|
509
|
+
this.consumir(delegua_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
|
|
504
510
|
elseBlock = this.blocoEscopo();
|
|
505
511
|
}
|
|
506
512
|
var finallyBlock = null;
|
|
507
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
508
|
-
this.consumir(
|
|
513
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.FINALMENTE)) {
|
|
514
|
+
this.consumir(delegua_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
|
|
509
515
|
finallyBlock = this.blocoEscopo();
|
|
510
516
|
}
|
|
511
517
|
return new declaracoes_1.Tente(0, 0, tryBlock, catchBlock, elseBlock, finallyBlock);
|
|
@@ -514,10 +520,10 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
514
520
|
try {
|
|
515
521
|
this.ciclos += 1;
|
|
516
522
|
var caminhoFazer = this.resolverDeclaracao();
|
|
517
|
-
this.consumir(
|
|
518
|
-
this.consumir(
|
|
523
|
+
this.consumir(delegua_1.default.ENQUANTO, "Esperado declaração do 'enquanto' após o escopo do 'fazer'.");
|
|
524
|
+
this.consumir(delegua_1.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração 'enquanto'.");
|
|
519
525
|
var condicaoEnquanto = this.expressao();
|
|
520
|
-
this.consumir(
|
|
526
|
+
this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' após declaração do 'enquanto'.");
|
|
521
527
|
return new declaracoes_1.Fazer(0, 0, caminhoFazer, condicaoEnquanto);
|
|
522
528
|
}
|
|
523
529
|
finally {
|
|
@@ -525,99 +531,99 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
525
531
|
}
|
|
526
532
|
};
|
|
527
533
|
AvaliadorSintaticoEguaClassico.prototype.resolverDeclaracao = function () {
|
|
528
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
534
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.FAZER))
|
|
529
535
|
return this.declaracaoFazer();
|
|
530
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
536
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.TENTE))
|
|
531
537
|
return this.declaracaoTente();
|
|
532
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
538
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.ESCOLHA))
|
|
533
539
|
return this.declaracaoEscolha();
|
|
534
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
540
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.RETORNA))
|
|
535
541
|
return this.declaracaoRetorna();
|
|
536
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
542
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.CONTINUA))
|
|
537
543
|
return this.declaracaoContinua();
|
|
538
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
544
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.PAUSA))
|
|
539
545
|
return this.declaracaoSustar();
|
|
540
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
546
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.PARA))
|
|
541
547
|
return this.declaracaoPara();
|
|
542
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
548
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.ENQUANTO))
|
|
543
549
|
return this.declaracaoEnquanto();
|
|
544
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
550
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.SE))
|
|
545
551
|
return this.declaracaoSe();
|
|
546
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
552
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.ESCREVA))
|
|
547
553
|
return this.declaracaoEscreva();
|
|
548
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
554
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.CHAVE_ESQUERDA))
|
|
549
555
|
return new declaracoes_1.Bloco(0, 0, this.blocoEscopo());
|
|
550
556
|
return this.declaracaoExpressao();
|
|
551
557
|
};
|
|
552
558
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoDeVariavel = function () {
|
|
553
|
-
var nome = this.consumir(
|
|
559
|
+
var nome = this.consumir(delegua_1.default.IDENTIFICADOR, 'Esperado nome de variável.');
|
|
554
560
|
var inicializador = null;
|
|
555
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
561
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.IGUAL)) {
|
|
556
562
|
inicializador = this.expressao();
|
|
557
563
|
}
|
|
558
|
-
this.consumir(
|
|
564
|
+
this.consumir(delegua_1.default.PONTO_E_VIRGULA, "Esperado ';' após a declaração da variável.");
|
|
559
565
|
return new declaracoes_1.Var(nome, inicializador);
|
|
560
566
|
};
|
|
561
567
|
AvaliadorSintaticoEguaClassico.prototype.funcao = function (kind) {
|
|
562
|
-
var nome = this.consumir(
|
|
568
|
+
var nome = this.consumir(delegua_1.default.IDENTIFICADOR, "Esperado nome ".concat(kind, "."));
|
|
563
569
|
return new declaracoes_1.Funcao(nome, this.corpoDaFuncao(kind));
|
|
564
570
|
};
|
|
565
571
|
AvaliadorSintaticoEguaClassico.prototype.corpoDaFuncao = function (kind) {
|
|
566
|
-
this.consumir(
|
|
572
|
+
this.consumir(delegua_1.default.PARENTESE_ESQUERDO, "Esperado '(' ap\u00F3s o nome ".concat(kind, "."));
|
|
567
573
|
var parametros = [];
|
|
568
|
-
if (!this.verificarTipoSimboloAtual(
|
|
574
|
+
if (!this.verificarTipoSimboloAtual(delegua_1.default.PARENTESE_DIREITO)) {
|
|
569
575
|
do {
|
|
570
576
|
if (parametros.length >= 255) {
|
|
571
577
|
this.erro(this.simboloAtual(), 'Não pode haver mais de 255 parâmetros');
|
|
572
578
|
}
|
|
573
579
|
var parametro = {};
|
|
574
|
-
if (this.simboloAtual().tipo ===
|
|
575
|
-
this.consumir(
|
|
580
|
+
if (this.simboloAtual().tipo === delegua_1.default.MULTIPLICACAO) {
|
|
581
|
+
this.consumir(delegua_1.default.MULTIPLICACAO, null);
|
|
576
582
|
parametro['tipo'] = 'estrela';
|
|
577
583
|
}
|
|
578
584
|
else {
|
|
579
585
|
parametro['tipo'] = 'padrao';
|
|
580
586
|
}
|
|
581
|
-
parametro['nome'] = this.consumir(
|
|
582
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
587
|
+
parametro['nome'] = this.consumir(delegua_1.default.IDENTIFICADOR, 'Esperado nome do parâmetro.');
|
|
588
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.IGUAL)) {
|
|
583
589
|
parametro['padrao'] = this.primario();
|
|
584
590
|
}
|
|
585
591
|
parametros.push(parametro);
|
|
586
592
|
if (parametro['tipo'] === 'estrela')
|
|
587
593
|
break;
|
|
588
|
-
} while (this.verificarSeSimboloAtualEIgualA(
|
|
594
|
+
} while (this.verificarSeSimboloAtualEIgualA(delegua_1.default.VIRGULA));
|
|
589
595
|
}
|
|
590
|
-
this.consumir(
|
|
591
|
-
this.consumir(
|
|
596
|
+
this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' após parâmetros.");
|
|
597
|
+
this.consumir(delegua_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo do ".concat(kind, "."));
|
|
592
598
|
var corpo = this.blocoEscopo();
|
|
593
599
|
return new construtos_1.Funcao(this.hashArquivo, 0, parametros, corpo);
|
|
594
600
|
};
|
|
595
601
|
AvaliadorSintaticoEguaClassico.prototype.declaracaoDeClasse = function () {
|
|
596
|
-
var nome = this.consumir(
|
|
602
|
+
var nome = this.consumir(delegua_1.default.IDENTIFICADOR, 'Esperado nome da classe.');
|
|
597
603
|
var superClasse = null;
|
|
598
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
599
|
-
this.consumir(
|
|
604
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.HERDA)) {
|
|
605
|
+
this.consumir(delegua_1.default.IDENTIFICADOR, 'Esperado nome da SuperClasse.');
|
|
600
606
|
superClasse = new construtos_1.Variavel(this.hashArquivo, this.simboloAnterior());
|
|
601
607
|
}
|
|
602
|
-
this.consumir(
|
|
608
|
+
this.consumir(delegua_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo da classe.");
|
|
603
609
|
var metodos = [];
|
|
604
|
-
while (!this.verificarTipoSimboloAtual(
|
|
610
|
+
while (!this.verificarTipoSimboloAtual(delegua_1.default.CHAVE_DIREITA) &&
|
|
605
611
|
!this.estaNoFinal()) {
|
|
606
612
|
metodos.push(this.funcao('método'));
|
|
607
613
|
}
|
|
608
|
-
this.consumir(
|
|
614
|
+
this.consumir(delegua_1.default.CHAVE_DIREITA, "Esperado '}' após o escopo da classe.");
|
|
609
615
|
return new declaracoes_1.Classe(nome, superClasse, metodos);
|
|
610
616
|
};
|
|
611
617
|
AvaliadorSintaticoEguaClassico.prototype.declaracao = function () {
|
|
612
618
|
try {
|
|
613
|
-
if (this.verificarTipoSimboloAtual(
|
|
614
|
-
this.verificarTipoProximoSimbolo(
|
|
615
|
-
this.consumir(
|
|
619
|
+
if (this.verificarTipoSimboloAtual(delegua_1.default.FUNÇÃO) &&
|
|
620
|
+
this.verificarTipoProximoSimbolo(delegua_1.default.IDENTIFICADOR)) {
|
|
621
|
+
this.consumir(delegua_1.default.FUNÇÃO, null);
|
|
616
622
|
return this.funcao('função');
|
|
617
623
|
}
|
|
618
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
624
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.VARIAVEL))
|
|
619
625
|
return this.declaracaoDeVariavel();
|
|
620
|
-
if (this.verificarSeSimboloAtualEIgualA(
|
|
626
|
+
if (this.verificarSeSimboloAtualEIgualA(delegua_1.default.CLASSE))
|
|
621
627
|
return this.declaracaoDeClasse();
|
|
622
628
|
return this.resolverDeclaracao();
|
|
623
629
|
}
|
|
@@ -638,7 +644,7 @@ var AvaliadorSintaticoEguaClassico = /** @class */ (function () {
|
|
|
638
644
|
}
|
|
639
645
|
return {
|
|
640
646
|
declaracoes: declaracoes,
|
|
641
|
-
erros: this.erros
|
|
647
|
+
erros: this.erros,
|
|
642
648
|
};
|
|
643
649
|
};
|
|
644
650
|
return AvaliadorSintaticoEguaClassico;
|