@designliquido/delegua 0.1.5 → 0.1.9

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