@designliquido/delegua 0.1.4 → 0.1.8

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