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