@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
package/bin/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designliquido/delegua",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Linguagem de programação simples e moderna usando português",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"empacotar": "rm -Rf ./dist && tsc && copyfiles -V ./bin/delegua ./bin/delegua.cmd ./dist && copyfiles -V ./package.json ./dist/bin && copyfiles -V ./README.md ./dist",
|
|
8
|
-
"npm
|
|
8
|
+
"publicar-npm": "npm publish --access public",
|
|
9
9
|
"testes": "./bin/delegua-ts testes/testes.egua",
|
|
10
|
+
"testes:egua-classico": "./bin/delegua-ts testes/dialetos/egua-classico/testes.egua",
|
|
10
11
|
"testes-unitarios": "jest",
|
|
11
12
|
"release": "release-it"
|
|
12
13
|
},
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designliquido/delegua",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Linguagem de programação simples e moderna usando português",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"empacotar": "rm -Rf ./dist && tsc && copyfiles -V ./bin/delegua ./bin/delegua.cmd ./dist && copyfiles -V ./package.json ./dist/bin && copyfiles -V ./README.md ./dist",
|
|
8
|
-
"npm
|
|
8
|
+
"publicar-npm": "npm publish --access public",
|
|
9
9
|
"testes": "./bin/delegua-ts testes/testes.egua",
|
|
10
10
|
"testes:egua-classico": "./bin/delegua-ts testes/dialetos/egua-classico/testes.egua",
|
|
11
11
|
"testes-unitarios": "jest",
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ParserEguaClassico = 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 ParserEguaClassico = /** @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 ParserEguaClassico = /** @class */ (function () {
|
|
|
37
37
|
};
|
|
38
38
|
ParserEguaClassico.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
|
ParserEguaClassico.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
|
ParserEguaClassico.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
|
ParserEguaClassico.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
|
-
ParserEguaClassico.prototype.
|
|
58
|
+
ParserEguaClassico.prototype.simboloAtual = function () {
|
|
59
59
|
return this.simbolos[this.atual];
|
|
60
60
|
};
|
|
61
61
|
ParserEguaClassico.prototype.voltar = function () {
|
|
@@ -65,14 +65,14 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
65
65
|
return this.simbolos[this.atual + posicao];
|
|
66
66
|
};
|
|
67
67
|
ParserEguaClassico.prototype.estaNoFinal = function () {
|
|
68
|
-
return this.
|
|
68
|
+
return this.simboloAtual().tipo === tiposDeSimbolos_1.default.EOF;
|
|
69
69
|
};
|
|
70
70
|
ParserEguaClassico.prototype.avancar = function () {
|
|
71
71
|
if (!this.estaNoFinal())
|
|
72
72
|
this.atual += 1;
|
|
73
73
|
return this.voltar();
|
|
74
74
|
};
|
|
75
|
-
ParserEguaClassico.prototype.
|
|
75
|
+
ParserEguaClassico.prototype.verificarSeSimboloAtualEIgualA = function () {
|
|
76
76
|
var argumentos = [];
|
|
77
77
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
78
78
|
argumentos[_i] = arguments[_i];
|
|
@@ -87,78 +87,78 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
87
87
|
return false;
|
|
88
88
|
};
|
|
89
89
|
ParserEguaClassico.prototype.primario = function () {
|
|
90
|
-
if (this.
|
|
90
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SUPER)) {
|
|
91
91
|
var palavraChave = this.voltar();
|
|
92
|
-
this.consumir(tiposDeSimbolos_1.default.
|
|
92
|
+
this.consumir(tiposDeSimbolos_1.default.PONTO, "Esperado '.' após 'super'.");
|
|
93
93
|
var metodo = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome do método da SuperClasse.");
|
|
94
94
|
return new construtos_1.Super(palavraChave, metodo);
|
|
95
95
|
}
|
|
96
|
-
if (this.
|
|
96
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_ESQUERDO)) {
|
|
97
97
|
var valores = [];
|
|
98
|
-
if (this.
|
|
98
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_DIREITO)) {
|
|
99
99
|
return new construtos_1.Vetor([]);
|
|
100
100
|
}
|
|
101
|
-
while (!this.
|
|
101
|
+
while (!this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_DIREITO)) {
|
|
102
102
|
var valor = this.atribuir();
|
|
103
103
|
valores.push(valor);
|
|
104
|
-
if (this.
|
|
104
|
+
if (this.simboloAtual().tipo !== tiposDeSimbolos_1.default.COLCHETE_DIREITO) {
|
|
105
105
|
this.consumir(tiposDeSimbolos_1.default.COMMA, "Esperado vírgula antes da próxima expressão.");
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
return new construtos_1.Vetor(valores);
|
|
109
109
|
}
|
|
110
|
-
if (this.
|
|
110
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_ESQUERDA)) {
|
|
111
111
|
var chaves = [];
|
|
112
112
|
var valores = [];
|
|
113
|
-
if (this.
|
|
113
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_DIREITA)) {
|
|
114
114
|
return new construtos_1.Dicionario([], []);
|
|
115
115
|
}
|
|
116
|
-
while (!this.
|
|
116
|
+
while (!this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.CHAVE_DIREITA)) {
|
|
117
117
|
var chave = this.atribuir();
|
|
118
118
|
this.consumir(tiposDeSimbolos_1.default.DOIS_PONTOS, "Esperado ':' entre chave e valor.");
|
|
119
119
|
var valor = this.atribuir();
|
|
120
120
|
chaves.push(chave);
|
|
121
121
|
valores.push(valor);
|
|
122
|
-
if (this.
|
|
122
|
+
if (this.simboloAtual().tipo !== tiposDeSimbolos_1.default.CHAVE_DIREITA) {
|
|
123
123
|
this.consumir(tiposDeSimbolos_1.default.COMMA, "Esperado vírgula antes da próxima expressão.");
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
return new construtos_1.Dicionario(chaves, valores);
|
|
127
127
|
}
|
|
128
|
-
if (this.
|
|
128
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.FUNCAO))
|
|
129
129
|
return this.corpoDaFuncao("funcao");
|
|
130
|
-
if (this.
|
|
130
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.FALSO))
|
|
131
131
|
return new construtos_1.Literal(false);
|
|
132
|
-
if (this.
|
|
132
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.VERDADEIRO))
|
|
133
133
|
return new construtos_1.Literal(true);
|
|
134
|
-
if (this.
|
|
134
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.NULO))
|
|
135
135
|
return new construtos_1.Literal(null);
|
|
136
|
-
if (this.
|
|
136
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.ISTO))
|
|
137
137
|
return new construtos_1.Isto(this.voltar());
|
|
138
|
-
if (this.
|
|
138
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.NUMERO, tiposDeSimbolos_1.default.TEXTO)) {
|
|
139
139
|
return new construtos_1.Literal(this.voltar().literal);
|
|
140
140
|
}
|
|
141
|
-
if (this.
|
|
141
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IDENTIFICADOR)) {
|
|
142
142
|
return new construtos_1.Variavel(this.voltar());
|
|
143
143
|
}
|
|
144
|
-
if (this.
|
|
144
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO)) {
|
|
145
145
|
var expr = this.expressao();
|
|
146
146
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após a expressão.");
|
|
147
147
|
return new construtos_1.Grouping(expr);
|
|
148
148
|
}
|
|
149
|
-
if (this.
|
|
150
|
-
return this.
|
|
151
|
-
throw this.erro(this.
|
|
149
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IMPORTAR))
|
|
150
|
+
return this.declaracaoImportar();
|
|
151
|
+
throw this.erro(this.simboloAtual(), "Esperado expressão.");
|
|
152
152
|
};
|
|
153
153
|
ParserEguaClassico.prototype.finalizarChamada = function (callee) {
|
|
154
154
|
var argumentos = [];
|
|
155
155
|
if (!this.verificar(tiposDeSimbolos_1.default.PARENTESE_DIREITO)) {
|
|
156
156
|
do {
|
|
157
157
|
if (argumentos.length >= 255) {
|
|
158
|
-
throw this.erro(this.
|
|
158
|
+
throw this.erro(this.simboloAtual(), "Não pode haver mais de 255 argumentos.");
|
|
159
159
|
}
|
|
160
160
|
argumentos.push(this.expressao());
|
|
161
|
-
} while (this.
|
|
161
|
+
} while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COMMA));
|
|
162
162
|
}
|
|
163
163
|
var parenteseDireito = this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após os argumentos.");
|
|
164
164
|
return new construtos_1.Call(callee, parenteseDireito, argumentos);
|
|
@@ -166,14 +166,14 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
166
166
|
ParserEguaClassico.prototype.chamar = function () {
|
|
167
167
|
var expr = this.primario();
|
|
168
168
|
while (true) {
|
|
169
|
-
if (this.
|
|
169
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO)) {
|
|
170
170
|
expr = this.finalizarChamada(expr);
|
|
171
171
|
}
|
|
172
|
-
else if (this.
|
|
172
|
+
else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PONTO)) {
|
|
173
173
|
var nome = this.consumir(tiposDeSimbolos_1.default.IDENTIFICADOR, "Esperado nome do método após '.'.");
|
|
174
174
|
expr = new construtos_1.Get(expr, nome);
|
|
175
175
|
}
|
|
176
|
-
else if (this.
|
|
176
|
+
else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.COLCHETE_ESQUERDO)) {
|
|
177
177
|
var indice = this.expressao();
|
|
178
178
|
var closeBracket = this.consumir(tiposDeSimbolos_1.default.COLCHETE_DIREITO, "Esperado ']' após escrita do indice.");
|
|
179
179
|
expr = new construtos_1.Subscript(expr, indice, closeBracket);
|
|
@@ -185,16 +185,16 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
185
185
|
return expr;
|
|
186
186
|
};
|
|
187
187
|
ParserEguaClassico.prototype.unario = function () {
|
|
188
|
-
if (this.
|
|
188
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.NEGACAO, tiposDeSimbolos_1.default.SUBTRACAO, tiposDeSimbolos_1.default.BIT_NOT)) {
|
|
189
189
|
var operador = this.voltar();
|
|
190
190
|
var direito = this.unario();
|
|
191
191
|
return new construtos_1.Unario(operador, direito);
|
|
192
192
|
}
|
|
193
193
|
return this.chamar();
|
|
194
194
|
};
|
|
195
|
-
ParserEguaClassico.prototype.
|
|
195
|
+
ParserEguaClassico.prototype.exponenciacao = function () {
|
|
196
196
|
var expr = this.unario();
|
|
197
|
-
while (this.
|
|
197
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.EXPONENCIACAO)) {
|
|
198
198
|
var operador = this.voltar();
|
|
199
199
|
var direito = this.unario();
|
|
200
200
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -202,17 +202,17 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
202
202
|
return expr;
|
|
203
203
|
};
|
|
204
204
|
ParserEguaClassico.prototype.multiplicar = function () {
|
|
205
|
-
var expr = this.
|
|
206
|
-
while (this.
|
|
205
|
+
var expr = this.exponenciacao();
|
|
206
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.DIVISAO, tiposDeSimbolos_1.default.MULTIPLICACAO, tiposDeSimbolos_1.default.MODULO)) {
|
|
207
207
|
var operador = this.voltar();
|
|
208
|
-
var direito = this.
|
|
208
|
+
var direito = this.exponenciacao();
|
|
209
209
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
210
210
|
}
|
|
211
211
|
return expr;
|
|
212
212
|
};
|
|
213
213
|
ParserEguaClassico.prototype.adicionar = function () {
|
|
214
214
|
var expr = this.multiplicar();
|
|
215
|
-
while (this.
|
|
215
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SUBTRACAO, tiposDeSimbolos_1.default.ADICAO)) {
|
|
216
216
|
var operador = this.voltar();
|
|
217
217
|
var direito = this.multiplicar();
|
|
218
218
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -221,7 +221,7 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
221
221
|
};
|
|
222
222
|
ParserEguaClassico.prototype.bitFill = function () {
|
|
223
223
|
var expr = this.adicionar();
|
|
224
|
-
while (this.
|
|
224
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.MENOR_MENOR, tiposDeSimbolos_1.default.MAIOR_MAIOR)) {
|
|
225
225
|
var operador = this.voltar();
|
|
226
226
|
var direito = this.adicionar();
|
|
227
227
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -230,7 +230,7 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
230
230
|
};
|
|
231
231
|
ParserEguaClassico.prototype.bitE = function () {
|
|
232
232
|
var expr = this.bitFill();
|
|
233
|
-
while (this.
|
|
233
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.BIT_AND)) {
|
|
234
234
|
var operador = this.voltar();
|
|
235
235
|
var direito = this.bitFill();
|
|
236
236
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -239,7 +239,7 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
239
239
|
};
|
|
240
240
|
ParserEguaClassico.prototype.bitOu = function () {
|
|
241
241
|
var expr = this.bitE();
|
|
242
|
-
while (this.
|
|
242
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.BIT_OR, tiposDeSimbolos_1.default.BIT_XOR)) {
|
|
243
243
|
var operador = this.voltar();
|
|
244
244
|
var direito = this.bitE();
|
|
245
245
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -248,16 +248,16 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
248
248
|
};
|
|
249
249
|
ParserEguaClassico.prototype.comparar = function () {
|
|
250
250
|
var expr = this.bitOu();
|
|
251
|
-
while (this.
|
|
251
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.MAIOR, tiposDeSimbolos_1.default.MAIOR_IGUAL, tiposDeSimbolos_1.default.MENOR, tiposDeSimbolos_1.default.MENOR_IGUAL)) {
|
|
252
252
|
var operador = this.voltar();
|
|
253
253
|
var direito = this.bitOu();
|
|
254
254
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
255
255
|
}
|
|
256
256
|
return expr;
|
|
257
257
|
};
|
|
258
|
-
ParserEguaClassico.prototype.
|
|
258
|
+
ParserEguaClassico.prototype.comparacaoIgualdade = function () {
|
|
259
259
|
var expr = this.comparar();
|
|
260
|
-
while (this.
|
|
260
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.DIFERENTE, tiposDeSimbolos_1.default.IGUAL_IGUAL)) {
|
|
261
261
|
var operador = this.voltar();
|
|
262
262
|
var direito = this.comparar();
|
|
263
263
|
expr = new construtos_1.Binario(expr, operador, direito);
|
|
@@ -265,17 +265,17 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
265
265
|
return expr;
|
|
266
266
|
};
|
|
267
267
|
ParserEguaClassico.prototype.em = function () {
|
|
268
|
-
var expr = this.
|
|
269
|
-
while (this.
|
|
268
|
+
var expr = this.comparacaoIgualdade();
|
|
269
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.EM)) {
|
|
270
270
|
var operador = this.voltar();
|
|
271
|
-
var direito = this.
|
|
271
|
+
var direito = this.comparacaoIgualdade();
|
|
272
272
|
expr = new construtos_1.Logical(expr, operador, direito);
|
|
273
273
|
}
|
|
274
274
|
return expr;
|
|
275
275
|
};
|
|
276
276
|
ParserEguaClassico.prototype.e = function () {
|
|
277
277
|
var expr = this.em();
|
|
278
|
-
while (this.
|
|
278
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.E)) {
|
|
279
279
|
var operador = this.voltar();
|
|
280
280
|
var direito = this.em();
|
|
281
281
|
expr = new construtos_1.Logical(expr, operador, direito);
|
|
@@ -284,7 +284,7 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
284
284
|
};
|
|
285
285
|
ParserEguaClassico.prototype.ou = function () {
|
|
286
286
|
var expr = this.e();
|
|
287
|
-
while (this.
|
|
287
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.OU)) {
|
|
288
288
|
var operador = this.voltar();
|
|
289
289
|
var direito = this.e();
|
|
290
290
|
expr = new construtos_1.Logical(expr, operador, direito);
|
|
@@ -293,8 +293,7 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
293
293
|
};
|
|
294
294
|
ParserEguaClassico.prototype.atribuir = function () {
|
|
295
295
|
var expr = this.ou();
|
|
296
|
-
if (this.
|
|
297
|
-
this.match(tiposDeSimbolos_1.default.MAIS_IGUAL)) {
|
|
296
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IGUAL)) {
|
|
298
297
|
var igual = this.voltar();
|
|
299
298
|
var valor = this.atribuir();
|
|
300
299
|
if (expr instanceof construtos_1.Variavel) {
|
|
@@ -322,12 +321,12 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
322
321
|
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após o valor.");
|
|
323
322
|
return new declaracoes_1.Escreva(valor);
|
|
324
323
|
};
|
|
325
|
-
ParserEguaClassico.prototype.
|
|
324
|
+
ParserEguaClassico.prototype.declaracaoExpressao = function () {
|
|
326
325
|
var expr = this.expressao();
|
|
327
326
|
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após expressão.");
|
|
328
327
|
return new declaracoes_1.Expressao(expr);
|
|
329
328
|
};
|
|
330
|
-
ParserEguaClassico.prototype.
|
|
329
|
+
ParserEguaClassico.prototype.blocoEscopo = function () {
|
|
331
330
|
var declaracoes = [];
|
|
332
331
|
while (!this.verificar(tiposDeSimbolos_1.default.CHAVE_DIREITA) &&
|
|
333
332
|
!this.estaNoFinal()) {
|
|
@@ -340,50 +339,50 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
340
339
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'se'.");
|
|
341
340
|
var condicao = this.expressao();
|
|
342
341
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após condição do se.");
|
|
343
|
-
var thenBranch = this.
|
|
342
|
+
var thenBranch = this.resolverDeclaracao();
|
|
344
343
|
var elifBranches = [];
|
|
345
|
-
while (this.
|
|
344
|
+
while (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SENAOSE)) {
|
|
346
345
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'senaose'.");
|
|
347
346
|
var elifCondition = this.expressao();
|
|
348
347
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' apóes codição do 'senaose.");
|
|
349
|
-
var branch = this.
|
|
348
|
+
var branch = this.resolverDeclaracao();
|
|
350
349
|
elifBranches.push({
|
|
351
350
|
condition: elifCondition,
|
|
352
351
|
branch: branch,
|
|
353
352
|
});
|
|
354
353
|
}
|
|
355
354
|
var elseBranch = null;
|
|
356
|
-
if (this.
|
|
357
|
-
elseBranch = this.
|
|
355
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.SENAO)) {
|
|
356
|
+
elseBranch = this.resolverDeclaracao();
|
|
358
357
|
}
|
|
359
358
|
return new declaracoes_1.Se(condicao, thenBranch, elifBranches, elseBranch);
|
|
360
359
|
};
|
|
361
|
-
ParserEguaClassico.prototype.
|
|
360
|
+
ParserEguaClassico.prototype.declaracaoEnquanto = function () {
|
|
362
361
|
try {
|
|
363
362
|
this.ciclos += 1;
|
|
364
363
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'enquanto'.");
|
|
365
364
|
var condicao = this.expressao();
|
|
366
365
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após condicional.");
|
|
367
|
-
var corpo = this.
|
|
366
|
+
var corpo = this.resolverDeclaracao();
|
|
368
367
|
return new declaracoes_1.Enquanto(condicao, corpo);
|
|
369
368
|
}
|
|
370
369
|
finally {
|
|
371
370
|
this.ciclos -= 1;
|
|
372
371
|
}
|
|
373
372
|
};
|
|
374
|
-
ParserEguaClassico.prototype.
|
|
373
|
+
ParserEguaClassico.prototype.declaracaoPara = function () {
|
|
375
374
|
try {
|
|
376
375
|
this.ciclos += 1;
|
|
377
376
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_ESQUERDO, "Esperado '(' após 'para'.");
|
|
378
377
|
var inicializador = void 0;
|
|
379
|
-
if (this.
|
|
378
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.PONTO_E_VIRGULA)) {
|
|
380
379
|
inicializador = null;
|
|
381
380
|
}
|
|
382
|
-
else if (this.
|
|
381
|
+
else if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.VAR)) {
|
|
383
382
|
inicializador = this.declaracaoDeVariavel();
|
|
384
383
|
}
|
|
385
384
|
else {
|
|
386
|
-
inicializador = this.
|
|
385
|
+
inicializador = this.declaracaoExpressao();
|
|
387
386
|
}
|
|
388
387
|
var condicao = null;
|
|
389
388
|
if (!this.verificar(tiposDeSimbolos_1.default.PONTO_E_VIRGULA)) {
|
|
@@ -395,7 +394,7 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
395
394
|
incrementar = this.expressao();
|
|
396
395
|
}
|
|
397
396
|
this.consumir(tiposDeSimbolos_1.default.PARENTESE_DIREITO, "Esperado ')' após cláusulas");
|
|
398
|
-
var corpo = this.
|
|
397
|
+
var corpo = this.resolverDeclaracao();
|
|
399
398
|
return new declaracoes_1.Para(inicializador, condicao, incrementar, corpo);
|
|
400
399
|
}
|
|
401
400
|
finally {
|
|
@@ -409,7 +408,7 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
409
408
|
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após 'pausa'.");
|
|
410
409
|
return new declaracoes_1.Pausa();
|
|
411
410
|
};
|
|
412
|
-
ParserEguaClassico.prototype.
|
|
411
|
+
ParserEguaClassico.prototype.declaracaoContinua = function () {
|
|
413
412
|
if (this.ciclos < 1) {
|
|
414
413
|
this.erro(this.voltar(), "'continua' precisa estar em um laço de repetição.");
|
|
415
414
|
}
|
|
@@ -434,9 +433,9 @@ var ParserEguaClassico = /** @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 ParserEguaClassico = /** @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 ParserEguaClassico = /** @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 ParserEguaClassico = /** @class */ (function () {
|
|
|
476
475
|
this.ciclos -= 1;
|
|
477
476
|
}
|
|
478
477
|
};
|
|
479
|
-
ParserEguaClassico.prototype.
|
|
478
|
+
ParserEguaClassico.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
|
-
ParserEguaClassico.prototype.
|
|
484
|
+
ParserEguaClassico.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
|
-
ParserEguaClassico.prototype.
|
|
504
|
+
ParserEguaClassico.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,36 +515,35 @@ var ParserEguaClassico = /** @class */ (function () {
|
|
|
516
515
|
this.ciclos -= 1;
|
|
517
516
|
}
|
|
518
517
|
};
|
|
519
|
-
ParserEguaClassico.prototype.
|
|
520
|
-
if (this.
|
|
521
|
-
return this.
|
|
522
|
-
if (this.
|
|
523
|
-
return this.
|
|
524
|
-
if (this.
|
|
518
|
+
ParserEguaClassico.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
|
ParserEguaClassico.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.match(tiposDeSimbolos_1.default.MAIS_IGUAL)) {
|
|
546
|
+
if (this.verificarSeSimboloAtualEIgualA(tiposDeSimbolos_1.default.IGUAL)) {
|
|
549
547
|
inicializador = this.expressao();
|
|
550
548
|
}
|
|
551
549
|
this.consumir(tiposDeSimbolos_1.default.PONTO_E_VIRGULA, "Esperado ';' após a declaração da variável.");
|
|
@@ -561,10 +559,10 @@ var ParserEguaClassico = /** @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 ParserEguaClassico = /** @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
|
ParserEguaClassico.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 ParserEguaClassico = /** @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 ParserEguaClassico = /** @class */ (function () {
|
|
|
620
618
|
}
|
|
621
619
|
};
|
|
622
620
|
ParserEguaClassico.prototype.analisar = function (simbolos) {
|
|
621
|
+
this.atual = 0;
|
|
622
|
+
this.ciclos = 0;
|
|
623
623
|
if (simbolos) {
|
|
624
624
|
this.simbolos = simbolos;
|
|
625
625
|
}
|