@designliquido/delegua 0.1.6 → 0.1.7
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 +4 -3
- package/package.json +2 -2
- package/src/avaliador-sintatico/dialetos/egua-classico.js +116 -116
- package/src/avaliador-sintatico/dialetos/egua-classico.js.map +1 -1
- package/src/avaliador-sintatico/{parser-error.js → erros-avaliador.js} +1 -1
- package/src/avaliador-sintatico/erros-avaliador.js.map +1 -0
- package/src/avaliador-sintatico/index.js +123 -123
- package/src/avaliador-sintatico/index.js.map +1 -1
- package/src/construtos/assign-subscript.js +1 -1
- package/src/construtos/assign-subscript.js.map +1 -1
- package/src/construtos/atribuir.js +1 -1
- package/src/construtos/atribuir.js.map +1 -1
- package/src/construtos/binario.js +1 -1
- package/src/construtos/binario.js.map +1 -1
- package/src/construtos/call.js +1 -1
- package/src/construtos/call.js.map +1 -1
- package/src/construtos/conjunto.js +1 -1
- package/src/construtos/conjunto.js.map +1 -1
- package/src/construtos/dicionario.js +1 -1
- package/src/construtos/dicionario.js.map +1 -1
- package/src/construtos/funcao.js +1 -1
- package/src/construtos/funcao.js.map +1 -1
- package/src/construtos/get.js +1 -1
- package/src/construtos/get.js.map +1 -1
- package/src/construtos/grouping.js +1 -1
- package/src/construtos/grouping.js.map +1 -1
- package/src/construtos/isto.js +1 -1
- package/src/construtos/isto.js.map +1 -1
- package/src/construtos/literal.js +1 -1
- package/src/construtos/literal.js.map +1 -1
- package/src/construtos/logical.js +1 -1
- package/src/construtos/logical.js.map +1 -1
- package/src/construtos/subscript.js +1 -1
- package/src/construtos/subscript.js.map +1 -1
- package/src/construtos/super.js +1 -1
- package/src/construtos/super.js.map +1 -1
- package/src/construtos/unario.js +1 -1
- package/src/construtos/unario.js.map +1 -1
- package/src/construtos/variavel.js +1 -1
- package/src/construtos/variavel.js.map +1 -1
- package/src/construtos/vetor.js +1 -1
- package/src/construtos/vetor.js.map +1 -1
- package/src/declaracoes/block.js +33 -0
- package/src/declaracoes/block.js.map +1 -0
- package/src/declaracoes/classe.js +35 -0
- package/src/declaracoes/classe.js.map +1 -0
- package/src/declaracoes/continua.js +31 -0
- package/src/declaracoes/continua.js.map +1 -0
- package/src/declaracoes/enquanto.js +34 -0
- package/src/declaracoes/enquanto.js.map +1 -0
- package/src/declaracoes/escolha.js +35 -0
- package/src/declaracoes/escolha.js.map +1 -0
- package/src/declaracoes/escreva.js +33 -0
- package/src/declaracoes/escreva.js.map +1 -0
- package/src/declaracoes/expressao.js +33 -0
- package/src/declaracoes/expressao.js.map +1 -0
- package/src/declaracoes/fazer.js +34 -0
- package/src/declaracoes/fazer.js.map +1 -0
- package/src/declaracoes/funcao.js +34 -0
- package/src/declaracoes/funcao.js.map +1 -0
- package/src/declaracoes/importar.js +34 -0
- package/src/declaracoes/importar.js.map +1 -0
- package/src/declaracoes/index.js +27 -246
- package/src/declaracoes/index.js.map +1 -1
- package/src/declaracoes/para.js +36 -0
- package/src/declaracoes/para.js.map +1 -0
- package/src/declaracoes/pausa.js +31 -0
- package/src/declaracoes/pausa.js.map +1 -0
- package/src/declaracoes/retorna.js +34 -0
- package/src/declaracoes/retorna.js.map +1 -0
- package/src/declaracoes/se.js +36 -0
- package/src/declaracoes/se.js.map +1 -0
- package/src/declaracoes/stmt.js +11 -0
- package/src/declaracoes/stmt.js.map +1 -0
- package/src/declaracoes/tente.js +36 -0
- package/src/declaracoes/tente.js.map +1 -0
- package/src/declaracoes/var.js +34 -0
- package/src/declaracoes/var.js.map +1 -0
- package/src/delegua.js +11 -6
- package/src/delegua.js.map +1 -1
- package/src/estruturas/funcao.js +1 -1
- package/src/estruturas/funcao.js.map +1 -1
- package/src/interpretador/dialetos/egua-classico.js +64 -68
- package/src/interpretador/dialetos/egua-classico.js.map +1 -1
- package/src/interpretador/index.js +74 -75
- package/src/interpretador/index.js.map +1 -1
- package/src/lexador/dialetos/egua-classico.js +5 -7
- package/src/lexador/dialetos/egua-classico.js.map +1 -1
- package/src/lexador/index.js +7 -10
- package/src/lexador/index.js.map +1 -1
- package/src/resolvedor/dialetos/egua-classico.js +39 -39
- package/src/resolvedor/dialetos/egua-classico.js.map +1 -1
- package/src/resolvedor/index.js +39 -39
- package/src/resolvedor/index.js.map +1 -1
- package/src/tiposDeSimbolos.js +1 -1
- package/src/tiposDeSimbolos.js.map +1 -1
- package/src/avaliador-sintatico/parser-error.js.map +0 -1
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Parser = void 0;
|
|
4
4
|
var tiposDeSimbolos_1 = require("../tiposDeSimbolos");
|
|
5
5
|
var construtos_1 = require("../construtos");
|
|
6
|
+
var erros_avaliador_1 = require("./erros-avaliador");
|
|
6
7
|
var declaracoes_1 = require("../declaracoes");
|
|
7
|
-
var parser_error_1 = require("./parser-error");
|
|
8
8
|
/**
|
|
9
9
|
* O avaliador sintático (Parser) é responsável por transformar os símbolos do Lexador em estruturas de alto nível.
|
|
10
10
|
* Essas estruturas de alto nível são as partes que executam lógica de programação de fato.
|
|
@@ -21,7 +21,7 @@ var Parser = /** @class */ (function () {
|
|
|
21
21
|
while (!this.estaNoFinal()) {
|
|
22
22
|
if (this.voltar().tipo === tiposDeSimbolos_1.default.PONTO_E_VIRGULA)
|
|
23
23
|
return;
|
|
24
|
-
switch (this.
|
|
24
|
+
switch (this.simboloAtual().tipo) {
|
|
25
25
|
case tiposDeSimbolos_1.default.CLASSE:
|
|
26
26
|
case tiposDeSimbolos_1.default.FUNCAO:
|
|
27
27
|
case tiposDeSimbolos_1.default.VAR:
|
|
@@ -37,25 +37,25 @@ var Parser = /** @class */ (function () {
|
|
|
37
37
|
};
|
|
38
38
|
Parser.prototype.erro = function (simbolo, mensagemDeErro) {
|
|
39
39
|
this.Delegua.erro(simbolo, mensagemDeErro);
|
|
40
|
-
return new
|
|
40
|
+
return new erros_avaliador_1.ErroAvaliador();
|
|
41
41
|
};
|
|
42
42
|
Parser.prototype.consumir = function (tipo, mensagemDeErro) {
|
|
43
43
|
if (this.verificar(tipo))
|
|
44
44
|
return this.avancar();
|
|
45
45
|
else
|
|
46
|
-
throw this.erro(this.
|
|
46
|
+
throw this.erro(this.simboloAtual(), mensagemDeErro);
|
|
47
47
|
};
|
|
48
48
|
Parser.prototype.verificar = function (tipo) {
|
|
49
49
|
if (this.estaNoFinal())
|
|
50
50
|
return false;
|
|
51
|
-
return this.
|
|
51
|
+
return this.simboloAtual().tipo === tipo;
|
|
52
52
|
};
|
|
53
53
|
Parser.prototype.verificarProximo = function (tipo) {
|
|
54
54
|
if (this.estaNoFinal())
|
|
55
55
|
return false;
|
|
56
56
|
return this.simbolos[this.atual + 1].tipo === tipo;
|
|
57
57
|
};
|
|
58
|
-
Parser.prototype.
|
|
58
|
+
Parser.prototype.simboloAtual = function () {
|
|
59
59
|
return this.simbolos[this.atual];
|
|
60
60
|
};
|
|
61
61
|
Parser.prototype.voltar = function () {
|
|
@@ -65,14 +65,18 @@ var Parser = /** @class */ (function () {
|
|
|
65
65
|
return this.simbolos[this.atual + posicao];
|
|
66
66
|
};
|
|
67
67
|
Parser.prototype.estaNoFinal = function () {
|
|
68
|
-
|
|
68
|
+
var simboloAtual = this.simboloAtual();
|
|
69
|
+
if (simboloAtual && (simboloAtual.tipo === tiposDeSimbolos_1.default.PONTO_E_VIRGULA)) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return this.atual === this.simbolos.length;
|
|
69
73
|
};
|
|
70
74
|
Parser.prototype.avancar = function () {
|
|
71
75
|
if (!this.estaNoFinal())
|
|
72
76
|
this.atual += 1;
|
|
73
77
|
return this.voltar();
|
|
74
78
|
};
|
|
75
|
-
Parser.prototype.
|
|
79
|
+
Parser.prototype.verificarSeSimboloAtualEIgualA = function () {
|
|
76
80
|
var argumentos = [];
|
|
77
81
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
78
82
|
argumentos[_i] = arguments[_i];
|
|
@@ -87,78 +91,78 @@ var Parser = /** @class */ (function () {
|
|
|
87
91
|
return false;
|
|
88
92
|
};
|
|
89
93
|
Parser.prototype.primario = function () {
|
|
90
|
-
if (this.
|
|
94
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SUPER)) {
|
|
91
95
|
var palavraChave = this.voltar();
|
|
92
|
-
this.consumir(tiposDeSimbolos_1.default.
|
|
96
|
+
this.consumir(tiposDeSimbolos_1.default.PONTO, "Esperado '.' após 'super'.");
|
|
93
97
|
var metodo = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome do método da SuperClasse.");
|
|
94
98
|
return new construtos_1.Super(palavraChave, metodo);
|
|
95
99
|
}
|
|
96
|
-
if (this.
|
|
100
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_ESQUERDO)) {
|
|
97
101
|
var valores = [];
|
|
98
|
-
if (this.
|
|
102
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_DIREITO)) {
|
|
99
103
|
return new construtos_1.Vetor([]);
|
|
100
104
|
}
|
|
101
|
-
while (!this.
|
|
105
|
+
while (!this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_DIREITO)) {
|
|
102
106
|
var valor = this.atribuir();
|
|
103
107
|
valores.push(valor);
|
|
104
|
-
if (this.
|
|
108
|
+
if (this.simboloAtual().tipo !== tiposDeSimbolos_1.default.COLCHETE_DIREITO) {
|
|
105
109
|
this.consumir(tiposDeSimbolos_1.default.COMMA, "Esperado vírgula antes da próxima expressão.");
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
112
|
return new construtos_1.Vetor(valores);
|
|
109
113
|
}
|
|
110
|
-
if (this.
|
|
114
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_ESQUERDA)) {
|
|
111
115
|
var chaves = [];
|
|
112
116
|
var valores = [];
|
|
113
|
-
if (this.
|
|
117
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_DIREITA)) {
|
|
114
118
|
return new construtos_1.Dicionario([], []);
|
|
115
119
|
}
|
|
116
|
-
while (!this.
|
|
120
|
+
while (!this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_DIREITA)) {
|
|
117
121
|
var chave = this.atribuir();
|
|
118
122
|
this.consumir(tiposDeSimbolos_1.default.DOIS_PONTOS, "Esperado ':' entre chave e valor.");
|
|
119
123
|
var valor = this.atribuir();
|
|
120
124
|
chaves.push(chave);
|
|
121
125
|
valores.push(valor);
|
|
122
|
-
if (this.
|
|
126
|
+
if (this.simboloAtual().tipo !== tiposDeSimbolos_1.default.CHAVE_DIREITA) {
|
|
123
127
|
this.consumir(tiposDeSimbolos_1.default.COMMA, "Esperado vírgula antes da próxima expressão.");
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
return new construtos_1.Dicionario(chaves, valores);
|
|
127
131
|
}
|
|
128
|
-
if (this.
|
|
132
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.FUNCAO))
|
|
129
133
|
return this.corpoDaFuncao("funcao");
|
|
130
|
-
if (this.
|
|
134
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.FALSO))
|
|
131
135
|
return new construtos_1.Literal(false);
|
|
132
|
-
if (this.
|
|
136
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.VERDADEIRO))
|
|
133
137
|
return new construtos_1.Literal(true);
|
|
134
|
-
if (this.
|
|
138
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.NULO))
|
|
135
139
|
return new construtos_1.Literal(null);
|
|
136
|
-
if (this.
|
|
140
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.ISTO))
|
|
137
141
|
return new construtos_1.Isto(this.voltar());
|
|
138
|
-
if (this.
|
|
142
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.NUMERO, tiposDeSimbolos_1.default.TEXTO)) {
|
|
139
143
|
return new construtos_1.Literal(this.voltar().literal);
|
|
140
144
|
}
|
|
141
|
-
if (this.
|
|
145
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IDENTIFICADOR)) {
|
|
142
146
|
return new construtos_1.Variavel(this.voltar());
|
|
143
147
|
}
|
|
144
|
-
if (this.
|
|
148
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO)) {
|
|
145
149
|
var expr = this.expressao();
|
|
146
150
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após a expressão.");
|
|
147
151
|
return new construtos_1.Grouping(expr);
|
|
148
152
|
}
|
|
149
|
-
if (this.
|
|
150
|
-
return this.
|
|
151
|
-
throw this.erro(this.
|
|
153
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IMPORTAR))
|
|
154
|
+
return this.declaracaoImportar();
|
|
155
|
+
throw this.erro(this.simboloAtual(), "Esperado expressão.");
|
|
152
156
|
};
|
|
153
157
|
Parser.prototype.finalizarChamada = function (callee) {
|
|
154
158
|
var argumentos = [];
|
|
155
159
|
if (!this.verificar(tiposDeSimbolos_1.default.PARENTESE_DIREITO)) {
|
|
156
160
|
do {
|
|
157
161
|
if (argumentos.length >= 255) {
|
|
158
|
-
throw this.erro(this.
|
|
162
|
+
throw this.erro(this.simboloAtual(), "Não pode haver mais de 255 argumentos.");
|
|
159
163
|
}
|
|
160
164
|
argumentos.push(this.expressao());
|
|
161
|
-
} while (this.
|
|
165
|
+
} while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COMMA));
|
|
162
166
|
}
|
|
163
167
|
var parenteseDireito = this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após os argumentos.");
|
|
164
168
|
return new construtos_1.Call(callee, parenteseDireito, argumentos);
|
|
@@ -166,14 +170,14 @@ var Parser = /** @class */ (function () {
|
|
|
166
170
|
Parser.prototype.chamar = function () {
|
|
167
171
|
var expr = this.primario();
|
|
168
172
|
while (true) {
|
|
169
|
-
if (this.
|
|
173
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO)) {
|
|
170
174
|
expr = this.finalizarChamada(expr);
|
|
171
175
|
}
|
|
172
|
-
else if (this.
|
|
176
|
+
else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PONTO)) {
|
|
173
177
|
var nome = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome do método após '.'.");
|
|
174
178
|
expr = new construtos_1.Get(expr, nome);
|
|
175
179
|
}
|
|
176
|
-
else if (this.
|
|
180
|
+
else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_ESQUERDO)) {
|
|
177
181
|
var indice = this.expressao();
|
|
178
182
|
var closeBracket = this.consumir(tiposDeSimbolos_1.default.COLCHETE_DIREITO, "Esperado ']' após escrita do indice.");
|
|
179
183
|
expr = new construtos_1.Subscript(expr, indice, closeBracket);
|
|
@@ -185,16 +189,16 @@ var Parser = /** @class */ (function () {
|
|
|
185
189
|
return expr;
|
|
186
190
|
};
|
|
187
191
|
Parser.prototype.unario = function () {
|
|
188
|
-
if (this.
|
|
192
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.NEGACAO, tiposDeSimbolos_1.default.SUBTRACAO, tiposDeSimbolos_1.default.BIT_NOT)) {
|
|
189
193
|
var operador = this.voltar();
|
|
190
194
|
var direito = this.unario();
|
|
191
195
|
return new construtos_1.Unario(operador, direito);
|
|
192
196
|
}
|
|
193
197
|
return this.chamar();
|
|
194
198
|
};
|
|
195
|
-
Parser.prototype.
|
|
199
|
+
Parser.prototype.exponenciacao = function () {
|
|
196
200
|
var expr = this.unario();
|
|
197
|
-
while (this.
|
|
201
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.EXPONENCIACAO)) {
|
|
198
202
|
var operador = this.voltar();
|
|
199
203
|
var direito = this.unario();
|
|
200
204
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -202,17 +206,17 @@ var Parser = /** @class */ (function () {
|
|
|
202
206
|
return expr;
|
|
203
207
|
};
|
|
204
208
|
Parser.prototype.multiplicar = function () {
|
|
205
|
-
var expr = this.
|
|
206
|
-
while (this.
|
|
209
|
+
var expr = this.exponenciacao();
|
|
210
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.DIVISAO, tiposDeSimbolos_1.default.MULTIPLICACAO, tiposDeSimbolos_1.default.MODULO)) {
|
|
207
211
|
var operador = this.voltar();
|
|
208
|
-
var direito = this.
|
|
212
|
+
var direito = this.exponenciacao();
|
|
209
213
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
210
214
|
}
|
|
211
215
|
return expr;
|
|
212
216
|
};
|
|
213
217
|
Parser.prototype.adicionar = function () {
|
|
214
218
|
var expr = this.multiplicar();
|
|
215
|
-
while (this.
|
|
219
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SUBTRACAO, tiposDeSimbolos_1.default.ADICAO)) {
|
|
216
220
|
var operador = this.voltar();
|
|
217
221
|
var direito = this.multiplicar();
|
|
218
222
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -221,7 +225,7 @@ var Parser = /** @class */ (function () {
|
|
|
221
225
|
};
|
|
222
226
|
Parser.prototype.bitFill = function () {
|
|
223
227
|
var expr = this.adicionar();
|
|
224
|
-
while (this.
|
|
228
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.MENOR_MENOR, tiposDeSimbolos_1.default.MAIOR_MAIOR)) {
|
|
225
229
|
var operador = this.voltar();
|
|
226
230
|
var direito = this.adicionar();
|
|
227
231
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -230,7 +234,7 @@ var Parser = /** @class */ (function () {
|
|
|
230
234
|
};
|
|
231
235
|
Parser.prototype.bitE = function () {
|
|
232
236
|
var expr = this.bitFill();
|
|
233
|
-
while (this.
|
|
237
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.BIT_AND)) {
|
|
234
238
|
var operador = this.voltar();
|
|
235
239
|
var direito = this.bitFill();
|
|
236
240
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -239,7 +243,7 @@ var Parser = /** @class */ (function () {
|
|
|
239
243
|
};
|
|
240
244
|
Parser.prototype.bitOu = function () {
|
|
241
245
|
var expr = this.bitE();
|
|
242
|
-
while (this.
|
|
246
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.BIT_OR, tiposDeSimbolos_1.default.BIT_XOR)) {
|
|
243
247
|
var operador = this.voltar();
|
|
244
248
|
var direito = this.bitE();
|
|
245
249
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -248,16 +252,16 @@ var Parser = /** @class */ (function () {
|
|
|
248
252
|
};
|
|
249
253
|
Parser.prototype.comparar = function () {
|
|
250
254
|
var expr = this.bitOu();
|
|
251
|
-
while (this.
|
|
255
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.MAIOR, tiposDeSimbolos_1.default.MAIOR_IGUAL, tiposDeSimbolos_1.default.MENOR, tiposDeSimbolos_1.default.MENOR_IGUAL)) {
|
|
252
256
|
var operador = this.voltar();
|
|
253
257
|
var direito = this.bitOu();
|
|
254
258
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
255
259
|
}
|
|
256
260
|
return expr;
|
|
257
261
|
};
|
|
258
|
-
Parser.prototype.
|
|
262
|
+
Parser.prototype.comparacaoIgualdade = function () {
|
|
259
263
|
var expr = this.comparar();
|
|
260
|
-
while (this.
|
|
264
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.DIFERENTE, tiposDeSimbolos_1.default.IGUAL_IGUAL)) {
|
|
261
265
|
var operador = this.voltar();
|
|
262
266
|
var direito = this.comparar();
|
|
263
267
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -265,17 +269,17 @@ var Parser = /** @class */ (function () {
|
|
|
265
269
|
return expr;
|
|
266
270
|
};
|
|
267
271
|
Parser.prototype.em = function () {
|
|
268
|
-
var expr = this.
|
|
269
|
-
while (this.
|
|
272
|
+
var expr = this.comparacaoIgualdade();
|
|
273
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.EM)) {
|
|
270
274
|
var operador = this.voltar();
|
|
271
|
-
var direito = this.
|
|
275
|
+
var direito = this.comparacaoIgualdade();
|
|
272
276
|
expr = new construtos_1.Logical(expr, operador, direito);
|
|
273
277
|
}
|
|
274
278
|
return expr;
|
|
275
279
|
};
|
|
276
280
|
Parser.prototype.e = function () {
|
|
277
281
|
var expr = this.em();
|
|
278
|
-
while (this.
|
|
282
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.E)) {
|
|
279
283
|
var operador = this.voltar();
|
|
280
284
|
var direito = this.em();
|
|
281
285
|
expr = new construtos_1.Logical(expr, operador, direito);
|
|
@@ -284,7 +288,7 @@ var Parser = /** @class */ (function () {
|
|
|
284
288
|
};
|
|
285
289
|
Parser.prototype.ou = function () {
|
|
286
290
|
var expr = this.e();
|
|
287
|
-
while (this.
|
|
291
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.OU)) {
|
|
288
292
|
var operador = this.voltar();
|
|
289
293
|
var direito = this.e();
|
|
290
294
|
expr = new construtos_1.Logical(expr, operador, direito);
|
|
@@ -293,8 +297,8 @@ var Parser = /** @class */ (function () {
|
|
|
293
297
|
};
|
|
294
298
|
Parser.prototype.atribuir = function () {
|
|
295
299
|
var expr = this.ou();
|
|
296
|
-
if (this.
|
|
297
|
-
this.
|
|
300
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IGUAL) ||
|
|
301
|
+
this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.MAIS_IGUAL)) {
|
|
298
302
|
var igual = this.voltar();
|
|
299
303
|
var valor = this.atribuir();
|
|
300
304
|
if (expr instanceof construtos_1.Variavel) {
|
|
@@ -319,15 +323,13 @@ var Parser = /** @class */ (function () {
|
|
|
319
323
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' antes dos valores em escreva.");
|
|
320
324
|
var valor = this.expressao();
|
|
321
325
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após os valores em escreva.");
|
|
322
|
-
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após o valor.");
|
|
323
326
|
return new declaracoes_1.Escreva(valor);
|
|
324
327
|
};
|
|
325
|
-
Parser.prototype.
|
|
328
|
+
Parser.prototype.declaracaoExpressao = function () {
|
|
326
329
|
var expr = this.expressao();
|
|
327
|
-
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após expressão.");
|
|
328
330
|
return new declaracoes_1.Expressao(expr);
|
|
329
331
|
};
|
|
330
|
-
Parser.prototype.
|
|
332
|
+
Parser.prototype.blocoEscopo = function () {
|
|
331
333
|
var declaracoes = [];
|
|
332
334
|
while (!this.verificar(tiposDeSimbolos_1.default.CHAVE_DIREITA) &&
|
|
333
335
|
!this.estaNoFinal()) {
|
|
@@ -340,80 +342,78 @@ var Parser = /** @class */ (function () {
|
|
|
340
342
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'se'.");
|
|
341
343
|
var condicao = this.expressao();
|
|
342
344
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após condição do se.");
|
|
343
|
-
var thenBranch = this.
|
|
345
|
+
var thenBranch = this.resolverDeclaracao();
|
|
344
346
|
var elifBranches = [];
|
|
345
|
-
while (this.
|
|
347
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SENAOSE)) {
|
|
346
348
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'senaose'.");
|
|
347
349
|
var elifCondition = this.expressao();
|
|
348
350
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' apóes codição do 'senaose.");
|
|
349
|
-
var branch = this.
|
|
351
|
+
var branch = this.resolverDeclaracao();
|
|
350
352
|
elifBranches.push({
|
|
351
353
|
condition: elifCondition,
|
|
352
354
|
branch: branch,
|
|
353
355
|
});
|
|
354
356
|
}
|
|
355
357
|
var elseBranch = null;
|
|
356
|
-
if (this.
|
|
357
|
-
elseBranch = this.
|
|
358
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SENAO)) {
|
|
359
|
+
elseBranch = this.resolverDeclaracao();
|
|
358
360
|
}
|
|
359
361
|
return new declaracoes_1.Se(condicao, thenBranch, elifBranches, elseBranch);
|
|
360
362
|
};
|
|
361
|
-
Parser.prototype.
|
|
363
|
+
Parser.prototype.declaracaoEnquanto = function () {
|
|
362
364
|
try {
|
|
363
365
|
this.ciclos += 1;
|
|
364
366
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'enquanto'.");
|
|
365
367
|
var condicao = this.expressao();
|
|
366
368
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após condicional.");
|
|
367
|
-
var corpo = this.
|
|
369
|
+
var corpo = this.resolverDeclaracao();
|
|
368
370
|
return new declaracoes_1.Enquanto(condicao, corpo);
|
|
369
371
|
}
|
|
370
372
|
finally {
|
|
371
373
|
this.ciclos -= 1;
|
|
372
374
|
}
|
|
373
375
|
};
|
|
374
|
-
Parser.prototype.
|
|
376
|
+
Parser.prototype.declaracaoPara = function () {
|
|
375
377
|
try {
|
|
376
378
|
this.ciclos += 1;
|
|
377
379
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'para'.");
|
|
378
380
|
var inicializador = void 0;
|
|
379
|
-
if (this.
|
|
381
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PONTO_E_VIRGULA)) {
|
|
380
382
|
inicializador = null;
|
|
381
383
|
}
|
|
382
|
-
else if (this.
|
|
384
|
+
else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.VAR)) {
|
|
383
385
|
inicializador = this.declaracaoDeVariavel();
|
|
384
386
|
}
|
|
385
387
|
else {
|
|
386
|
-
inicializador = this.
|
|
388
|
+
inicializador = this.declaracaoExpressao();
|
|
387
389
|
}
|
|
388
390
|
var condicao = null;
|
|
389
391
|
if (!this.verificar(tiposDeSimbolos_1.default.PONTO_E_VIRGULA)) {
|
|
390
392
|
condicao = this.expressao();
|
|
391
393
|
}
|
|
392
|
-
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após valores da condicional");
|
|
393
394
|
var incrementar = null;
|
|
394
395
|
if (!this.verificar(tiposDeSimbolos_1.default.PARENTESE_DIREITO)) {
|
|
395
396
|
incrementar = this.expressao();
|
|
396
397
|
}
|
|
397
398
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após cláusulas");
|
|
398
|
-
var corpo = this.
|
|
399
|
+
var corpo = this.resolverDeclaracao();
|
|
399
400
|
return new declaracoes_1.Para(inicializador, condicao, incrementar, corpo);
|
|
400
401
|
}
|
|
401
402
|
finally {
|
|
402
403
|
this.ciclos -= 1;
|
|
403
404
|
}
|
|
404
405
|
};
|
|
406
|
+
// TODO: Mudar palavra para 'interromper'
|
|
405
407
|
Parser.prototype.breakStatement = function () {
|
|
406
408
|
if (this.ciclos < 1) {
|
|
407
409
|
this.erro(this.voltar(), "'pausa' deve estar dentro de um loop.");
|
|
408
410
|
}
|
|
409
|
-
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após 'pausa'.");
|
|
410
411
|
return new declaracoes_1.Pausa();
|
|
411
412
|
};
|
|
412
|
-
Parser.prototype.
|
|
413
|
+
Parser.prototype.declaracaoContinua = function () {
|
|
413
414
|
if (this.ciclos < 1) {
|
|
414
415
|
this.erro(this.voltar(), "'continua' precisa estar em um laço de repetição.");
|
|
415
416
|
}
|
|
416
|
-
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após 'continua'.");
|
|
417
417
|
return new declaracoes_1.Continua();
|
|
418
418
|
};
|
|
419
419
|
Parser.prototype.declaracaoRetorna = function () {
|
|
@@ -422,7 +422,6 @@ var Parser = /** @class */ (function () {
|
|
|
422
422
|
if (!this.verificar(tiposDeSimbolos_1.default.PONTO_E_VIRGULA)) {
|
|
423
423
|
valor = this.expressao();
|
|
424
424
|
}
|
|
425
|
-
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após o retorno.");
|
|
426
425
|
return new declaracoes_1.Retorna(palavraChave, valor);
|
|
427
426
|
};
|
|
428
427
|
Parser.prototype.declaracaoEscolha = function () {
|
|
@@ -434,9 +433,9 @@ var Parser = /** @class */ (function () {
|
|
|
434
433
|
this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo do 'escolha'.");
|
|
435
434
|
var branches = [];
|
|
436
435
|
var defaultBranch = null;
|
|
437
|
-
while (!this.
|
|
436
|
+
while (!this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_DIREITA) &&
|
|
438
437
|
!this.estaNoFinal()) {
|
|
439
|
-
if (this.
|
|
438
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CASO)) {
|
|
440
439
|
var branchConditions = [this.expressao()];
|
|
441
440
|
this.consumir(tiposDeSimbolos_1.default.DOIS_PONTOS, "Esperado ':' após o 'caso'.");
|
|
442
441
|
while (this.verificar(tiposDeSimbolos_1.default.CASO)) {
|
|
@@ -446,7 +445,7 @@ var Parser = /** @class */ (function () {
|
|
|
446
445
|
}
|
|
447
446
|
var stmts = [];
|
|
448
447
|
do {
|
|
449
|
-
stmts.push(this.
|
|
448
|
+
stmts.push(this.resolverDeclaracao());
|
|
450
449
|
} while (!this.verificar(tiposDeSimbolos_1.default.CASO) &&
|
|
451
450
|
!this.verificar(tiposDeSimbolos_1.default.PADRAO) &&
|
|
452
451
|
!this.verificar(tiposDeSimbolos_1.default.CHAVE_DIREITA));
|
|
@@ -455,13 +454,13 @@ var Parser = /** @class */ (function () {
|
|
|
455
454
|
stmts: stmts,
|
|
456
455
|
});
|
|
457
456
|
}
|
|
458
|
-
else if (this.
|
|
457
|
+
else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PADRAO)) {
|
|
459
458
|
if (defaultBranch !== null)
|
|
460
|
-
throw new
|
|
459
|
+
throw new erros_avaliador_1.ErroAvaliador("Você só pode ter um 'padrao' em cada declaração de 'escolha'.");
|
|
461
460
|
this.consumir(tiposDeSimbolos_1.default.DOIS_PONTOS, "Esperado ':' após declaração do 'padrao'.");
|
|
462
461
|
var stmts = [];
|
|
463
462
|
do {
|
|
464
|
-
stmts.push(this.
|
|
463
|
+
stmts.push(this.resolverDeclaracao());
|
|
465
464
|
} while (!this.verificar(tiposDeSimbolos_1.default.CASO) &&
|
|
466
465
|
!this.verificar(tiposDeSimbolos_1.default.PADRAO) &&
|
|
467
466
|
!this.verificar(tiposDeSimbolos_1.default.CHAVE_DIREITA));
|
|
@@ -476,36 +475,36 @@ var Parser = /** @class */ (function () {
|
|
|
476
475
|
this.ciclos -= 1;
|
|
477
476
|
}
|
|
478
477
|
};
|
|
479
|
-
Parser.prototype.
|
|
478
|
+
Parser.prototype.declaracaoImportar = function () {
|
|
480
479
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração.");
|
|
481
480
|
var caminho = this.expressao();
|
|
482
481
|
var closeBracket = this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após declaração.");
|
|
483
482
|
return new declaracoes_1.Importar(caminho, closeBracket);
|
|
484
483
|
};
|
|
485
|
-
Parser.prototype.
|
|
484
|
+
Parser.prototype.declaracaoTentar = function () {
|
|
486
485
|
this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'tente'.");
|
|
487
|
-
var tryBlock = this.
|
|
486
|
+
var tryBlock = this.blocoEscopo();
|
|
488
487
|
var catchBlock = null;
|
|
489
|
-
if (this.
|
|
488
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PEGUE)) {
|
|
490
489
|
this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
|
|
491
|
-
catchBlock = this.
|
|
490
|
+
catchBlock = this.blocoEscopo();
|
|
492
491
|
}
|
|
493
492
|
var elseBlock = null;
|
|
494
|
-
if (this.
|
|
493
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SENAO)) {
|
|
495
494
|
this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
|
|
496
|
-
elseBlock = this.
|
|
495
|
+
elseBlock = this.blocoEscopo();
|
|
497
496
|
}
|
|
498
497
|
var finallyBlock = null;
|
|
499
|
-
if (this.
|
|
498
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.FINALMENTE)) {
|
|
500
499
|
this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' após a declaração 'pegue'.");
|
|
501
|
-
finallyBlock = this.
|
|
500
|
+
finallyBlock = this.blocoEscopo();
|
|
502
501
|
}
|
|
503
502
|
return new declaracoes_1.Tente(tryBlock, catchBlock, elseBlock, finallyBlock);
|
|
504
503
|
};
|
|
505
|
-
Parser.prototype.
|
|
504
|
+
Parser.prototype.declaracaoFazer = function () {
|
|
506
505
|
try {
|
|
507
506
|
this.ciclos += 1;
|
|
508
|
-
var doBranch = this.
|
|
507
|
+
var doBranch = this.resolverDeclaracao();
|
|
509
508
|
this.consumir(tiposDeSimbolos_1.default.ENQUANTO, "Esperado declaração do 'enquanto' após o escopo do 'fazer'.");
|
|
510
509
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após declaração 'enquanto'.");
|
|
511
510
|
var whileCondition = this.expressao();
|
|
@@ -516,39 +515,38 @@ var Parser = /** @class */ (function () {
|
|
|
516
515
|
this.ciclos -= 1;
|
|
517
516
|
}
|
|
518
517
|
};
|
|
519
|
-
Parser.prototype.
|
|
520
|
-
if (this.
|
|
521
|
-
return this.
|
|
522
|
-
if (this.
|
|
523
|
-
return this.
|
|
524
|
-
if (this.
|
|
518
|
+
Parser.prototype.resolverDeclaracao = function () {
|
|
519
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.FAZER))
|
|
520
|
+
return this.declaracaoFazer();
|
|
521
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.TENTE))
|
|
522
|
+
return this.declaracaoTentar();
|
|
523
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.ESCOLHA))
|
|
525
524
|
return this.declaracaoEscolha();
|
|
526
|
-
if (this.
|
|
525
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.RETORNA))
|
|
527
526
|
return this.declaracaoRetorna();
|
|
528
|
-
if (this.
|
|
529
|
-
return this.
|
|
530
|
-
if (this.
|
|
527
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CONTINUA))
|
|
528
|
+
return this.declaracaoContinua();
|
|
529
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PAUSA))
|
|
531
530
|
return this.breakStatement();
|
|
532
|
-
if (this.
|
|
533
|
-
return this.
|
|
534
|
-
if (this.
|
|
535
|
-
return this.
|
|
536
|
-
if (this.
|
|
531
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PARA))
|
|
532
|
+
return this.declaracaoPara();
|
|
533
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.ENQUANTO))
|
|
534
|
+
return this.declaracaoEnquanto();
|
|
535
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SE))
|
|
537
536
|
return this.declaracaoSe();
|
|
538
|
-
if (this.
|
|
537
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.ESCREVA))
|
|
539
538
|
return this.declaracaoMostrar();
|
|
540
|
-
if (this.
|
|
541
|
-
return new declaracoes_1.Block(this.
|
|
542
|
-
return this.
|
|
539
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_ESQUERDA))
|
|
540
|
+
return new declaracoes_1.Block(this.blocoEscopo());
|
|
541
|
+
return this.declaracaoExpressao();
|
|
543
542
|
};
|
|
544
543
|
Parser.prototype.declaracaoDeVariavel = function () {
|
|
545
544
|
var nome = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome de variável.");
|
|
546
545
|
var inicializador = null;
|
|
547
|
-
if (this.
|
|
548
|
-
this.
|
|
546
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IGUAL) ||
|
|
547
|
+
this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.MAIS_IGUAL)) {
|
|
549
548
|
inicializador = this.expressao();
|
|
550
549
|
}
|
|
551
|
-
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após a declaração da variável.");
|
|
552
550
|
return new declaracoes_1.Var(nome, inicializador);
|
|
553
551
|
};
|
|
554
552
|
Parser.prototype.funcao = function (kind) {
|
|
@@ -561,10 +559,10 @@ var Parser = /** @class */ (function () {
|
|
|
561
559
|
if (!this.verificar(tiposDeSimbolos_1.default.PARENTESE_DIREITO)) {
|
|
562
560
|
do {
|
|
563
561
|
if (parametros.length >= 255) {
|
|
564
|
-
this.erro(this.
|
|
562
|
+
this.erro(this.simboloAtual(), "Não pode haver mais de 255 parâmetros");
|
|
565
563
|
}
|
|
566
564
|
var paramObj = {};
|
|
567
|
-
if (this.
|
|
565
|
+
if (this.simboloAtual().tipo === tiposDeSimbolos_1.default.MULTIPLICACAO) {
|
|
568
566
|
this.consumir(tiposDeSimbolos_1.default.MULTIPLICACAO, null);
|
|
569
567
|
paramObj["tipo"] = "wildcard";
|
|
570
568
|
}
|
|
@@ -572,23 +570,23 @@ var Parser = /** @class */ (function () {
|
|
|
572
570
|
paramObj["tipo"] = "standard";
|
|
573
571
|
}
|
|
574
572
|
paramObj["nome"] = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome do parâmetro.");
|
|
575
|
-
if (this.
|
|
573
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IGUAL)) {
|
|
576
574
|
paramObj["default"] = this.primario();
|
|
577
575
|
}
|
|
578
576
|
parametros.push(paramObj);
|
|
579
577
|
if (paramObj["tipo"] === "wildcard")
|
|
580
578
|
break;
|
|
581
|
-
} while (this.
|
|
579
|
+
} while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COMMA));
|
|
582
580
|
}
|
|
583
581
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após parâmetros.");
|
|
584
582
|
this.consumir(tiposDeSimbolos_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo do ".concat(kind, "."));
|
|
585
|
-
var corpo = this.
|
|
583
|
+
var corpo = this.blocoEscopo();
|
|
586
584
|
return new declaracoes_1.Funcao(parametros, corpo);
|
|
587
585
|
};
|
|
588
586
|
Parser.prototype.declaracaoDeClasse = function () {
|
|
589
587
|
var nome = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome da classe.");
|
|
590
588
|
var superClasse = null;
|
|
591
|
-
if (this.
|
|
589
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.HERDA)) {
|
|
592
590
|
this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome da SuperClasse.");
|
|
593
591
|
superClasse = new construtos_1.Variavel(this.voltar());
|
|
594
592
|
}
|
|
@@ -608,11 +606,11 @@ var Parser = /** @class */ (function () {
|
|
|
608
606
|
this.consumir(tiposDeSimbolos_1.default.FUNCAO, null);
|
|
609
607
|
return this.funcao("funcao");
|
|
610
608
|
}
|
|
611
|
-
if (this.
|
|
609
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.VAR))
|
|
612
610
|
return this.declaracaoDeVariavel();
|
|
613
|
-
if (this.
|
|
611
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CLASSE))
|
|
614
612
|
return this.declaracaoDeClasse();
|
|
615
|
-
return this.
|
|
613
|
+
return this.resolverDeclaracao();
|
|
616
614
|
}
|
|
617
615
|
catch (erro) {
|
|
618
616
|
this.sincronizar();
|
|
@@ -620,6 +618,8 @@ var Parser = /** @class */ (function () {
|
|
|
620
618
|
}
|
|
621
619
|
};
|
|
622
620
|
Parser.prototype.analisar = function (simbolos) {
|
|
621
|
+
this.atual = 0;
|
|
622
|
+
this.ciclos = 0;
|
|
623
623
|
if (simbolos) {
|
|
624
624
|
this.simbolos = simbolos;
|
|
625
625
|
}
|