@designliquido/delegua 0.2.1 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/package.json +2 -1
- package/{src → fontes}/ambiente.d.ts +4 -3
- package/{src → fontes}/ambiente.js +7 -7
- package/fontes/ambiente.js.map +1 -0
- package/fontes/avaliador-sintatico/dialetos/egua-classico.d.ts +63 -0
- package/fontes/avaliador-sintatico/dialetos/egua-classico.js +646 -0
- package/fontes/avaliador-sintatico/dialetos/egua-classico.js.map +1 -0
- package/{src → fontes}/avaliador-sintatico/dialetos/index.d.ts +0 -0
- package/{src → fontes}/avaliador-sintatico/dialetos/index.js +0 -0
- package/fontes/avaliador-sintatico/dialetos/index.js.map +1 -0
- package/fontes/avaliador-sintatico/erro-avaliador-sintatico.d.ts +5 -0
- package/fontes/avaliador-sintatico/erro-avaliador-sintatico.js +30 -0
- package/fontes/avaliador-sintatico/erro-avaliador-sintatico.js.map +1 -0
- package/fontes/avaliador-sintatico/index.d.ts +66 -0
- package/fontes/avaliador-sintatico/index.js +663 -0
- package/fontes/avaliador-sintatico/index.js.map +1 -0
- package/fontes/avaliador-sintatico/retorno-avaliador-sintatico.d.ts +6 -0
- package/fontes/avaliador-sintatico/retorno-avaliador-sintatico.js +3 -0
- package/fontes/avaliador-sintatico/retorno-avaliador-sintatico.js.map +1 -0
- package/{src → fontes}/bibliotecas/biblioteca-global.d.ts +0 -0
- package/{src → fontes}/bibliotecas/biblioteca-global.js +4 -4
- package/fontes/bibliotecas/biblioteca-global.js.map +1 -0
- package/{src → fontes}/bibliotecas/importar-biblioteca.d.ts +0 -0
- package/{src → fontes}/bibliotecas/importar-biblioteca.js +0 -0
- package/fontes/bibliotecas/importar-biblioteca.js.map +1 -0
- package/fontes/construtos/acesso-indice-variavel.d.ts +13 -0
- package/fontes/construtos/acesso-indice-variavel.js +21 -0
- package/fontes/construtos/acesso-indice-variavel.js.map +1 -0
- package/fontes/construtos/acesso-metodo.d.ts +13 -0
- package/fontes/construtos/acesso-metodo.js +20 -0
- package/fontes/construtos/acesso-metodo.js.map +1 -0
- package/fontes/construtos/agrupamento.d.ts +7 -0
- package/fontes/construtos/agrupamento.js +15 -0
- package/fontes/construtos/agrupamento.js.map +1 -0
- package/{src → fontes}/construtos/atribuicao-sobrescrita.d.ts +2 -1
- package/{src → fontes}/construtos/atribuicao-sobrescrita.js +2 -1
- package/fontes/construtos/atribuicao-sobrescrita.js.map +1 -0
- package/fontes/construtos/atribuir.d.ts +9 -0
- package/{src → fontes}/construtos/atribuir.js +3 -2
- package/fontes/construtos/atribuir.js.map +1 -0
- package/{src → fontes}/construtos/binario.d.ts +1 -0
- package/{src → fontes}/construtos/binario.js +1 -0
- package/fontes/construtos/binario.js.map +1 -0
- package/{src → fontes}/construtos/chamada.d.ts +3 -2
- package/{src → fontes}/construtos/chamada.js +1 -0
- package/fontes/construtos/chamada.js.map +1 -0
- package/{src → fontes}/construtos/conjunto.d.ts +2 -1
- package/{src → fontes}/construtos/conjunto.js +2 -1
- package/fontes/construtos/conjunto.js.map +1 -0
- package/{src → fontes}/construtos/construto.d.ts +1 -0
- package/{src → fontes}/construtos/construto.js +0 -0
- package/fontes/construtos/construto.js.map +1 -0
- package/{src → fontes}/construtos/dicionario.d.ts +2 -1
- package/{src → fontes}/construtos/dicionario.js +2 -1
- package/fontes/construtos/dicionario.js.map +1 -0
- package/{src → fontes}/construtos/funcao.d.ts +2 -1
- package/{src → fontes}/construtos/funcao.js +2 -1
- package/fontes/construtos/funcao.js.map +1 -0
- package/{src → fontes}/construtos/index.d.ts +4 -4
- package/{src → fontes}/construtos/index.js +4 -4
- package/fontes/construtos/index.js.map +1 -0
- package/{src → fontes}/construtos/isto.d.ts +2 -1
- package/{src → fontes}/construtos/isto.js +2 -1
- package/fontes/construtos/isto.js.map +1 -0
- package/{src → fontes}/construtos/literal.d.ts +2 -1
- package/{src → fontes}/construtos/literal.js +2 -1
- package/fontes/construtos/literal.js.map +1 -0
- package/{src/construtos/logical.d.ts → fontes/construtos/logico.d.ts} +2 -1
- package/fontes/construtos/logico.js +17 -0
- package/fontes/construtos/logico.js.map +1 -0
- package/{src → fontes}/construtos/super.d.ts +2 -1
- package/{src → fontes}/construtos/super.js +2 -1
- package/fontes/construtos/super.js.map +1 -0
- package/{src → fontes}/construtos/unario.d.ts +1 -0
- package/{src → fontes}/construtos/unario.js +1 -0
- package/fontes/construtos/unario.js.map +1 -0
- package/fontes/construtos/variavel.d.ts +8 -0
- package/{src → fontes}/construtos/variavel.js +3 -2
- package/fontes/construtos/variavel.js.map +1 -0
- package/{src → fontes}/construtos/vetor.d.ts +2 -1
- package/{src → fontes}/construtos/vetor.js +2 -1
- package/fontes/construtos/vetor.js.map +1 -0
- package/{src → fontes}/declaracoes/bloco.d.ts +0 -0
- package/{src → fontes}/declaracoes/bloco.js +1 -1
- package/fontes/declaracoes/bloco.js.map +1 -0
- package/{src → fontes}/declaracoes/classe.d.ts +3 -2
- package/{src → fontes}/declaracoes/classe.js +3 -3
- package/fontes/declaracoes/classe.js.map +1 -0
- package/{src → fontes}/declaracoes/continua.d.ts +0 -0
- package/{src → fontes}/declaracoes/continua.js +1 -1
- package/fontes/declaracoes/continua.js.map +1 -0
- package/{src → fontes}/declaracoes/declaracao.d.ts +2 -0
- package/{src → fontes}/declaracoes/declaracao.js +2 -1
- package/fontes/declaracoes/declaracao.js.map +1 -0
- package/{src → fontes}/declaracoes/enquanto.d.ts +0 -0
- package/{src → fontes}/declaracoes/enquanto.js +1 -1
- package/fontes/declaracoes/enquanto.js.map +1 -0
- package/{src → fontes}/declaracoes/escolha.d.ts +3 -3
- package/{src → fontes}/declaracoes/escolha.js +4 -4
- package/fontes/declaracoes/escolha.js.map +1 -0
- package/{src → fontes}/declaracoes/escreva.d.ts +0 -0
- package/{src → fontes}/declaracoes/escreva.js +1 -1
- package/fontes/declaracoes/escreva.js.map +1 -0
- package/{src → fontes}/declaracoes/expressao.d.ts +3 -2
- package/{src → fontes}/declaracoes/expressao.js +1 -1
- package/fontes/declaracoes/expressao.js.map +1 -0
- package/{src → fontes}/declaracoes/fazer.d.ts +3 -3
- package/{src → fontes}/declaracoes/fazer.js +4 -4
- package/fontes/declaracoes/fazer.js.map +1 -0
- package/fontes/declaracoes/funcao.d.ts +8 -0
- package/{src → fontes}/declaracoes/funcao.js +3 -3
- package/fontes/declaracoes/funcao.js.map +1 -0
- package/fontes/declaracoes/importar.d.ts +8 -0
- package/{src → fontes}/declaracoes/importar.js +3 -3
- package/fontes/declaracoes/importar.js.map +1 -0
- package/{src → fontes}/declaracoes/index.d.ts +1 -1
- package/{src → fontes}/declaracoes/index.js +1 -1
- package/fontes/declaracoes/index.js.map +1 -0
- package/{src → fontes}/declaracoes/para.d.ts +1 -1
- package/{src → fontes}/declaracoes/para.js +2 -2
- package/fontes/declaracoes/para.js.map +1 -0
- package/{src → fontes}/declaracoes/retorna.d.ts +0 -0
- package/{src → fontes}/declaracoes/retorna.js +1 -1
- package/fontes/declaracoes/retorna.js.map +1 -0
- package/fontes/declaracoes/se.d.ts +9 -0
- package/{src → fontes}/declaracoes/se.js +5 -5
- package/fontes/declaracoes/se.js.map +1 -0
- package/{src/declaracoes/pausa.d.ts → fontes/declaracoes/sustar.d.ts} +1 -1
- package/{src/declaracoes/pausa.js → fontes/declaracoes/sustar.js} +10 -10
- package/fontes/declaracoes/sustar.js.map +1 -0
- package/fontes/declaracoes/tente.d.ts +9 -0
- package/{src → fontes}/declaracoes/tente.js +6 -6
- package/fontes/declaracoes/tente.js.map +1 -0
- package/fontes/declaracoes/var.d.ts +8 -0
- package/{src → fontes}/declaracoes/var.js +3 -3
- package/fontes/declaracoes/var.js.map +1 -0
- package/{src → fontes}/delegua.d.ts +7 -8
- package/fontes/delegua.js +180 -0
- package/fontes/delegua.js.map +1 -0
- package/{src → fontes}/estruturas/chamavel.d.ts +0 -0
- package/{src → fontes}/estruturas/chamavel.js +0 -0
- package/fontes/estruturas/chamavel.js.map +1 -0
- package/{src → fontes}/estruturas/classe.d.ts +0 -0
- package/{src → fontes}/estruturas/classe.js +0 -0
- package/fontes/estruturas/classe.js.map +1 -0
- package/{src → fontes}/estruturas/funcao-padrao.d.ts +0 -0
- package/{src → fontes}/estruturas/funcao-padrao.js +0 -0
- package/fontes/estruturas/funcao-padrao.js.map +1 -0
- package/{src → fontes}/estruturas/funcao.d.ts +0 -0
- package/{src → fontes}/estruturas/funcao.js +0 -0
- package/fontes/estruturas/funcao.js.map +1 -0
- package/{src → fontes}/estruturas/index.d.ts +0 -0
- package/{src → fontes}/estruturas/index.js +0 -0
- package/fontes/estruturas/index.js.map +1 -0
- package/fontes/estruturas/instancia.d.ts +9 -0
- package/{src → fontes}/estruturas/instancia.js +7 -7
- package/fontes/estruturas/instancia.js.map +1 -0
- package/{src → fontes}/estruturas/modulo.d.ts +4 -0
- package/{src → fontes}/estruturas/modulo.js +3 -3
- package/fontes/estruturas/modulo.js.map +1 -0
- package/fontes/excecoes/erro-em-tempo-de-execucao.d.ts +7 -0
- package/{src → fontes}/excecoes/erro-em-tempo-de-execucao.js +2 -1
- package/fontes/excecoes/erro-em-tempo-de-execucao.js.map +1 -0
- package/{src → fontes}/excecoes/excecao-continuar.d.ts +0 -0
- package/{src → fontes}/excecoes/excecao-continuar.js +0 -0
- package/fontes/excecoes/excecao-continuar.js.map +1 -0
- package/{src → fontes}/excecoes/excecao-retornar.d.ts +0 -0
- package/{src → fontes}/excecoes/excecao-retornar.js +0 -0
- package/fontes/excecoes/excecao-retornar.js.map +1 -0
- package/fontes/excecoes/excecao-sustar.d.ts +2 -0
- package/{src/excecoes/excecao-quebra.js → fontes/excecoes/excecao-sustar.js} +7 -7
- package/fontes/excecoes/excecao-sustar.js.map +1 -0
- package/{src → fontes}/excecoes/index.d.ts +1 -1
- package/{src → fontes}/excecoes/index.js +1 -1
- package/fontes/excecoes/index.js.map +1 -0
- package/fontes/interfaces/avaliador-sintatico-interface.d.ts +59 -0
- package/{src → fontes}/interfaces/avaliador-sintatico-interface.js +0 -0
- package/fontes/interfaces/avaliador-sintatico-interface.js.map +1 -0
- package/fontes/interfaces/delegua-interface.d.ts +3 -0
- package/fontes/interfaces/delegua-interface.js +3 -0
- package/fontes/interfaces/delegua-interface.js.map +1 -0
- package/fontes/interfaces/index.d.ts +7 -0
- package/{src → fontes}/interfaces/index.js +1 -0
- package/fontes/interfaces/index.js.map +1 -0
- package/fontes/interfaces/interpretador-interface.d.ts +52 -0
- package/{src → fontes}/interfaces/interpretador-interface.js +0 -0
- package/fontes/interfaces/interpretador-interface.js.map +1 -0
- package/fontes/interfaces/lexador-interface.d.ts +24 -0
- package/{src → fontes}/interfaces/lexador-interface.js +0 -0
- package/fontes/interfaces/lexador-interface.js.map +1 -0
- package/fontes/interfaces/pilha-interface.d.ts +7 -0
- package/{src → fontes}/interfaces/pilha-interface.js +0 -0
- package/fontes/interfaces/pilha-interface.js.map +1 -0
- package/fontes/interfaces/resolvedor-interface.d.ts +53 -0
- package/{src → fontes}/interfaces/resolvedor-interface.js +0 -0
- package/fontes/interfaces/resolvedor-interface.js.map +1 -0
- package/{src → fontes}/interfaces/simbolo-interface.d.ts +0 -0
- package/{src → fontes}/interfaces/simbolo-interface.js +0 -0
- package/fontes/interfaces/simbolo-interface.js.map +1 -0
- package/fontes/interpretador/dialetos/egua-classico.d.ts +64 -0
- package/{src → fontes}/interpretador/dialetos/egua-classico.js +237 -208
- package/fontes/interpretador/dialetos/egua-classico.js.map +1 -0
- package/{src → fontes}/interpretador/dialetos/index.d.ts +0 -0
- package/{src → fontes}/interpretador/dialetos/index.js +0 -0
- package/fontes/interpretador/dialetos/index.js.map +1 -0
- package/fontes/interpretador/erro-interpretador.d.ts +5 -0
- package/fontes/interpretador/erro-interpretador.js +3 -0
- package/fontes/interpretador/erro-interpretador.js.map +1 -0
- package/fontes/interpretador/index.d.ts +66 -0
- package/fontes/interpretador/index.js +700 -0
- package/fontes/interpretador/index.js.map +1 -0
- package/fontes/interpretador/retorno-interpretador.d.ts +4 -0
- package/fontes/interpretador/retorno-interpretador.js +3 -0
- package/fontes/interpretador/retorno-interpretador.js.map +1 -0
- package/{src → fontes}/lexador/dialetos/egua-classico.d.ts +11 -9
- package/fontes/lexador/dialetos/egua-classico.js +334 -0
- package/fontes/lexador/dialetos/egua-classico.js.map +1 -0
- package/{src → fontes}/lexador/dialetos/index.d.ts +0 -0
- package/{src → fontes}/lexador/dialetos/index.js +0 -0
- package/fontes/lexador/dialetos/index.js.map +1 -0
- package/fontes/lexador/erro-lexador.d.ts +5 -0
- package/fontes/lexador/erro-lexador.js +3 -0
- package/fontes/lexador/erro-lexador.js.map +1 -0
- package/{src → fontes}/lexador/index.d.ts +5 -4
- package/{src → fontes}/lexador/index.js +87 -75
- package/fontes/lexador/index.js.map +1 -0
- package/fontes/lexador/retorno-lexador.d.ts +6 -0
- package/fontes/lexador/retorno-lexador.js +3 -0
- package/fontes/lexador/retorno-lexador.js.map +1 -0
- package/fontes/resolvedor/dialetos/egua-classico.d.ts +62 -0
- package/fontes/resolvedor/dialetos/egua-classico.js +344 -0
- package/fontes/resolvedor/dialetos/egua-classico.js.map +1 -0
- package/{src → fontes}/resolvedor/dialetos/index.d.ts +0 -0
- package/{src → fontes}/resolvedor/dialetos/index.js +0 -0
- package/fontes/resolvedor/dialetos/index.js.map +1 -0
- package/fontes/resolvedor/erro-resolvedor.d.ts +5 -0
- package/{src → fontes}/resolvedor/erro-resolvedor.js +3 -2
- package/fontes/resolvedor/erro-resolvedor.js.map +1 -0
- package/fontes/resolvedor/index.d.ts +62 -0
- package/fontes/resolvedor/index.js +343 -0
- package/fontes/resolvedor/index.js.map +1 -0
- package/{src → fontes}/resolvedor/pilha-escopos.d.ts +1 -1
- package/{src → fontes}/resolvedor/pilha-escopos.js +0 -0
- package/fontes/resolvedor/pilha-escopos.js.map +1 -0
- package/fontes/resolvedor/retorno-resolvedor.d.ts +6 -0
- package/fontes/resolvedor/retorno-resolvedor.js +3 -0
- package/fontes/resolvedor/retorno-resolvedor.js.map +1 -0
- package/{src/tiposDeSimbolos.d.ts → fontes/tipos-de-simbolos.d.ts} +0 -0
- package/{src/tiposDeSimbolos.js → fontes/tipos-de-simbolos.js} +1 -1
- package/fontes/tipos-de-simbolos.js.map +1 -0
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +2 -1
- package/testes/avaliador-sintatico.test.js +14 -14
- package/testes/avaliador-sintatico.test.js.map +1 -1
- package/testes/biblioteca-global.test.d.ts +1 -0
- package/testes/biblioteca-global.test.js +131 -0
- package/testes/biblioteca-global.test.js.map +1 -0
- package/testes/egua-classico/avaliador-sintatico.test.d.ts +1 -0
- package/testes/egua-classico/avaliador-sintatico.test.js +24 -0
- package/testes/egua-classico/avaliador-sintatico.test.js.map +1 -0
- package/testes/egua-classico/interpretador.test.d.ts +1 -0
- package/testes/egua-classico/interpretador.test.js +219 -0
- package/testes/egua-classico/interpretador.test.js.map +1 -0
- package/testes/egua-classico/lexador.test.d.ts +1 -0
- package/testes/egua-classico/lexador.test.js +80 -0
- package/testes/egua-classico/lexador.test.js.map +1 -0
- package/testes/egua-classico/resolvedor.test.d.ts +1 -0
- package/testes/egua-classico/resolvedor.test.js +38 -0
- package/testes/egua-classico/resolvedor.test.js.map +1 -0
- package/testes/interpretador.test.js +171 -92
- package/testes/interpretador.test.js.map +1 -1
- package/testes/lexador.test.js +17 -14
- package/testes/lexador.test.js.map +1 -1
- package/testes/resolvedor.test.js +4 -4
- package/testes/resolvedor.test.js.map +1 -1
- package/src/ambiente.js.map +0 -1
- package/src/avaliador-sintatico/dialetos/egua-classico.d.ts +0 -60
- package/src/avaliador-sintatico/dialetos/egua-classico.js +0 -635
- package/src/avaliador-sintatico/dialetos/egua-classico.js.map +0 -1
- package/src/avaliador-sintatico/dialetos/index.js.map +0 -1
- package/src/avaliador-sintatico/erros-avaliador.d.ts +0 -2
- package/src/avaliador-sintatico/erros-avaliador.js +0 -27
- package/src/avaliador-sintatico/erros-avaliador.js.map +0 -1
- package/src/avaliador-sintatico/index.d.ts +0 -62
- package/src/avaliador-sintatico/index.js +0 -650
- package/src/avaliador-sintatico/index.js.map +0 -1
- package/src/bibliotecas/biblioteca-global.js.map +0 -1
- package/src/bibliotecas/importar-biblioteca.js.map +0 -1
- package/src/construtos/atribuicao-sobrescrita.js.map +0 -1
- package/src/construtos/atribuir.d.ts +0 -7
- package/src/construtos/atribuir.js.map +0 -1
- package/src/construtos/binario.js.map +0 -1
- package/src/construtos/chamada.js.map +0 -1
- package/src/construtos/conjunto.js.map +0 -1
- package/src/construtos/construto.js.map +0 -1
- package/src/construtos/dicionario.js.map +0 -1
- package/src/construtos/funcao.js.map +0 -1
- package/src/construtos/get.d.ts +0 -7
- package/src/construtos/get.js +0 -15
- package/src/construtos/get.js.map +0 -1
- package/src/construtos/grouping.d.ts +0 -6
- package/src/construtos/grouping.js +0 -14
- package/src/construtos/grouping.js.map +0 -1
- package/src/construtos/index.js.map +0 -1
- package/src/construtos/isto.js.map +0 -1
- package/src/construtos/literal.js.map +0 -1
- package/src/construtos/logical.js +0 -16
- package/src/construtos/logical.js.map +0 -1
- package/src/construtos/subscript.d.ts +0 -8
- package/src/construtos/subscript.js +0 -16
- package/src/construtos/subscript.js.map +0 -1
- package/src/construtos/super.js.map +0 -1
- package/src/construtos/unario.js.map +0 -1
- package/src/construtos/variavel.d.ts +0 -6
- package/src/construtos/variavel.js.map +0 -1
- package/src/construtos/vetor.js.map +0 -1
- package/src/declaracoes/bloco.js.map +0 -1
- package/src/declaracoes/classe.js.map +0 -1
- package/src/declaracoes/continua.js.map +0 -1
- package/src/declaracoes/declaracao.js.map +0 -1
- package/src/declaracoes/enquanto.js.map +0 -1
- package/src/declaracoes/escolha.js.map +0 -1
- package/src/declaracoes/escreva.js.map +0 -1
- package/src/declaracoes/expressao.js.map +0 -1
- package/src/declaracoes/fazer.js.map +0 -1
- package/src/declaracoes/funcao.d.ts +0 -7
- package/src/declaracoes/funcao.js.map +0 -1
- package/src/declaracoes/importar.d.ts +0 -7
- package/src/declaracoes/importar.js.map +0 -1
- package/src/declaracoes/index.js.map +0 -1
- package/src/declaracoes/para.js.map +0 -1
- package/src/declaracoes/pausa.js.map +0 -1
- package/src/declaracoes/retorna.js.map +0 -1
- package/src/declaracoes/se.d.ts +0 -9
- package/src/declaracoes/se.js.map +0 -1
- package/src/declaracoes/tente.d.ts +0 -9
- package/src/declaracoes/tente.js.map +0 -1
- package/src/declaracoes/var.d.ts +0 -7
- package/src/declaracoes/var.js.map +0 -1
- package/src/delegua.js +0 -138
- package/src/delegua.js.map +0 -1
- package/src/estruturas/chamavel.js.map +0 -1
- package/src/estruturas/classe.js.map +0 -1
- package/src/estruturas/funcao-padrao.js.map +0 -1
- package/src/estruturas/funcao.js.map +0 -1
- package/src/estruturas/index.js.map +0 -1
- package/src/estruturas/instancia.d.ts +0 -8
- package/src/estruturas/instancia.js.map +0 -1
- package/src/estruturas/modulo.js.map +0 -1
- package/src/excecoes/erro-em-tempo-de-execucao.d.ts +0 -5
- package/src/excecoes/erro-em-tempo-de-execucao.js.map +0 -1
- package/src/excecoes/excecao-continuar.js.map +0 -1
- package/src/excecoes/excecao-quebra.d.ts +0 -2
- package/src/excecoes/excecao-quebra.js.map +0 -1
- package/src/excecoes/excecao-retornar.js.map +0 -1
- package/src/excecoes/index.js.map +0 -1
- package/src/interfaces/avaliador-sintatico-interface.d.ts +0 -55
- package/src/interfaces/avaliador-sintatico-interface.js.map +0 -1
- package/src/interfaces/index.d.ts +0 -6
- package/src/interfaces/index.js.map +0 -1
- package/src/interfaces/interpretador-interface.d.ts +0 -51
- package/src/interfaces/interpretador-interface.js.map +0 -1
- package/src/interfaces/lexador-interface.d.ts +0 -23
- package/src/interfaces/lexador-interface.js.map +0 -1
- package/src/interfaces/pilha-interface.d.ts +0 -7
- package/src/interfaces/pilha-interface.js.map +0 -1
- package/src/interfaces/resolvedor-interface.d.ts +0 -50
- package/src/interfaces/resolvedor-interface.js.map +0 -1
- package/src/interfaces/simbolo-interface.js.map +0 -1
- package/src/interpretador/dialetos/egua-classico.d.ts +0 -58
- package/src/interpretador/dialetos/egua-classico.js.map +0 -1
- package/src/interpretador/dialetos/index.js.map +0 -1
- package/src/interpretador/index.d.ts +0 -59
- package/src/interpretador/index.js +0 -675
- package/src/interpretador/index.js.map +0 -1
- package/src/lexador/dialetos/egua-classico.js +0 -285
- package/src/lexador/dialetos/egua-classico.js.map +0 -1
- package/src/lexador/dialetos/index.js.map +0 -1
- package/src/lexador/index.js.map +0 -1
- package/src/resolvedor/dialetos/egua-classico.d.ts +0 -59
- package/src/resolvedor/dialetos/egua-classico.js +0 -331
- package/src/resolvedor/dialetos/egua-classico.js.map +0 -1
- package/src/resolvedor/dialetos/index.js.map +0 -1
- package/src/resolvedor/erro-resolvedor.d.ts +0 -4
- package/src/resolvedor/erro-resolvedor.js.map +0 -1
- package/src/resolvedor/index.d.ts +0 -60
- package/src/resolvedor/index.js +0 -331
- package/src/resolvedor/index.js.map +0 -1
- package/src/resolvedor/pilha-escopos.js.map +0 -1
- package/src/tiposDeSimbolos.js.map +0 -1
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
29
|
exports.InterpretadorEguaClassico = void 0;
|
|
4
|
-
var
|
|
30
|
+
var caminho = __importStar(require("path"));
|
|
31
|
+
var fs = __importStar(require("fs"));
|
|
32
|
+
var tipos_de_simbolos_1 = __importDefault(require("../../tipos-de-simbolos"));
|
|
5
33
|
var ambiente_1 = require("../../ambiente");
|
|
6
34
|
var delegua_1 = require("../../delegua");
|
|
7
|
-
var biblioteca_global_1 = require("../../bibliotecas/biblioteca-global");
|
|
8
|
-
var
|
|
9
|
-
var fs = require("fs");
|
|
10
|
-
var importar_biblioteca_1 = require("../../bibliotecas/importar-biblioteca");
|
|
35
|
+
var biblioteca_global_1 = __importDefault(require("../../bibliotecas/biblioteca-global"));
|
|
36
|
+
var importar_biblioteca_1 = __importDefault(require("../../bibliotecas/importar-biblioteca"));
|
|
11
37
|
var chamavel_1 = require("../../estruturas/chamavel");
|
|
12
38
|
var funcao_padrao_1 = require("../../estruturas/funcao-padrao");
|
|
13
39
|
var classe_1 = require("../../estruturas/classe");
|
|
@@ -26,43 +52,41 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
26
52
|
this.global = new ambiente_1.Ambiente();
|
|
27
53
|
this.ambiente = this.global;
|
|
28
54
|
this.locais = new Map();
|
|
55
|
+
this.erros = [];
|
|
29
56
|
this.global = (0, biblioteca_global_1.default)(this, this.global);
|
|
30
57
|
}
|
|
31
|
-
InterpretadorEguaClassico.prototype.
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoLiteral = function (expr) {
|
|
35
|
-
return expr.valor;
|
|
58
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoLiteral = function (expressao) {
|
|
59
|
+
return expressao.valor;
|
|
36
60
|
};
|
|
37
|
-
InterpretadorEguaClassico.prototype.avaliar = function (
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
61
|
+
InterpretadorEguaClassico.prototype.avaliar = function (expressao) {
|
|
62
|
+
if (expressao.aceitar) {
|
|
63
|
+
return expressao.aceitar(this);
|
|
40
64
|
}
|
|
41
65
|
};
|
|
42
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoAgrupamento = function (
|
|
43
|
-
return this.avaliar(
|
|
66
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoAgrupamento = function (expressao) {
|
|
67
|
+
return this.avaliar(expressao.expressao);
|
|
44
68
|
};
|
|
45
69
|
InterpretadorEguaClassico.prototype.eVerdadeiro = function (objeto) {
|
|
46
70
|
if (objeto === null)
|
|
47
71
|
return false;
|
|
48
|
-
if (typeof objeto ===
|
|
72
|
+
if (typeof objeto === 'boolean')
|
|
49
73
|
return Boolean(objeto);
|
|
50
74
|
return true;
|
|
51
75
|
};
|
|
52
76
|
InterpretadorEguaClassico.prototype.verificarOperandoNumero = function (operador, operand) {
|
|
53
|
-
if (typeof operand ===
|
|
77
|
+
if (typeof operand === 'number')
|
|
54
78
|
return;
|
|
55
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(operador,
|
|
79
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(operador, 'Operador precisa ser um número.', operador.linha);
|
|
56
80
|
};
|
|
57
81
|
InterpretadorEguaClassico.prototype.visitarExpressaoUnaria = function (expr) {
|
|
58
82
|
var direita = this.avaliar(expr.direita);
|
|
59
83
|
switch (expr.operador.tipo) {
|
|
60
|
-
case
|
|
84
|
+
case tipos_de_simbolos_1.default.SUBTRACAO:
|
|
61
85
|
this.verificarOperandoNumero(expr.operador, direita);
|
|
62
86
|
return -direita;
|
|
63
|
-
case
|
|
87
|
+
case tipos_de_simbolos_1.default.NEGACAO:
|
|
64
88
|
return !this.eVerdadeiro(direita);
|
|
65
|
-
case
|
|
89
|
+
case tipos_de_simbolos_1.default.BIT_NOT:
|
|
66
90
|
return ~direita;
|
|
67
91
|
}
|
|
68
92
|
return null;
|
|
@@ -75,80 +99,81 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
75
99
|
return esquerda === direita;
|
|
76
100
|
};
|
|
77
101
|
InterpretadorEguaClassico.prototype.verificarOperandosNumeros = function (operador, direita, esquerda) {
|
|
78
|
-
if (typeof direita ===
|
|
102
|
+
if (typeof direita === 'number' && typeof esquerda === 'number')
|
|
79
103
|
return;
|
|
80
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(operador,
|
|
104
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(operador, 'Operadores precisam ser números.', operador.linha);
|
|
81
105
|
};
|
|
82
106
|
InterpretadorEguaClassico.prototype.visitarExpressaoBinaria = function (expr) {
|
|
83
107
|
var esquerda = this.avaliar(expr.esquerda);
|
|
84
108
|
var direita = this.avaliar(expr.direita);
|
|
85
109
|
switch (expr.operador.tipo) {
|
|
86
|
-
case
|
|
110
|
+
case tipos_de_simbolos_1.default.EXPONENCIACAO:
|
|
87
111
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
88
112
|
return Math.pow(esquerda, direita);
|
|
89
|
-
case
|
|
113
|
+
case tipos_de_simbolos_1.default.MAIOR:
|
|
90
114
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
91
115
|
return Number(esquerda) > Number(direita);
|
|
92
|
-
case
|
|
116
|
+
case tipos_de_simbolos_1.default.MAIOR_IGUAL:
|
|
93
117
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
94
118
|
return Number(esquerda) >= Number(direita);
|
|
95
|
-
case
|
|
119
|
+
case tipos_de_simbolos_1.default.MENOR:
|
|
96
120
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
97
121
|
return Number(esquerda) < Number(direita);
|
|
98
|
-
case
|
|
122
|
+
case tipos_de_simbolos_1.default.MENOR_IGUAL:
|
|
99
123
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
100
124
|
return Number(esquerda) <= Number(direita);
|
|
101
|
-
case
|
|
125
|
+
case tipos_de_simbolos_1.default.SUBTRACAO:
|
|
102
126
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
103
127
|
return Number(esquerda) - Number(direita);
|
|
104
|
-
case
|
|
105
|
-
if (typeof esquerda ===
|
|
128
|
+
case tipos_de_simbolos_1.default.ADICAO:
|
|
129
|
+
if (typeof esquerda === 'number' &&
|
|
130
|
+
typeof direita === 'number') {
|
|
106
131
|
return Number(esquerda) + Number(direita);
|
|
107
132
|
}
|
|
108
|
-
else if (typeof esquerda ===
|
|
109
|
-
typeof direita ===
|
|
133
|
+
else if (typeof esquerda === 'string' &&
|
|
134
|
+
typeof direita === 'string') {
|
|
110
135
|
return String(esquerda) + String(direita);
|
|
111
136
|
}
|
|
112
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expr.operador,
|
|
113
|
-
case
|
|
137
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expr.operador, 'Operadores precisam ser dois números ou duas strings.');
|
|
138
|
+
case tipos_de_simbolos_1.default.DIVISAO:
|
|
114
139
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
115
140
|
return Number(esquerda) / Number(direita);
|
|
116
|
-
case
|
|
141
|
+
case tipos_de_simbolos_1.default.MULTIPLICACAO:
|
|
117
142
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
118
143
|
return Number(esquerda) * Number(direita);
|
|
119
|
-
case
|
|
144
|
+
case tipos_de_simbolos_1.default.MODULO:
|
|
120
145
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
121
146
|
return Number(esquerda) % Number(direita);
|
|
122
|
-
case
|
|
147
|
+
case tipos_de_simbolos_1.default.BIT_AND:
|
|
123
148
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
124
149
|
return Number(esquerda) & Number(direita);
|
|
125
|
-
case
|
|
150
|
+
case tipos_de_simbolos_1.default.BIT_XOR:
|
|
126
151
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
127
152
|
return Number(esquerda) ^ Number(direita);
|
|
128
|
-
case
|
|
153
|
+
case tipos_de_simbolos_1.default.BIT_OR:
|
|
129
154
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
130
155
|
return Number(esquerda) | Number(direita);
|
|
131
|
-
case
|
|
156
|
+
case tipos_de_simbolos_1.default.MENOR_MENOR:
|
|
132
157
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
133
158
|
return Number(esquerda) << Number(direita);
|
|
134
|
-
case
|
|
159
|
+
case tipos_de_simbolos_1.default.MAIOR_MAIOR:
|
|
135
160
|
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
136
161
|
return Number(esquerda) >> Number(direita);
|
|
137
|
-
case
|
|
162
|
+
case tipos_de_simbolos_1.default.DIFERENTE:
|
|
138
163
|
return !this.eIgual(esquerda, direita);
|
|
139
|
-
case
|
|
164
|
+
case tipos_de_simbolos_1.default.IGUAL_IGUAL:
|
|
140
165
|
return this.eIgual(esquerda, direita);
|
|
141
166
|
}
|
|
142
167
|
return null;
|
|
143
168
|
};
|
|
144
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoDeChamada = function (
|
|
145
|
-
var entidadeChamada = this.avaliar(
|
|
169
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDeChamada = function (expressao) {
|
|
170
|
+
var entidadeChamada = this.avaliar(expressao.entidadeChamada);
|
|
146
171
|
var argumentos = [];
|
|
147
|
-
for (var i = 0; i <
|
|
148
|
-
argumentos.push(this.avaliar(
|
|
172
|
+
for (var i = 0; i < expressao.argumentos.length; i++) {
|
|
173
|
+
argumentos.push(this.avaliar(expressao.argumentos[i]));
|
|
149
174
|
}
|
|
150
175
|
if (!(entidadeChamada instanceof chamavel_1.Chamavel)) {
|
|
151
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(
|
|
176
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.parentese, 'Só pode chamar função ou classe.', expressao.linha);
|
|
152
177
|
}
|
|
153
178
|
var parametros;
|
|
154
179
|
if (entidadeChamada instanceof funcao_1.DeleguaFuncao) {
|
|
@@ -172,101 +197,101 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
172
197
|
else {
|
|
173
198
|
if (parametros &&
|
|
174
199
|
parametros.length > 0 &&
|
|
175
|
-
parametros[parametros.length - 1][
|
|
200
|
+
parametros[parametros.length - 1]['tipo'] === 'wildcard') {
|
|
176
201
|
var novosArgumentos = argumentos.slice(0, parametros.length - 1);
|
|
177
202
|
novosArgumentos.push(argumentos.slice(parametros.length - 1, argumentos.length));
|
|
178
203
|
argumentos = novosArgumentos;
|
|
179
204
|
}
|
|
180
205
|
}
|
|
181
206
|
if (entidadeChamada instanceof funcao_padrao_1.FuncaoPadrao) {
|
|
182
|
-
return entidadeChamada.chamar(this, argumentos,
|
|
207
|
+
return entidadeChamada.chamar(this, argumentos, expressao.entidadeChamada.nome);
|
|
183
208
|
}
|
|
184
209
|
return entidadeChamada.chamar(this, argumentos);
|
|
185
210
|
};
|
|
186
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoDeAtribuicao = function (
|
|
187
|
-
var valor = this.avaliar(
|
|
188
|
-
var distancia = this.locais.get(
|
|
211
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDeAtribuicao = function (expressao) {
|
|
212
|
+
var valor = this.avaliar(expressao.valor);
|
|
213
|
+
var distancia = this.locais.get(expressao);
|
|
189
214
|
if (distancia !== undefined) {
|
|
190
|
-
this.ambiente.atribuirVariavelEm(distancia,
|
|
215
|
+
this.ambiente.atribuirVariavelEm(distancia, expressao.simbolo, valor);
|
|
191
216
|
}
|
|
192
217
|
else {
|
|
193
|
-
this.ambiente.atribuirVariavel(
|
|
218
|
+
this.ambiente.atribuirVariavel(expressao.simbolo, valor);
|
|
194
219
|
}
|
|
195
220
|
return valor;
|
|
196
221
|
};
|
|
197
|
-
InterpretadorEguaClassico.prototype.procurarVariavel = function (
|
|
222
|
+
InterpretadorEguaClassico.prototype.procurarVariavel = function (simbolo, expr) {
|
|
198
223
|
var distancia = this.locais.get(expr);
|
|
199
224
|
if (distancia !== undefined) {
|
|
200
|
-
return this.ambiente.obterVariavelEm(distancia,
|
|
225
|
+
return this.ambiente.obterVariavelEm(distancia, simbolo.lexema);
|
|
201
226
|
}
|
|
202
227
|
else {
|
|
203
|
-
return this.global.obterVariavel(
|
|
228
|
+
return this.global.obterVariavel(simbolo);
|
|
204
229
|
}
|
|
205
230
|
};
|
|
206
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoDeVariavel = function (
|
|
207
|
-
return this.procurarVariavel(
|
|
231
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDeVariavel = function (expressao) {
|
|
232
|
+
return this.procurarVariavel(expressao.simbolo, expressao);
|
|
208
233
|
};
|
|
209
|
-
InterpretadorEguaClassico.prototype.visitarDeclaracaoDeExpressao = function (
|
|
210
|
-
return this.avaliar(
|
|
234
|
+
InterpretadorEguaClassico.prototype.visitarDeclaracaoDeExpressao = function (declaracao) {
|
|
235
|
+
return this.avaliar(declaracao.expressao);
|
|
211
236
|
};
|
|
212
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoLogica = function (
|
|
213
|
-
var esquerda = this.avaliar(
|
|
214
|
-
if (
|
|
215
|
-
var direita = this.avaliar(
|
|
216
|
-
if (Array.isArray(direita) || typeof direita ===
|
|
237
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoLogica = function (expressao) {
|
|
238
|
+
var esquerda = this.avaliar(expressao.esquerda);
|
|
239
|
+
if (expressao.operador.tipo === tipos_de_simbolos_1.default.EM) {
|
|
240
|
+
var direita = this.avaliar(expressao.direita);
|
|
241
|
+
if (Array.isArray(direita) || typeof direita === 'string') {
|
|
217
242
|
return direita.includes(esquerda);
|
|
218
243
|
}
|
|
219
244
|
else if (direita.constructor === Object) {
|
|
220
245
|
return esquerda in direita;
|
|
221
246
|
}
|
|
222
247
|
else {
|
|
223
|
-
throw new excecoes_1.ErroEmTempoDeExecucao("Tipo de chamada inválida com 'em'.");
|
|
248
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(esquerda, "Tipo de chamada inválida com 'em'.", expressao.linha);
|
|
224
249
|
}
|
|
225
250
|
}
|
|
226
251
|
// se um estado for verdadeiro, retorna verdadeiro
|
|
227
|
-
if (
|
|
252
|
+
if (expressao.operador.tipo === tipos_de_simbolos_1.default.OU) {
|
|
228
253
|
if (this.eVerdadeiro(esquerda))
|
|
229
254
|
return esquerda;
|
|
230
255
|
}
|
|
231
256
|
// se um estado for falso, retorna falso
|
|
232
|
-
if (
|
|
257
|
+
if (expressao.operador.tipo === tipos_de_simbolos_1.default.E) {
|
|
233
258
|
if (!this.eVerdadeiro(esquerda))
|
|
234
259
|
return esquerda;
|
|
235
260
|
}
|
|
236
|
-
return this.avaliar(
|
|
261
|
+
return this.avaliar(expressao.direita);
|
|
237
262
|
};
|
|
238
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoSe = function (
|
|
239
|
-
if (this.eVerdadeiro(this.avaliar(
|
|
240
|
-
this.executar(
|
|
263
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoSe = function (declaracao) {
|
|
264
|
+
if (this.eVerdadeiro(this.avaliar(declaracao.condicao))) {
|
|
265
|
+
this.executar(declaracao.caminhoEntao);
|
|
241
266
|
return null;
|
|
242
267
|
}
|
|
243
|
-
for (var i = 0; i <
|
|
244
|
-
var atual =
|
|
268
|
+
for (var i = 0; i < declaracao.caminhosSeSenao.length; i++) {
|
|
269
|
+
var atual = declaracao.caminhosSeSenao[i];
|
|
245
270
|
if (this.eVerdadeiro(this.avaliar(atual.condicao))) {
|
|
246
|
-
this.executar(atual.
|
|
271
|
+
this.executar(atual.caminho);
|
|
247
272
|
return null;
|
|
248
273
|
}
|
|
249
274
|
}
|
|
250
|
-
if (
|
|
251
|
-
this.executar(
|
|
275
|
+
if (declaracao.caminhoSenao !== null) {
|
|
276
|
+
this.executar(declaracao.caminhoSenao);
|
|
252
277
|
}
|
|
253
278
|
return null;
|
|
254
279
|
};
|
|
255
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoPara = function (
|
|
256
|
-
if (
|
|
257
|
-
this.avaliar(
|
|
280
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoPara = function (declaracao) {
|
|
281
|
+
if (declaracao.inicializador !== null) {
|
|
282
|
+
this.avaliar(declaracao.inicializador);
|
|
258
283
|
}
|
|
259
284
|
while (true) {
|
|
260
|
-
if (
|
|
261
|
-
if (!this.eVerdadeiro(this.avaliar(
|
|
285
|
+
if (declaracao.condicao !== null) {
|
|
286
|
+
if (!this.eVerdadeiro(this.avaliar(declaracao.condicao))) {
|
|
262
287
|
break;
|
|
263
288
|
}
|
|
264
289
|
}
|
|
265
290
|
try {
|
|
266
|
-
this.executar(
|
|
291
|
+
this.executar(declaracao.corpo);
|
|
267
292
|
}
|
|
268
293
|
catch (erro) {
|
|
269
|
-
if (erro instanceof excecoes_1.
|
|
294
|
+
if (erro instanceof excecoes_1.ExcecaoSustar) {
|
|
270
295
|
break;
|
|
271
296
|
}
|
|
272
297
|
else if (erro instanceof excecoes_1.ExcecaoContinuar) {
|
|
@@ -275,19 +300,19 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
275
300
|
throw erro;
|
|
276
301
|
}
|
|
277
302
|
}
|
|
278
|
-
if (
|
|
279
|
-
this.avaliar(
|
|
303
|
+
if (declaracao.incrementar !== null) {
|
|
304
|
+
this.avaliar(declaracao.incrementar);
|
|
280
305
|
}
|
|
281
306
|
}
|
|
282
307
|
return null;
|
|
283
308
|
};
|
|
284
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoFazer = function (
|
|
309
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoFazer = function (declaracao) {
|
|
285
310
|
do {
|
|
286
311
|
try {
|
|
287
|
-
this.executar(
|
|
312
|
+
this.executar(declaracao.caminhoFazer);
|
|
288
313
|
}
|
|
289
314
|
catch (erro) {
|
|
290
|
-
if (erro instanceof excecoes_1.
|
|
315
|
+
if (erro instanceof excecoes_1.ExcecaoSustar) {
|
|
291
316
|
break;
|
|
292
317
|
}
|
|
293
318
|
else if (erro instanceof excecoes_1.ExcecaoContinuar) {
|
|
@@ -296,22 +321,22 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
296
321
|
throw erro;
|
|
297
322
|
}
|
|
298
323
|
}
|
|
299
|
-
} while (this.eVerdadeiro(this.avaliar(
|
|
324
|
+
} while (this.eVerdadeiro(this.avaliar(declaracao.condicaoEnquanto)));
|
|
300
325
|
};
|
|
301
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoEscolha = function (
|
|
302
|
-
var
|
|
303
|
-
var
|
|
304
|
-
var
|
|
305
|
-
var
|
|
326
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoEscolha = function (declaracao) {
|
|
327
|
+
var condicaoEscolha = this.avaliar(declaracao.condicao);
|
|
328
|
+
var caminhos = declaracao.caminhos;
|
|
329
|
+
var caminhoPadrao = declaracao.caminhoPadrao;
|
|
330
|
+
var encontrado = false;
|
|
306
331
|
try {
|
|
307
|
-
for (var i = 0; i <
|
|
308
|
-
var
|
|
309
|
-
for (var j = 0; j <
|
|
310
|
-
if (this.avaliar(
|
|
311
|
-
|
|
332
|
+
for (var i = 0; i < caminhos.length; i++) {
|
|
333
|
+
var caminho_1 = caminhos[i];
|
|
334
|
+
for (var j = 0; j < caminho_1.conditions.length; j++) {
|
|
335
|
+
if (this.avaliar(caminho_1.conditions[j]) === condicaoEscolha) {
|
|
336
|
+
encontrado = true;
|
|
312
337
|
try {
|
|
313
|
-
for (var k = 0; k <
|
|
314
|
-
this.executar(
|
|
338
|
+
for (var k = 0; k < caminho_1.declaracoes.length; k++) {
|
|
339
|
+
this.executar(caminho_1.declaracoes[k]);
|
|
315
340
|
}
|
|
316
341
|
}
|
|
317
342
|
catch (erro) {
|
|
@@ -324,48 +349,48 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
324
349
|
}
|
|
325
350
|
}
|
|
326
351
|
}
|
|
327
|
-
if (
|
|
328
|
-
for (var i = 0; i <
|
|
329
|
-
this.executar(
|
|
352
|
+
if (caminhoPadrao !== null && encontrado === false) {
|
|
353
|
+
for (var i = 0; i < caminhoPadrao.declaracoes.length; i++) {
|
|
354
|
+
this.executar(caminhoPadrao['declaracoes'][i]);
|
|
330
355
|
}
|
|
331
356
|
}
|
|
332
357
|
}
|
|
333
358
|
catch (erro) {
|
|
334
|
-
if (erro instanceof excecoes_1.
|
|
359
|
+
if (erro instanceof excecoes_1.ExcecaoSustar) {
|
|
335
360
|
}
|
|
336
361
|
else {
|
|
337
362
|
throw erro;
|
|
338
363
|
}
|
|
339
364
|
}
|
|
340
365
|
};
|
|
341
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoTente = function (
|
|
366
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoTente = function (declaracao) {
|
|
342
367
|
try {
|
|
343
368
|
var sucesso = true;
|
|
344
369
|
try {
|
|
345
|
-
this.executarBloco(
|
|
370
|
+
this.executarBloco(declaracao.caminhoTente, new ambiente_1.Ambiente(this.ambiente));
|
|
346
371
|
}
|
|
347
372
|
catch (erro) {
|
|
348
373
|
sucesso = false;
|
|
349
|
-
if (
|
|
350
|
-
this.executarBloco(
|
|
374
|
+
if (declaracao.caminhoPegue !== null) {
|
|
375
|
+
this.executarBloco(declaracao.caminhoPegue, new ambiente_1.Ambiente(this.ambiente));
|
|
351
376
|
}
|
|
352
377
|
}
|
|
353
|
-
if (sucesso &&
|
|
354
|
-
this.executarBloco(
|
|
378
|
+
if (sucesso && declaracao.caminhoSenao !== null) {
|
|
379
|
+
this.executarBloco(declaracao.caminhoSenao, new ambiente_1.Ambiente(this.ambiente));
|
|
355
380
|
}
|
|
356
381
|
}
|
|
357
382
|
finally {
|
|
358
|
-
if (
|
|
359
|
-
this.executarBloco(
|
|
383
|
+
if (declaracao.caminhoFinalmente !== null)
|
|
384
|
+
this.executarBloco(declaracao.caminhoFinalmente, new ambiente_1.Ambiente(this.ambiente));
|
|
360
385
|
}
|
|
361
386
|
};
|
|
362
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoEnquanto = function (
|
|
363
|
-
while (this.eVerdadeiro(this.avaliar(
|
|
387
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoEnquanto = function (declaracao) {
|
|
388
|
+
while (this.eVerdadeiro(this.avaliar(declaracao.condicao))) {
|
|
364
389
|
try {
|
|
365
|
-
this.executar(
|
|
390
|
+
this.executar(declaracao.corpo);
|
|
366
391
|
}
|
|
367
392
|
catch (erro) {
|
|
368
|
-
if (erro instanceof excecoes_1.
|
|
393
|
+
if (erro instanceof excecoes_1.ExcecaoSustar) {
|
|
369
394
|
break;
|
|
370
395
|
}
|
|
371
396
|
else if (erro instanceof excecoes_1.ExcecaoContinuar) {
|
|
@@ -377,21 +402,20 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
377
402
|
}
|
|
378
403
|
return null;
|
|
379
404
|
};
|
|
380
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoImportar = function (
|
|
381
|
-
var caminhoRelativo = this.avaliar(
|
|
405
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoImportar = function (declaracao) {
|
|
406
|
+
var caminhoRelativo = this.avaliar(declaracao.caminho);
|
|
382
407
|
var caminhoTotal = caminho.join(this.diretorioBase, caminhoRelativo);
|
|
383
|
-
// const pastaTotal = caminho.dirname(caminhoTotal);
|
|
384
408
|
var nomeArquivo = caminho.basename(caminhoTotal);
|
|
385
409
|
var dados = (0, importar_biblioteca_1.default)(caminhoRelativo);
|
|
386
410
|
if (dados)
|
|
387
411
|
return dados;
|
|
388
412
|
try {
|
|
389
413
|
if (!fs.existsSync(caminhoTotal)) {
|
|
390
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(
|
|
414
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(declaracao.simboloFechamento, 'Não foi possível encontrar arquivo importado.', declaracao.linha);
|
|
391
415
|
}
|
|
392
416
|
}
|
|
393
417
|
catch (erro) {
|
|
394
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(
|
|
418
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(declaracao.simboloFechamento, 'Não foi possível ler o arquivo.', declaracao.linha);
|
|
395
419
|
}
|
|
396
420
|
dados = fs.readFileSync(caminhoTotal).toString();
|
|
397
421
|
var delegua = new delegua_1.Delegua(this.Delegua.dialeto, false, nomeArquivo);
|
|
@@ -408,8 +432,8 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
408
432
|
}
|
|
409
433
|
return exportar;
|
|
410
434
|
};
|
|
411
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoEscreva = function (
|
|
412
|
-
var valor = this.avaliar(
|
|
435
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoEscreva = function (declaracao) {
|
|
436
|
+
var valor = this.avaliar(declaracao.expressao);
|
|
413
437
|
console.log(this.paraTexto(valor));
|
|
414
438
|
return null;
|
|
415
439
|
};
|
|
@@ -431,37 +455,37 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
431
455
|
this.ambiente = anterior;
|
|
432
456
|
}
|
|
433
457
|
};
|
|
434
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoBloco = function (
|
|
435
|
-
this.executarBloco(
|
|
458
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoBloco = function (declaracao) {
|
|
459
|
+
this.executarBloco(declaracao.declaracoes, new ambiente_1.Ambiente(this.ambiente));
|
|
436
460
|
return null;
|
|
437
461
|
};
|
|
438
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoVar = function (
|
|
462
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoVar = function (declaracao) {
|
|
439
463
|
var valor = null;
|
|
440
|
-
if (
|
|
441
|
-
valor = this.avaliar(
|
|
464
|
+
if (declaracao.inicializador !== null) {
|
|
465
|
+
valor = this.avaliar(declaracao.inicializador);
|
|
442
466
|
}
|
|
443
|
-
this.ambiente.definirVariavel(
|
|
467
|
+
this.ambiente.definirVariavel(declaracao.simbolo.lexema, valor);
|
|
444
468
|
return null;
|
|
445
469
|
};
|
|
446
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoContinua = function (
|
|
470
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoContinua = function (declaracao) {
|
|
447
471
|
throw new excecoes_1.ExcecaoContinuar();
|
|
448
472
|
};
|
|
449
|
-
InterpretadorEguaClassico.prototype.
|
|
450
|
-
throw new excecoes_1.
|
|
473
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoSustar = function (declaracao) {
|
|
474
|
+
throw new excecoes_1.ExcecaoSustar();
|
|
451
475
|
};
|
|
452
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoRetornar = function (
|
|
476
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoRetornar = function (declaracao) {
|
|
453
477
|
var valor = null;
|
|
454
|
-
if (
|
|
455
|
-
valor = this.avaliar(
|
|
478
|
+
if (declaracao.valor != null)
|
|
479
|
+
valor = this.avaliar(declaracao.valor);
|
|
456
480
|
throw new excecoes_1.ExcecaoRetornar(valor);
|
|
457
481
|
};
|
|
458
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoDeleguaFuncao = function (
|
|
459
|
-
return new funcao_1.DeleguaFuncao(null,
|
|
482
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDeleguaFuncao = function (expressao) {
|
|
483
|
+
return new funcao_1.DeleguaFuncao(null, expressao, this.ambiente, false);
|
|
460
484
|
};
|
|
461
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoAtribuicaoSobrescrita = function (
|
|
462
|
-
var objeto = this.avaliar(
|
|
463
|
-
var indice = this.avaliar(
|
|
464
|
-
var valor = this.avaliar(
|
|
485
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoAtribuicaoSobrescrita = function (expressao) {
|
|
486
|
+
var objeto = this.avaliar(expressao.objeto);
|
|
487
|
+
var indice = this.avaliar(expressao.indice);
|
|
488
|
+
var valor = this.avaliar(expressao.valor);
|
|
465
489
|
if (Array.isArray(objeto)) {
|
|
466
490
|
if (indice < 0 && objeto.length !== 0) {
|
|
467
491
|
while (indice < 0) {
|
|
@@ -481,15 +505,15 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
481
505
|
objeto[indice] = valor;
|
|
482
506
|
}
|
|
483
507
|
else {
|
|
484
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(
|
|
508
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.objeto.nome, 'Somente listas, dicionários, classes e objetos podem ser mudados por sobrescrita.', expressao.linha);
|
|
485
509
|
}
|
|
486
510
|
};
|
|
487
|
-
InterpretadorEguaClassico.prototype.
|
|
511
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoAcessoIndiceVariavel = function (expressao) {
|
|
488
512
|
var objeto = this.avaliar(expressao.entidadeChamada);
|
|
489
513
|
var indice = this.avaliar(expressao.indice);
|
|
490
514
|
if (Array.isArray(objeto)) {
|
|
491
515
|
if (!Number.isInteger(indice)) {
|
|
492
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.
|
|
516
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simboloFechamento, 'Somente inteiros podem ser usados para indexar um vetor.', expressao.linha);
|
|
493
517
|
}
|
|
494
518
|
if (indice < 0 && objeto.length !== 0) {
|
|
495
519
|
while (indice < 0) {
|
|
@@ -497,7 +521,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
497
521
|
}
|
|
498
522
|
}
|
|
499
523
|
if (indice >= objeto.length) {
|
|
500
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.
|
|
524
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simboloFechamento, 'Índice do vetor fora do intervalo.', expressao.linha);
|
|
501
525
|
}
|
|
502
526
|
return objeto[indice];
|
|
503
527
|
}
|
|
@@ -508,9 +532,9 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
508
532
|
objeto instanceof modulo_1.DeleguaModulo) {
|
|
509
533
|
return objeto[indice] || null;
|
|
510
534
|
}
|
|
511
|
-
else if (typeof objeto ===
|
|
535
|
+
else if (typeof objeto === 'string') {
|
|
512
536
|
if (!Number.isInteger(indice)) {
|
|
513
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.
|
|
537
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simboloFechamento, 'Somente inteiros podem ser usados para indexar um vetor.', expressao.linha);
|
|
514
538
|
}
|
|
515
539
|
if (indice < 0 && objeto.length !== 0) {
|
|
516
540
|
while (indice < 0) {
|
|
@@ -518,133 +542,138 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
518
542
|
}
|
|
519
543
|
}
|
|
520
544
|
if (indice >= objeto.length) {
|
|
521
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.
|
|
545
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.simboloFechamento, 'Índice fora do tamanho.', expressao.linha);
|
|
522
546
|
}
|
|
523
547
|
return objeto.charAt(indice);
|
|
524
548
|
}
|
|
525
549
|
else {
|
|
526
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.entidadeChamada.nome,
|
|
550
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.entidadeChamada.nome, 'Somente listas, dicionários, classes e objetos podem ser mudados por sobrescrita.', expressao.linha);
|
|
527
551
|
}
|
|
528
552
|
};
|
|
529
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoDefinir = function (
|
|
530
|
-
var objeto = this.avaliar(
|
|
553
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDefinir = function (expressao) {
|
|
554
|
+
var objeto = this.avaliar(expressao.objeto);
|
|
531
555
|
if (!(objeto instanceof instancia_1.DeleguaInstancia) &&
|
|
532
556
|
objeto.constructor !== Object) {
|
|
533
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(
|
|
557
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.objeto.nome, 'Somente instâncias e dicionários podem possuir campos.', expressao.linha);
|
|
534
558
|
}
|
|
535
|
-
var valor = this.avaliar(
|
|
559
|
+
var valor = this.avaliar(expressao.valor);
|
|
536
560
|
if (objeto instanceof instancia_1.DeleguaInstancia) {
|
|
537
|
-
objeto.set(
|
|
561
|
+
objeto.set(expressao.nome, valor);
|
|
538
562
|
return valor;
|
|
539
563
|
}
|
|
540
564
|
else if (objeto.constructor === Object) {
|
|
541
|
-
objeto[
|
|
565
|
+
objeto[expressao.simbolo.lexema] = valor;
|
|
542
566
|
}
|
|
543
567
|
};
|
|
544
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoFuncao = function (
|
|
545
|
-
var funcao = new funcao_1.DeleguaFuncao(
|
|
546
|
-
this.ambiente.definirVariavel(
|
|
568
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoFuncao = function (declaracao) {
|
|
569
|
+
var funcao = new funcao_1.DeleguaFuncao(declaracao.simbolo.lexema, declaracao.funcao, this.ambiente, false);
|
|
570
|
+
this.ambiente.definirVariavel(declaracao.simbolo.lexema, funcao);
|
|
547
571
|
};
|
|
548
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoClasse = function (
|
|
572
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoClasse = function (declaracao) {
|
|
549
573
|
var superClasse = null;
|
|
550
|
-
if (
|
|
551
|
-
superClasse = this.avaliar(
|
|
574
|
+
if (declaracao.superClasse !== null) {
|
|
575
|
+
superClasse = this.avaliar(declaracao.superClasse);
|
|
552
576
|
if (!(superClasse instanceof classe_1.DeleguaClasse)) {
|
|
553
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(
|
|
577
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(declaracao.superClasse.nome, 'SuperClasse precisa ser uma classe.', declaracao.linha);
|
|
554
578
|
}
|
|
555
579
|
}
|
|
556
|
-
this.ambiente.definirVariavel(
|
|
557
|
-
if (
|
|
580
|
+
this.ambiente.definirVariavel(declaracao.simbolo.lexema, null);
|
|
581
|
+
if (declaracao.superClasse !== null) {
|
|
558
582
|
this.ambiente = new ambiente_1.Ambiente(this.ambiente);
|
|
559
|
-
this.ambiente.definirVariavel(
|
|
583
|
+
this.ambiente.definirVariavel('super', superClasse);
|
|
560
584
|
}
|
|
561
585
|
var metodos = {};
|
|
562
|
-
var definirMetodos =
|
|
563
|
-
for (var i = 0; i <
|
|
586
|
+
var definirMetodos = declaracao.metodos;
|
|
587
|
+
for (var i = 0; i < declaracao.metodos.length; i++) {
|
|
564
588
|
var metodoAtual = definirMetodos[i];
|
|
565
|
-
var eInicializado = metodoAtual.
|
|
566
|
-
var funcao = new funcao_1.DeleguaFuncao(metodoAtual.
|
|
567
|
-
metodos[metodoAtual.
|
|
589
|
+
var eInicializado = metodoAtual.simbolo.lexema === 'construtor';
|
|
590
|
+
var funcao = new funcao_1.DeleguaFuncao(metodoAtual.simbolo.lexema, metodoAtual.funcao, this.ambiente, eInicializado);
|
|
591
|
+
metodos[metodoAtual.simbolo.lexema] = funcao;
|
|
568
592
|
}
|
|
569
|
-
var criado = new classe_1.DeleguaClasse(
|
|
593
|
+
var criado = new classe_1.DeleguaClasse(declaracao.simbolo.lexema, superClasse, metodos);
|
|
570
594
|
if (superClasse !== null) {
|
|
571
595
|
this.ambiente = this.ambiente.enclosing;
|
|
572
596
|
}
|
|
573
|
-
this.ambiente.atribuirVariavel(
|
|
597
|
+
this.ambiente.atribuirVariavel(declaracao.simbolo, criado);
|
|
574
598
|
return null;
|
|
575
599
|
};
|
|
576
|
-
InterpretadorEguaClassico.prototype.
|
|
577
|
-
var objeto = this.avaliar(
|
|
600
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoAcessoMetodo = function (expressao) {
|
|
601
|
+
var objeto = this.avaliar(expressao.objeto);
|
|
578
602
|
if (objeto instanceof instancia_1.DeleguaInstancia) {
|
|
579
|
-
return objeto.get(
|
|
603
|
+
return objeto.get(expressao.simbolo) || null;
|
|
580
604
|
}
|
|
581
605
|
else if (objeto.constructor === Object) {
|
|
582
|
-
return objeto[
|
|
606
|
+
return objeto[expressao.simbolo.lexema] || null;
|
|
583
607
|
}
|
|
584
608
|
else if (objeto instanceof modulo_1.DeleguaModulo) {
|
|
585
|
-
return objeto[
|
|
609
|
+
return objeto[expressao.simbolo.lexema] || null;
|
|
586
610
|
}
|
|
587
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(
|
|
611
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.nome, 'Você só pode acessar métodos do objeto e dicionários.', expressao.linha);
|
|
588
612
|
};
|
|
589
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoIsto = function (
|
|
590
|
-
return this.procurarVariavel(
|
|
613
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoIsto = function (expressao) {
|
|
614
|
+
return this.procurarVariavel(expressao.palavraChave, expressao);
|
|
591
615
|
};
|
|
592
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoDicionario = function (
|
|
616
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDicionario = function (expressao) {
|
|
593
617
|
var dicionario = {};
|
|
594
|
-
for (var i = 0; i <
|
|
595
|
-
dicionario[this.avaliar(
|
|
618
|
+
for (var i = 0; i < expressao.chaves.length; i++) {
|
|
619
|
+
dicionario[this.avaliar(expressao.chaves[i])] = this.avaliar(expressao.valores[i]);
|
|
596
620
|
}
|
|
597
621
|
return dicionario;
|
|
598
622
|
};
|
|
599
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoVetor = function (
|
|
623
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoVetor = function (expressao) {
|
|
600
624
|
var valores = [];
|
|
601
|
-
for (var i = 0; i <
|
|
602
|
-
valores.push(this.avaliar(
|
|
625
|
+
for (var i = 0; i < expressao.valores.length; i++) {
|
|
626
|
+
valores.push(this.avaliar(expressao.valores[i]));
|
|
603
627
|
}
|
|
604
628
|
return valores;
|
|
605
629
|
};
|
|
606
|
-
InterpretadorEguaClassico.prototype.visitarExpressaoSuper = function (
|
|
607
|
-
var distancia = this.locais.get(
|
|
608
|
-
var superClasse = this.ambiente.obterVariavelEm(distancia,
|
|
609
|
-
var objeto = this.ambiente.obterVariavelEm(distancia - 1,
|
|
610
|
-
var metodo = superClasse.encontrarMetodo(
|
|
630
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoSuper = function (expressao) {
|
|
631
|
+
var distancia = this.locais.get(expressao);
|
|
632
|
+
var superClasse = this.ambiente.obterVariavelEm(distancia, 'super');
|
|
633
|
+
var objeto = this.ambiente.obterVariavelEm(distancia - 1, 'isto');
|
|
634
|
+
var metodo = superClasse.encontrarMetodo(expressao.metodo.lexema);
|
|
611
635
|
if (metodo === undefined) {
|
|
612
|
-
throw new excecoes_1.ErroEmTempoDeExecucao(
|
|
636
|
+
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.metodo, 'Método chamado indefinido.', expressao.linha);
|
|
613
637
|
}
|
|
614
638
|
return metodo.definirEscopo(objeto);
|
|
615
639
|
};
|
|
616
640
|
InterpretadorEguaClassico.prototype.paraTexto = function (objeto) {
|
|
617
641
|
if (objeto === null)
|
|
618
|
-
return
|
|
619
|
-
if (typeof objeto ===
|
|
620
|
-
return objeto ?
|
|
642
|
+
return 'nulo';
|
|
643
|
+
if (typeof objeto === 'boolean') {
|
|
644
|
+
return objeto ? 'verdadeiro' : 'falso';
|
|
621
645
|
}
|
|
622
646
|
if (objeto instanceof Date) {
|
|
623
|
-
var formato = Intl.DateTimeFormat(
|
|
624
|
-
dateStyle:
|
|
625
|
-
timeStyle:
|
|
647
|
+
var formato = Intl.DateTimeFormat('pt', {
|
|
648
|
+
dateStyle: 'full',
|
|
649
|
+
timeStyle: 'full',
|
|
626
650
|
});
|
|
627
651
|
return formato.format(objeto);
|
|
628
652
|
}
|
|
629
653
|
if (Array.isArray(objeto))
|
|
630
654
|
return objeto;
|
|
631
|
-
if (typeof objeto ===
|
|
655
|
+
if (typeof objeto === 'object')
|
|
632
656
|
return JSON.stringify(objeto);
|
|
633
657
|
return objeto.toString();
|
|
634
658
|
};
|
|
635
|
-
InterpretadorEguaClassico.prototype.executar = function (
|
|
659
|
+
InterpretadorEguaClassico.prototype.executar = function (declaracao, mostrarResultado) {
|
|
636
660
|
if (mostrarResultado === void 0) { mostrarResultado = false; }
|
|
637
|
-
|
|
661
|
+
declaracao.aceitar(this);
|
|
638
662
|
};
|
|
639
|
-
InterpretadorEguaClassico.prototype.interpretar = function (declaracoes) {
|
|
663
|
+
InterpretadorEguaClassico.prototype.interpretar = function (declaracoes, locais) {
|
|
664
|
+
this.locais = locais;
|
|
665
|
+
this.erros = [];
|
|
640
666
|
try {
|
|
641
667
|
for (var i = 0; i < declaracoes.length; i++) {
|
|
642
668
|
this.executar(declaracoes[i], false);
|
|
643
669
|
}
|
|
644
670
|
}
|
|
645
671
|
catch (erro) {
|
|
646
|
-
this.
|
|
672
|
+
this.erros.push(erro);
|
|
647
673
|
}
|
|
674
|
+
return {
|
|
675
|
+
erros: this.erros
|
|
676
|
+
};
|
|
648
677
|
};
|
|
649
678
|
return InterpretadorEguaClassico;
|
|
650
679
|
}());
|