@designliquido/delegua 0.36.1 → 0.36.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analisador-semantico/analisador-semantico-base.d.ts +69 -69
- package/analisador-semantico/analisador-semantico-base.js +180 -180
- package/analisador-semantico/analisador-semantico.d.ts +59 -59
- package/analisador-semantico/analisador-semantico.js +442 -442
- package/analisador-semantico/analisador-semantico.js.map +1 -1
- package/analisador-semantico/index.d.ts +3 -3
- package/analisador-semantico/index.js +19 -19
- package/analisador-semantico/pilha-variaveis.d.ts +20 -20
- package/analisador-semantico/pilha-variaveis.js +25 -25
- package/avaliador-sintatico/avaliador-sintatico-base.d.ts +69 -69
- package/avaliador-sintatico/avaliador-sintatico-base.js +223 -223
- package/avaliador-sintatico/avaliador-sintatico-base.js.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico.d.ts +126 -126
- package/avaliador-sintatico/avaliador-sintatico.js +1093 -1093
- package/avaliador-sintatico/avaliador-sintatico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.d.ts +73 -73
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js +648 -648
- package/avaliador-sintatico/dialetos/avaliador-sintatico-egua-classico.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.d.ts +21 -21
- package/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.js +149 -149
- package/avaliador-sintatico/dialetos/avaliador-sintatico-guarani.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.d.ts +87 -87
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js +770 -770
- package/avaliador-sintatico/dialetos/avaliador-sintatico-pitugues.js.map +1 -1
- package/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-ipt.d.ts +34 -34
- package/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-ipt.js +168 -168
- package/avaliador-sintatico/dialetos/avaliador-sintatico-portugol-ipt.js.map +1 -1
- package/avaliador-sintatico/dialetos/index.d.ts +3 -3
- package/avaliador-sintatico/dialetos/index.js +19 -19
- package/avaliador-sintatico/erro-avaliador-sintatico.d.ts +5 -5
- package/avaliador-sintatico/erro-avaliador-sintatico.js +11 -11
- package/avaliador-sintatico/index.d.ts +6 -6
- package/avaliador-sintatico/index.js +22 -22
- package/avaliador-sintatico/micro-avaliador-sintatico-base.d.ts +27 -27
- package/avaliador-sintatico/micro-avaliador-sintatico-base.js +116 -116
- package/avaliador-sintatico/micro-avaliador-sintatico-base.js.map +1 -1
- package/avaliador-sintatico/micro-avaliador-sintatico.d.ts +33 -33
- package/avaliador-sintatico/micro-avaliador-sintatico.js +287 -287
- package/avaliador-sintatico/micro-avaliador-sintatico.js.map +1 -1
- package/avaliador-sintatico/retornos/index.d.ts +3 -3
- package/avaliador-sintatico/retornos/index.js +19 -19
- package/avaliador-sintatico/retornos/retorno-declaracao.d.ts +3 -3
- package/avaliador-sintatico/retornos/retorno-declaracao.js +2 -2
- package/avaliador-sintatico/retornos/retorno-primario.d.ts +3 -3
- package/avaliador-sintatico/retornos/retorno-primario.js +2 -2
- package/avaliador-sintatico/retornos/retorno-resolver-declaracao.d.ts +2 -2
- package/avaliador-sintatico/retornos/retorno-resolver-declaracao.js +2 -2
- package/avaliador-sintatico/traducao/avaliador-sintatico-javascript.d.ts +59 -59
- package/avaliador-sintatico/traducao/avaliador-sintatico-javascript.js +150 -150
- package/bibliotecas/biblioteca-global.d.ts +157 -157
- package/bibliotecas/biblioteca-global.js +497 -498
- package/bibliotecas/biblioteca-global.js.map +1 -1
- package/bibliotecas/dialetos/egua-classico/biblioteca-global.d.ts +1 -1
- package/bibliotecas/dialetos/egua-classico/biblioteca-global.js +236 -236
- package/bibliotecas/dialetos/egua-classico/biblioteca-global.js.map +1 -1
- package/bibliotecas/dialetos/egua-classico/index.d.ts +2 -2
- package/bibliotecas/dialetos/egua-classico/index.js +32 -32
- package/bibliotecas/dialetos/egua-classico/index.js.map +1 -1
- package/bibliotecas/dialetos/egua-classico/matematica.d.ts +1 -1
- package/bibliotecas/dialetos/egua-classico/matematica.js +541 -541
- package/bibliotecas/dialetos/egua-classico/matematica.js.map +1 -1
- package/bibliotecas/dialetos/egua-classico/tempo.d.ts +1 -1
- package/bibliotecas/dialetos/egua-classico/tempo.js +39 -39
- package/bibliotecas/dialetos/egua-classico/tempo.js.map +1 -1
- package/bibliotecas/dialetos/egua-classico/textos.d.ts +8 -8
- package/bibliotecas/dialetos/egua-classico/textos.js +201 -201
- package/bibliotecas/dialetos/egua-classico/textos.js.map +1 -1
- package/bibliotecas/primitivas-dicionario.d.ts +6 -6
- package/bibliotecas/primitivas-dicionario.d.ts.map +1 -1
- package/bibliotecas/primitivas-dicionario.js +10 -10
- package/bibliotecas/primitivas-numero.d.ts +6 -6
- package/bibliotecas/primitivas-numero.d.ts.map +1 -1
- package/bibliotecas/primitivas-numero.js +10 -10
- package/bibliotecas/primitivas-texto.d.ts +17 -17
- package/bibliotecas/primitivas-texto.d.ts.map +1 -1
- package/bibliotecas/primitivas-texto.js +22 -22
- package/bibliotecas/primitivas-texto.js.map +1 -1
- package/bibliotecas/primitivas-vetor.d.ts +21 -21
- package/bibliotecas/primitivas-vetor.d.ts.map +1 -1
- package/bibliotecas/primitivas-vetor.js +90 -90
- package/bibliotecas/primitivas-vetor.js.map +1 -1
- package/bin/package.json +5 -4
- package/construtos/acesso-elemento-matriz.d.ts +12 -12
- package/construtos/acesso-elemento-matriz.js +17 -17
- package/construtos/acesso-indice-variavel.d.ts +15 -15
- package/construtos/acesso-indice-variavel.js +20 -20
- package/construtos/acesso-metodo-ou-propriedade.d.ts +14 -14
- package/construtos/acesso-metodo-ou-propriedade.js +19 -19
- package/construtos/agrupamento.d.ts +14 -14
- package/construtos/agrupamento.js +19 -19
- package/construtos/atribuicao-por-indice.d.ts +11 -11
- package/construtos/atribuicao-por-indice.js +16 -16
- package/construtos/atribuicao-por-indices-matriz.d.ts +12 -12
- package/construtos/atribuicao-por-indices-matriz.js +17 -17
- package/construtos/atribuir.d.ts +15 -15
- package/construtos/atribuir.js +24 -24
- package/construtos/atribuir.js.map +1 -1
- package/construtos/binario.d.ts +33 -33
- package/construtos/binario.js +38 -38
- package/construtos/chamada.d.ts +15 -15
- package/construtos/chamada.js +21 -21
- package/construtos/comentario.d.ts +15 -15
- package/construtos/comentario.js +20 -20
- package/construtos/constante.d.ts +12 -12
- package/construtos/constante.js +17 -17
- package/construtos/construto.d.ts +7 -7
- package/construtos/construto.js +2 -2
- package/construtos/decorador.d.ts +14 -14
- package/construtos/decorador.js +19 -19
- package/construtos/definir-valor.d.ts +11 -11
- package/construtos/definir-valor.js +16 -16
- package/construtos/dicionario.d.ts +10 -10
- package/construtos/dicionario.js +15 -15
- package/construtos/expressao-regular.d.ts +10 -10
- package/construtos/expressao-regular.js +15 -15
- package/construtos/fim-para.d.ts +22 -22
- package/construtos/fim-para.js +25 -25
- package/construtos/formatacao-escrita.d.ts +16 -16
- package/construtos/formatacao-escrita.js +21 -21
- package/construtos/funcao.d.ts +12 -12
- package/construtos/funcao.js +16 -16
- package/construtos/index.d.ts +29 -29
- package/construtos/index.js +45 -45
- package/construtos/isto.d.ts +9 -9
- package/construtos/isto.js +14 -14
- package/construtos/literal.d.ts +10 -10
- package/construtos/literal.js +14 -14
- package/construtos/logico.d.ts +11 -11
- package/construtos/logico.js +16 -16
- package/construtos/qual-tipo.d.ts +11 -11
- package/construtos/qual-tipo.js +16 -16
- package/construtos/super.d.ts +10 -10
- package/construtos/super.js +15 -15
- package/construtos/tipo-de.d.ts +10 -10
- package/construtos/tipo-de.js +15 -15
- package/construtos/tuplas/deceto.d.ts +18 -18
- package/construtos/tuplas/deceto.js +32 -32
- package/construtos/tuplas/dupla.d.ts +6 -6
- package/construtos/tuplas/dupla.js +12 -12
- package/construtos/tuplas/index.d.ts +13 -13
- package/construtos/tuplas/index.js +67 -67
- package/construtos/tuplas/index.js.map +1 -1
- package/construtos/tuplas/noneto.d.ts +15 -15
- package/construtos/tuplas/noneto.js +25 -25
- package/construtos/tuplas/octeto.d.ts +14 -14
- package/construtos/tuplas/octeto.js +24 -24
- package/construtos/tuplas/quarteto.d.ts +8 -8
- package/construtos/tuplas/quarteto.js +14 -14
- package/construtos/tuplas/quinteto.d.ts +9 -9
- package/construtos/tuplas/quinteto.js +15 -15
- package/construtos/tuplas/septeto.d.ts +13 -13
- package/construtos/tuplas/septeto.js +23 -23
- package/construtos/tuplas/sexteto.d.ts +10 -10
- package/construtos/tuplas/sexteto.js +16 -16
- package/construtos/tuplas/trio.d.ts +7 -7
- package/construtos/tuplas/trio.js +13 -13
- package/construtos/tuplas/tupla.d.ts +8 -8
- package/construtos/tuplas/tupla.js +9 -9
- package/construtos/unario.d.ts +11 -11
- package/construtos/unario.js +16 -16
- package/construtos/variavel.d.ts +9 -9
- package/construtos/variavel.js +14 -14
- package/construtos/vetor.d.ts +11 -11
- package/construtos/vetor.js +21 -21
- package/construtos/vetor.js.map +1 -1
- package/declaracoes/aleatorio.d.ts +15 -15
- package/declaracoes/aleatorio.js +15 -15
- package/declaracoes/bloco.d.ts +7 -7
- package/declaracoes/bloco.js +14 -14
- package/declaracoes/cabecalho-programa.d.ts +7 -7
- package/declaracoes/cabecalho-programa.js +14 -14
- package/declaracoes/classe.d.ts +14 -14
- package/declaracoes/classe.js +18 -18
- package/declaracoes/const-multiplo.d.ts +14 -14
- package/declaracoes/const-multiplo.js +19 -19
- package/declaracoes/const.d.ts +14 -14
- package/declaracoes/const.js +19 -19
- package/declaracoes/continua.d.ts +6 -6
- package/declaracoes/continua.js +13 -13
- package/declaracoes/declaracao.d.ts +8 -8
- package/declaracoes/declaracao.js +17 -17
- package/declaracoes/enquanto.d.ts +10 -10
- package/declaracoes/enquanto.js +15 -15
- package/declaracoes/escolha.d.ts +14 -14
- package/declaracoes/escolha.js +19 -19
- package/declaracoes/escreva-mesma-linha.d.ts +8 -8
- package/declaracoes/escreva-mesma-linha.js +14 -14
- package/declaracoes/escreva.d.ts +8 -8
- package/declaracoes/escreva.js +14 -14
- package/declaracoes/expressao.d.ts +8 -8
- package/declaracoes/expressao.js +14 -14
- package/declaracoes/falhar.d.ts +8 -8
- package/declaracoes/falhar.js +15 -15
- package/declaracoes/fazer.d.ts +10 -10
- package/declaracoes/fazer.js +15 -15
- package/declaracoes/funcao.d.ts +11 -11
- package/declaracoes/funcao.js +17 -17
- package/declaracoes/importar.d.ts +9 -9
- package/declaracoes/importar.js +15 -15
- package/declaracoes/index.d.ts +31 -31
- package/declaracoes/index.js +47 -47
- package/declaracoes/inicio-algoritmo.d.ts +6 -6
- package/declaracoes/inicio-algoritmo.js +13 -13
- package/declaracoes/leia-multiplo.d.ts +14 -14
- package/declaracoes/leia-multiplo.js +21 -21
- package/declaracoes/leia.d.ts +17 -17
- package/declaracoes/leia.js +21 -21
- package/declaracoes/para-cada.d.ts +11 -11
- package/declaracoes/para-cada.js +17 -17
- package/declaracoes/para.d.ts +19 -19
- package/declaracoes/para.js +24 -24
- package/declaracoes/propriedade-classe.d.ts +10 -10
- package/declaracoes/propriedade-classe.js +16 -16
- package/declaracoes/retorna.d.ts +8 -8
- package/declaracoes/retorna.js +15 -15
- package/declaracoes/se.d.ts +11 -11
- package/declaracoes/se.js +17 -17
- package/declaracoes/sustar.d.ts +6 -6
- package/declaracoes/sustar.js +13 -13
- package/declaracoes/tendo-como.d.ts +16 -16
- package/declaracoes/tendo-como.js +21 -21
- package/declaracoes/tente.d.ts +14 -14
- package/declaracoes/tente.js +20 -20
- package/declaracoes/var-multiplo.d.ts +15 -15
- package/declaracoes/var-multiplo.js +20 -20
- package/declaracoes/var.d.ts +16 -16
- package/declaracoes/var.js +21 -21
- package/depuracao/cyrb53.d.ts +9 -9
- package/depuracao/cyrb53.js +22 -22
- package/depuracao/cyrb53.js.map +1 -1
- package/depuracao/index.d.ts +2 -2
- package/depuracao/index.js +23 -23
- package/depuracao/ponto-parada.d.ts +4 -4
- package/depuracao/ponto-parada.js +2 -2
- package/espaco-variaveis.d.ts +19 -19
- package/espaco-variaveis.js +19 -19
- package/estruturas/chamavel.d.ts +7 -7
- package/estruturas/chamavel.js +12 -12
- package/estruturas/classe-padrao.d.ts +31 -31
- package/estruturas/classe-padrao.js +39 -39
- package/estruturas/delegua-funcao.d.ts +29 -29
- package/estruturas/delegua-funcao.js +141 -141
- package/estruturas/delegua-funcao.js.map +1 -1
- package/estruturas/descritor-tipo-classe.d.ts +37 -37
- package/estruturas/descritor-tipo-classe.js +79 -79
- package/estruturas/descritor-tipo-classe.js.map +1 -1
- package/estruturas/funcao-padrao.d.ts +23 -23
- package/estruturas/funcao-padrao.js +34 -34
- package/estruturas/index.d.ts +9 -9
- package/estruturas/index.js +25 -25
- package/estruturas/metodo-primitiva.d.ts +28 -28
- package/estruturas/metodo-primitiva.js +40 -40
- package/estruturas/modulo.d.ts +18 -18
- package/estruturas/modulo.js +24 -24
- package/estruturas/objeto-delegua-classe.d.ts +26 -26
- package/estruturas/objeto-delegua-classe.js +53 -53
- package/estruturas/objeto-delegua-classe.js.map +1 -1
- package/estruturas/objeto-padrao.d.ts +18 -18
- package/estruturas/objeto-padrao.js +32 -32
- package/estruturas/objeto-padrao.js.map +1 -1
- package/excecoes/erro-em-tempo-de-execucao.d.ts +7 -7
- package/excecoes/erro-em-tempo-de-execucao.js +13 -13
- package/excecoes/index.d.ts +1 -1
- package/excecoes/index.js +17 -17
- package/formatadores/formatador-delegua.d.ts +79 -79
- package/formatadores/formatador-delegua.js +676 -676
- package/formatadores/formatador-delegua.js.map +1 -1
- package/formatadores/index.d.ts +1 -1
- package/formatadores/index.js +17 -17
- package/geracao-identificadores/index.d.ts +1 -1
- package/geracao-identificadores/index.js +22 -23
- package/geracao-identificadores/index.js.map +1 -1
- package/index.d.ts +9 -9
- package/index.js +27 -27
- package/interfaces/analisador-semantico-interface.d.ts +6 -6
- package/interfaces/analisador-semantico-interface.js +2 -2
- package/interfaces/avaliador-sintatico-interface.d.ts +55 -55
- package/interfaces/avaliador-sintatico-interface.js +2 -2
- package/interfaces/construtos/index.d.ts +4 -4
- package/interfaces/construtos/index.js +2 -2
- package/interfaces/erros/diagnostico-analisador-semantico.d.ts +14 -14
- package/interfaces/erros/diagnostico-analisador-semantico.js +10 -10
- package/interfaces/erros/diagnostico-analisador-semantico.js.map +1 -1
- package/interfaces/erros/erro-interpretador.d.ts +8 -8
- package/interfaces/erros/erro-interpretador.js +2 -2
- package/interfaces/erros/index.d.ts +1 -1
- package/interfaces/erros/index.js +17 -17
- package/interfaces/escopo-execucao.d.ts +12 -12
- package/interfaces/escopo-execucao.js +2 -2
- package/interfaces/formatador-comum-interface.d.ts +11 -11
- package/interfaces/formatador-comum-interface.js +2 -2
- package/interfaces/funcao-hipotetica-interface.d.ts +3 -3
- package/interfaces/funcao-hipotetica-interface.js +2 -2
- package/interfaces/index.d.ts +16 -16
- package/interfaces/index.js +32 -32
- package/interfaces/interpretador-com-depuracao-interface.d.ts +17 -17
- package/interfaces/interpretador-com-depuracao-interface.js +2 -2
- package/interfaces/interpretador-interface-potigol.d.ts +5 -5
- package/interfaces/interpretador-interface-potigol.js +2 -2
- package/interfaces/interpretador-interface.d.ts +20 -20
- package/interfaces/interpretador-interface.js +2 -2
- package/interfaces/lexador-interface.d.ts +23 -23
- package/interfaces/lexador-interface.js +2 -2
- package/interfaces/parametro-interface.d.ts +15 -15
- package/interfaces/parametro-interface.js +2 -2
- package/interfaces/pilha-escopos-execucao-interface.d.ts +26 -26
- package/interfaces/pilha-escopos-execucao-interface.js +2 -2
- package/interfaces/pilha-interface.d.ts +7 -7
- package/interfaces/pilha-interface.js +2 -2
- package/interfaces/resolvedor-interface.d.ts +41 -41
- package/interfaces/resolvedor-interface.js +2 -2
- package/interfaces/retornos/index.d.ts +4 -4
- package/interfaces/retornos/index.js +20 -20
- package/interfaces/retornos/retorno-analisador-semantico.d.ts +4 -4
- package/interfaces/retornos/retorno-analisador-semantico.js +2 -2
- package/interfaces/retornos/retorno-avaliador-sintatico.d.ts +5 -5
- package/interfaces/retornos/retorno-avaliador-sintatico.js +2 -2
- package/interfaces/retornos/retorno-execucao-interface.d.ts +5 -5
- package/interfaces/retornos/retorno-execucao-interface.js +2 -2
- package/interfaces/retornos/retorno-interpretador.d.ts +5 -5
- package/interfaces/retornos/retorno-interpretador.js +2 -2
- package/interfaces/retornos/retorno-lexador.d.ts +9 -9
- package/interfaces/retornos/retorno-lexador.js +2 -2
- package/interfaces/simbolo-interface.d.ts +7 -7
- package/interfaces/simbolo-interface.js +2 -2
- package/interfaces/tradutor-interface.d.ts +3 -3
- package/interfaces/tradutor-interface.js +2 -2
- package/interfaces/variavel-hipotetica-interface.d.ts +8 -8
- package/interfaces/variavel-hipotetica-interface.js +2 -2
- package/interfaces/variavel-interface.d.ts +8 -8
- package/interfaces/variavel-interface.js +2 -2
- package/interfaces/visitante-comum-interface.d.ts +58 -58
- package/interfaces/visitante-comum-interface.js +2 -2
- package/interpretador/argumento-interface.d.ts +4 -4
- package/interpretador/argumento-interface.js +2 -2
- package/interpretador/comum.d.ts +2 -2
- package/interpretador/comum.js +51 -52
- package/interpretador/comum.js.map +1 -1
- package/interpretador/dialetos/egua-classico/index.d.ts +1 -1
- package/interpretador/dialetos/egua-classico/index.js +17 -17
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.d.ts +119 -119
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.js +815 -815
- package/interpretador/dialetos/egua-classico/interpretador-egua-classico.js.map +1 -1
- package/interpretador/dialetos/egua-classico/resolvedor/erro-resolvedor.d.ts +5 -5
- package/interpretador/dialetos/egua-classico/resolvedor/erro-resolvedor.js +11 -11
- package/interpretador/dialetos/egua-classico/resolvedor/index.d.ts +3 -3
- package/interpretador/dialetos/egua-classico/resolvedor/index.js +19 -19
- package/interpretador/dialetos/egua-classico/resolvedor/pilha-escopos.d.ts +9 -9
- package/interpretador/dialetos/egua-classico/resolvedor/pilha-escopos.js +25 -25
- package/interpretador/dialetos/egua-classico/resolvedor/resolvedor.d.ts +106 -106
- package/interpretador/dialetos/egua-classico/resolvedor/resolvedor.js +441 -441
- package/interpretador/dialetos/egua-classico/resolvedor/resolvedor.js.map +1 -1
- package/interpretador/dialetos/egua-classico/resolvedor/retorno-resolvedor.d.ts +6 -6
- package/interpretador/dialetos/egua-classico/resolvedor/retorno-resolvedor.js +2 -2
- package/interpretador/dialetos/index.d.ts +2 -2
- package/interpretador/dialetos/index.js +18 -18
- package/interpretador/dialetos/portugol-ipt/index.d.ts +1 -1
- package/interpretador/dialetos/portugol-ipt/index.js +17 -17
- package/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.d.ts +133 -133
- package/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.js +501 -501
- package/interpretador/dialetos/portugol-ipt/interpretador-portugol-ipt.js.map +1 -1
- package/interpretador/index.d.ts +3 -3
- package/interpretador/index.js +19 -19
- package/interpretador/inferenciador.d.ts +15 -15
- package/interpretador/inferenciador.d.ts.map +1 -1
- package/interpretador/inferenciador.js +80 -80
- package/interpretador/inferenciador.js.map +1 -1
- package/interpretador/interpretador-base.d.ts +268 -268
- package/interpretador/interpretador-base.js +1399 -1399
- package/interpretador/interpretador-base.js.map +1 -1
- package/interpretador/interpretador-com-depuracao.d.ts +190 -190
- package/interpretador/interpretador-com-depuracao.js +568 -568
- package/interpretador/interpretador-com-depuracao.js.map +1 -1
- package/interpretador/pilha-escopos-execucao.d.ts +39 -39
- package/interpretador/pilha-escopos-execucao.js +243 -243
- package/interpretador/pilha-escopos-execucao.js.map +1 -1
- package/lexador/dialetos/index.d.ts +4 -4
- package/lexador/dialetos/index.js +20 -20
- package/lexador/dialetos/lexador-egua-classico.d.ts +36 -36
- package/lexador/dialetos/lexador-egua-classico.js +286 -286
- package/lexador/dialetos/lexador-egua-classico.js.map +1 -1
- package/lexador/dialetos/lexador-guarani.d.ts +10 -10
- package/lexador/dialetos/lexador-guarani.js +113 -113
- package/lexador/dialetos/lexador-guarani.js.map +1 -1
- package/lexador/dialetos/lexador-pitugues.d.ts +51 -51
- package/lexador/dialetos/lexador-pitugues.js +398 -398
- package/lexador/dialetos/lexador-pitugues.js.map +1 -1
- package/lexador/dialetos/lexador-portugol-ipt.d.ts +33 -33
- package/lexador/dialetos/lexador-portugol-ipt.js +237 -237
- package/lexador/dialetos/lexador-portugol-ipt.js.map +1 -1
- package/lexador/dialetos/palavras-reservadas/egua-classico.d.ts +32 -32
- package/lexador/dialetos/palavras-reservadas/egua-classico.js +39 -39
- package/lexador/dialetos/palavras-reservadas/guarani.d.ts +3 -3
- package/lexador/dialetos/palavras-reservadas/guarani.js +10 -10
- package/lexador/dialetos/palavras-reservadas/portugol-ipt.d.ts +13 -13
- package/lexador/dialetos/palavras-reservadas/portugol-ipt.js +20 -20
- package/lexador/dialetos/palavras-reservadas/rantiaquin.d.ts +1 -1
- package/lexador/dialetos/palavras-reservadas/rantiaquin.js +4 -4
- package/lexador/dialetos/pragma.d.ts +8 -8
- package/lexador/dialetos/pragma.js +2 -2
- package/lexador/erro-lexador.d.ts +5 -5
- package/lexador/erro-lexador.js +2 -2
- package/lexador/index.d.ts +4 -4
- package/lexador/index.js +20 -20
- package/lexador/lexador-base-linha-unica.d.ts +28 -28
- package/lexador/lexador-base-linha-unica.js +82 -82
- package/lexador/lexador-base-linha-unica.js.map +1 -1
- package/lexador/lexador-base.d.ts +41 -41
- package/lexador/lexador-base.js +112 -112
- package/lexador/lexador-base.js.map +1 -1
- package/lexador/lexador.d.ts +43 -43
- package/lexador/lexador.js +440 -440
- package/lexador/lexador.js.map +1 -1
- package/lexador/micro-lexador.d.ts +29 -29
- package/lexador/micro-lexador.js +207 -207
- package/lexador/micro-lexador.js.map +1 -1
- package/lexador/palavras-reservadas.d.ts +54 -54
- package/lexador/palavras-reservadas.js +61 -61
- package/lexador/simbolo.d.ts +10 -10
- package/lexador/simbolo.js +16 -16
- package/lexador/traducao/lexador-javascript.d.ts +28 -28
- package/lexador/traducao/lexador-javascript.js +58 -58
- package/package.json +5 -4
- package/quebras/index.d.ts +10 -10
- package/quebras/index.js +19 -19
- package/tipo-dados-elementar.d.ts +1 -1
- package/tipo-dados-elementar.js +2 -2
- package/tipos-de-dados/delegua.d.ts +18 -18
- package/tipos-de-dados/delegua.js +19 -19
- package/tipos-de-dados/listas-delegua.d.ts +6 -6
- package/tipos-de-dados/listas-delegua.js +7 -7
- package/tipos-de-dados/listas-primitivos.d.ts +5 -5
- package/tipos-de-dados/listas-primitivos.js +6 -6
- package/tipos-de-dados/primitivos.d.ts +16 -16
- package/tipos-de-dados/primitivos.js +17 -17
- package/tipos-de-simbolos/comum.d.ts +23 -23
- package/tipos-de-simbolos/comum.js +24 -24
- package/tipos-de-simbolos/delegua.d.ts +91 -91
- package/tipos-de-simbolos/delegua.js +92 -92
- package/tipos-de-simbolos/egua-classico.d.ts +75 -75
- package/tipos-de-simbolos/egua-classico.js +76 -76
- package/tipos-de-simbolos/guarani.d.ts +14 -14
- package/tipos-de-simbolos/guarani.js +15 -15
- package/tipos-de-simbolos/guarani.js.map +1 -1
- package/tipos-de-simbolos/microgramaticas/delegua.d.ts +46 -46
- package/tipos-de-simbolos/microgramaticas/delegua.js +47 -47
- package/tipos-de-simbolos/pitugues.d.ts +75 -75
- package/tipos-de-simbolos/pitugues.js +76 -76
- package/tipos-de-simbolos/portugol-ipt.d.ts +36 -36
- package/tipos-de-simbolos/portugol-ipt.js +37 -37
- package/tipos-de-simbolos/rantiaquin.d.ts +2 -2
- package/tipos-de-simbolos/rantiaquin.js +3 -3
- package/tradutores/dicionarios/dicionario-delegua-javascript.d.ts +2 -2
- package/tradutores/dicionarios/dicionario-delegua-javascript.js +10 -10
- package/tradutores/dicionarios/index.d.ts +1 -1
- package/tradutores/dicionarios/index.js +17 -17
- package/tradutores/index.d.ts +6 -6
- package/tradutores/index.js +22 -22
- package/tradutores/python/python3-lexer.d.ts +152 -152
- package/tradutores/python/python3-lexer.js +1227 -1227
- package/tradutores/python/python3-lexer.js.map +1 -1
- package/tradutores/python/python3-listener.d.ts +964 -964
- package/tradutores/python/python3-listener.js +3 -3
- package/tradutores/python/python3-parser.d.ts +1342 -1342
- package/tradutores/python/python3-parser.js +11226 -11226
- package/tradutores/python/python3-parser.js.map +1 -1
- package/tradutores/python/python3-visitor.d.ts +619 -619
- package/tradutores/python/python3-visitor.js +3 -3
- package/tradutores/tradutor-assembly-x64.d.ts +19 -19
- package/tradutores/tradutor-assembly-x64.js +128 -128
- package/tradutores/tradutor-assembly-x64.js.map +1 -1
- package/tradutores/tradutor-assemblyscript.d.ts +91 -91
- package/tradutores/tradutor-assemblyscript.js +590 -590
- package/tradutores/tradutor-assemblyscript.js.map +1 -1
- package/tradutores/tradutor-javascript.d.ts +95 -95
- package/tradutores/tradutor-javascript.js +577 -577
- package/tradutores/tradutor-javascript.js.map +1 -1
- package/tradutores/tradutor-portugol-ipt.d.ts +21 -21
- package/tradutores/tradutor-portugol-ipt.js +60 -60
- package/tradutores/tradutor-portugol-ipt.js.map +1 -1
- package/tradutores/tradutor-python.d.ts +65 -65
- package/tradutores/tradutor-python.js +461 -461
- package/tradutores/tradutor-python.js.map +1 -1
- package/tradutores/tradutor-reverso-javascript.d.ts +50 -50
- package/tradutores/tradutor-reverso-javascript.js +392 -392
- package/tradutores/tradutor-reverso-javascript.js.map +1 -1
- package/tradutores/tradutor-reverso-python.d.ts +32 -32
- package/tradutores/tradutor-reverso-python.js +71 -71
- package/tradutores/tradutor-reverso-python.js.map +1 -1
- package/umd/delegua.js +26337 -26340
package/lexador/lexador.js
CHANGED
|
@@ -1,441 +1,441 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Lexador = void 0;
|
|
7
|
-
const browser_process_hrtime_1 = __importDefault(require("browser-process-hrtime"));
|
|
8
|
-
const simbolo_1 = require("./simbolo");
|
|
9
|
-
const palavras_reservadas_1 = require("./palavras-reservadas");
|
|
10
|
-
const delegua_1 = __importDefault(require("../tipos-de-simbolos/delegua"));
|
|
11
|
-
/**
|
|
12
|
-
* O Lexador é responsável por transformar o código em uma coleção de tokens de linguagem.
|
|
13
|
-
* Cada token de linguagem é representado por um tipo, um lexema e informações da linha de código em que foi expresso.
|
|
14
|
-
* Também é responsável por mapear as palavras reservadas da linguagem, que não podem ser usadas por outras
|
|
15
|
-
* estruturas, tais como nomes de variáveis, funções, literais, classes e assim por diante.
|
|
16
|
-
*/
|
|
17
|
-
class Lexador {
|
|
18
|
-
constructor(performance = false) {
|
|
19
|
-
this.performance = performance;
|
|
20
|
-
this.simbolos = [];
|
|
21
|
-
this.erros = [];
|
|
22
|
-
this.hashArquivo = -1;
|
|
23
|
-
this.inicioSimbolo = 0;
|
|
24
|
-
this.atual = 0;
|
|
25
|
-
this.linha = 0;
|
|
26
|
-
}
|
|
27
|
-
eDigito(caractere) {
|
|
28
|
-
return caractere >= '0' && caractere <= '9';
|
|
29
|
-
}
|
|
30
|
-
eAlfabeto(caractere) {
|
|
31
|
-
const acentuacoes = [
|
|
32
|
-
'á',
|
|
33
|
-
'Á',
|
|
34
|
-
'ã',
|
|
35
|
-
'Ã',
|
|
36
|
-
'â',
|
|
37
|
-
'Â',
|
|
38
|
-
'à',
|
|
39
|
-
'À',
|
|
40
|
-
'é',
|
|
41
|
-
'É',
|
|
42
|
-
'ê',
|
|
43
|
-
'Ê',
|
|
44
|
-
'í',
|
|
45
|
-
'Í',
|
|
46
|
-
'ó',
|
|
47
|
-
'Ó',
|
|
48
|
-
'õ',
|
|
49
|
-
'Õ',
|
|
50
|
-
'ô',
|
|
51
|
-
'Ô',
|
|
52
|
-
'ú',
|
|
53
|
-
'Ú',
|
|
54
|
-
'ç',
|
|
55
|
-
'Ç',
|
|
56
|
-
'_',
|
|
57
|
-
];
|
|
58
|
-
return ((caractere >= 'a' && caractere <= 'z') ||
|
|
59
|
-
(caractere >= 'A' && caractere <= 'Z') ||
|
|
60
|
-
acentuacoes.includes(caractere));
|
|
61
|
-
}
|
|
62
|
-
eAlfabetoOuDigito(caractere) {
|
|
63
|
-
return this.eDigito(caractere) || this.eAlfabeto(caractere);
|
|
64
|
-
}
|
|
65
|
-
eFinalDaLinha() {
|
|
66
|
-
if (this.codigo.length === this.linha) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
return this.atual >= this.codigo[this.linha].length;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Indica se o código está na última linha.
|
|
73
|
-
* @returns Verdadeiro se contador de linhas está na última linha.
|
|
74
|
-
* Falso caso contrário.
|
|
75
|
-
*/
|
|
76
|
-
eUltimaLinha() {
|
|
77
|
-
return this.linha >= this.codigo.length - 1;
|
|
78
|
-
}
|
|
79
|
-
eFinalDoCodigo() {
|
|
80
|
-
return this.eUltimaLinha() && this.codigo[this.codigo.length - 1].length <= this.atual;
|
|
81
|
-
}
|
|
82
|
-
avancar() {
|
|
83
|
-
this.atual += 1;
|
|
84
|
-
if (this.eFinalDaLinha() && !this.eUltimaLinha()) {
|
|
85
|
-
this.linha++;
|
|
86
|
-
this.atual = 0;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
adicionarSimbolo(tipo, literal = null) {
|
|
90
|
-
const texto = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
91
|
-
this.simbolos.push(new simbolo_1.Simbolo(tipo, literal || texto, literal, this.linha + 1, this.hashArquivo));
|
|
92
|
-
}
|
|
93
|
-
simboloAtual() {
|
|
94
|
-
if (this.eFinalDaLinha())
|
|
95
|
-
return '\0';
|
|
96
|
-
return this.codigo[this.linha].charAt(this.atual);
|
|
97
|
-
}
|
|
98
|
-
comentarioMultilinha() {
|
|
99
|
-
let conteudo = '';
|
|
100
|
-
while (!this.eFinalDoCodigo()) {
|
|
101
|
-
this.avancar();
|
|
102
|
-
conteudo += this.codigo[this.linha].charAt(this.atual);
|
|
103
|
-
if (this.simboloAtual() === '*' && this.proximoSimbolo() === '/') {
|
|
104
|
-
const linhas = conteudo.split('\0');
|
|
105
|
-
for (let linha of linhas) {
|
|
106
|
-
this.adicionarSimbolo(delegua_1.default.LINHA_COMENTARIO, linha.trim());
|
|
107
|
-
}
|
|
108
|
-
// Remove o asterisco da última linha
|
|
109
|
-
let lexemaUltimaLinha = this.simbolos[this.simbolos.length - 1].lexema;
|
|
110
|
-
lexemaUltimaLinha = lexemaUltimaLinha.substring(0, lexemaUltimaLinha.length - 1);
|
|
111
|
-
this.simbolos[this.simbolos.length - 1].lexema = lexemaUltimaLinha;
|
|
112
|
-
this.simbolos[this.simbolos.length - 1].literal = lexemaUltimaLinha;
|
|
113
|
-
this.avancar();
|
|
114
|
-
this.avancar();
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
comentarioUmaLinha() {
|
|
120
|
-
this.avancar();
|
|
121
|
-
const linhaAtual = this.linha;
|
|
122
|
-
let ultimoAtual = this.atual;
|
|
123
|
-
while (linhaAtual === this.linha && !this.eFinalDoCodigo()) {
|
|
124
|
-
ultimoAtual = this.atual;
|
|
125
|
-
this.avancar();
|
|
126
|
-
}
|
|
127
|
-
const conteudo = this.codigo[linhaAtual].substring(this.inicioSimbolo + 2, ultimoAtual);
|
|
128
|
-
this.adicionarSimbolo(delegua_1.default.COMENTARIO, conteudo.trim());
|
|
129
|
-
}
|
|
130
|
-
proximoSimbolo() {
|
|
131
|
-
return this.codigo[this.linha].charAt(this.atual + 1);
|
|
132
|
-
}
|
|
133
|
-
simboloAnterior() {
|
|
134
|
-
return this.codigo[this.linha].charAt(this.atual - 1);
|
|
135
|
-
}
|
|
136
|
-
analisarTexto(delimitador = '"') {
|
|
137
|
-
while (this.simboloAtual() !== delimitador && !this.eFinalDoCodigo()) {
|
|
138
|
-
this.avancar();
|
|
139
|
-
}
|
|
140
|
-
if (this.eFinalDoCodigo()) {
|
|
141
|
-
this.erros.push({
|
|
142
|
-
linha: this.linha + 1,
|
|
143
|
-
caractere: this.simboloAnterior(),
|
|
144
|
-
mensagem: 'Texto não finalizado.',
|
|
145
|
-
});
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const valor = this.codigo[this.linha].substring(this.inicioSimbolo + 1, this.atual);
|
|
149
|
-
this.adicionarSimbolo(delegua_1.default.TEXTO, valor);
|
|
150
|
-
}
|
|
151
|
-
analisarNumero() {
|
|
152
|
-
while (this.eDigito(this.simboloAtual())) {
|
|
153
|
-
this.avancar();
|
|
154
|
-
}
|
|
155
|
-
if (this.simboloAtual() == '.' && this.eDigito(this.proximoSimbolo())) {
|
|
156
|
-
this.avancar();
|
|
157
|
-
while (this.eDigito(this.simboloAtual())) {
|
|
158
|
-
this.avancar();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const numeroCompleto = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
162
|
-
this.adicionarSimbolo(delegua_1.default.NUMERO, parseFloat(numeroCompleto));
|
|
163
|
-
}
|
|
164
|
-
identificarPalavraChave() {
|
|
165
|
-
while (this.eAlfabetoOuDigito(this.simboloAtual())) {
|
|
166
|
-
this.avancar();
|
|
167
|
-
}
|
|
168
|
-
const codigo = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
169
|
-
const tipo = codigo in palavras_reservadas_1.palavrasReservadas ? palavras_reservadas_1.palavrasReservadas[codigo] : delegua_1.default.IDENTIFICADOR;
|
|
170
|
-
this.adicionarSimbolo(tipo);
|
|
171
|
-
}
|
|
172
|
-
analisarToken() {
|
|
173
|
-
const caractere = this.simboloAtual();
|
|
174
|
-
switch (caractere) {
|
|
175
|
-
case '@':
|
|
176
|
-
this.adicionarSimbolo(delegua_1.default.ARROBA, '@');
|
|
177
|
-
this.avancar();
|
|
178
|
-
break;
|
|
179
|
-
case '[':
|
|
180
|
-
this.adicionarSimbolo(delegua_1.default.COLCHETE_ESQUERDO);
|
|
181
|
-
this.avancar();
|
|
182
|
-
break;
|
|
183
|
-
case ']':
|
|
184
|
-
this.adicionarSimbolo(delegua_1.default.COLCHETE_DIREITO);
|
|
185
|
-
this.avancar();
|
|
186
|
-
break;
|
|
187
|
-
case '(':
|
|
188
|
-
this.adicionarSimbolo(delegua_1.default.PARENTESE_ESQUERDO);
|
|
189
|
-
this.avancar();
|
|
190
|
-
break;
|
|
191
|
-
case ')':
|
|
192
|
-
this.adicionarSimbolo(delegua_1.default.PARENTESE_DIREITO);
|
|
193
|
-
this.avancar();
|
|
194
|
-
break;
|
|
195
|
-
case '{':
|
|
196
|
-
this.adicionarSimbolo(delegua_1.default.CHAVE_ESQUERDA);
|
|
197
|
-
this.avancar();
|
|
198
|
-
break;
|
|
199
|
-
case '}':
|
|
200
|
-
this.adicionarSimbolo(delegua_1.default.CHAVE_DIREITA);
|
|
201
|
-
this.avancar();
|
|
202
|
-
break;
|
|
203
|
-
case ',':
|
|
204
|
-
this.adicionarSimbolo(delegua_1.default.VIRGULA);
|
|
205
|
-
this.avancar();
|
|
206
|
-
break;
|
|
207
|
-
case '.':
|
|
208
|
-
this.adicionarSimbolo(delegua_1.default.PONTO);
|
|
209
|
-
this.avancar();
|
|
210
|
-
break;
|
|
211
|
-
case '-':
|
|
212
|
-
this.inicioSimbolo = this.atual;
|
|
213
|
-
this.avancar();
|
|
214
|
-
if (this.simboloAtual() === '=') {
|
|
215
|
-
this.adicionarSimbolo(delegua_1.default.MENOS_IGUAL);
|
|
216
|
-
this.avancar();
|
|
217
|
-
}
|
|
218
|
-
else if (this.simboloAtual() === '-') {
|
|
219
|
-
this.adicionarSimbolo(delegua_1.default.DECREMENTAR);
|
|
220
|
-
this.avancar();
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
this.adicionarSimbolo(delegua_1.default.SUBTRACAO);
|
|
224
|
-
}
|
|
225
|
-
break;
|
|
226
|
-
case '+':
|
|
227
|
-
this.inicioSimbolo = this.atual;
|
|
228
|
-
this.avancar();
|
|
229
|
-
if (this.simboloAtual() === '=') {
|
|
230
|
-
this.adicionarSimbolo(delegua_1.default.MAIS_IGUAL);
|
|
231
|
-
this.avancar();
|
|
232
|
-
}
|
|
233
|
-
else if (this.simboloAtual() === '+') {
|
|
234
|
-
this.adicionarSimbolo(delegua_1.default.INCREMENTAR);
|
|
235
|
-
this.avancar();
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
this.adicionarSimbolo(delegua_1.default.ADICAO);
|
|
239
|
-
}
|
|
240
|
-
break;
|
|
241
|
-
case ':':
|
|
242
|
-
this.adicionarSimbolo(delegua_1.default.DOIS_PONTOS);
|
|
243
|
-
this.avancar();
|
|
244
|
-
break;
|
|
245
|
-
case '%':
|
|
246
|
-
this.inicioSimbolo = this.atual;
|
|
247
|
-
this.avancar();
|
|
248
|
-
switch (this.simboloAtual()) {
|
|
249
|
-
case '=':
|
|
250
|
-
this.avancar();
|
|
251
|
-
this.adicionarSimbolo(delegua_1.default.MODULO_IGUAL);
|
|
252
|
-
break;
|
|
253
|
-
default:
|
|
254
|
-
this.adicionarSimbolo(delegua_1.default.MODULO);
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
break;
|
|
258
|
-
case '*':
|
|
259
|
-
this.inicioSimbolo = this.atual;
|
|
260
|
-
this.avancar();
|
|
261
|
-
switch (this.simboloAtual()) {
|
|
262
|
-
case '*':
|
|
263
|
-
this.avancar();
|
|
264
|
-
this.adicionarSimbolo(delegua_1.default.EXPONENCIACAO);
|
|
265
|
-
break;
|
|
266
|
-
case '=':
|
|
267
|
-
this.avancar();
|
|
268
|
-
this.adicionarSimbolo(delegua_1.default.MULTIPLICACAO_IGUAL);
|
|
269
|
-
break;
|
|
270
|
-
default:
|
|
271
|
-
this.adicionarSimbolo(delegua_1.default.MULTIPLICACAO);
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
break;
|
|
275
|
-
case '!':
|
|
276
|
-
this.avancar();
|
|
277
|
-
if (this.simboloAtual() === '=') {
|
|
278
|
-
this.adicionarSimbolo(delegua_1.default.DIFERENTE);
|
|
279
|
-
this.avancar();
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
this.adicionarSimbolo(delegua_1.default.NEGACAO);
|
|
283
|
-
}
|
|
284
|
-
break;
|
|
285
|
-
case '=':
|
|
286
|
-
this.avancar();
|
|
287
|
-
if (this.simboloAtual() === '=') {
|
|
288
|
-
this.adicionarSimbolo(delegua_1.default.IGUAL_IGUAL);
|
|
289
|
-
this.avancar();
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
this.adicionarSimbolo(delegua_1.default.IGUAL);
|
|
293
|
-
}
|
|
294
|
-
break;
|
|
295
|
-
case '&':
|
|
296
|
-
this.adicionarSimbolo(delegua_1.default.BIT_AND);
|
|
297
|
-
this.avancar();
|
|
298
|
-
break;
|
|
299
|
-
case '~':
|
|
300
|
-
this.adicionarSimbolo(delegua_1.default.BIT_NOT);
|
|
301
|
-
this.avancar();
|
|
302
|
-
break;
|
|
303
|
-
case '|':
|
|
304
|
-
this.avancar();
|
|
305
|
-
if (this.simboloAtual() === '|') {
|
|
306
|
-
this.adicionarSimbolo(delegua_1.default.EXPRESSAO_REGULAR, '||');
|
|
307
|
-
this.avancar();
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
this.adicionarSimbolo(delegua_1.default.BIT_OR);
|
|
311
|
-
}
|
|
312
|
-
break;
|
|
313
|
-
case '^':
|
|
314
|
-
this.adicionarSimbolo(delegua_1.default.BIT_XOR);
|
|
315
|
-
this.avancar();
|
|
316
|
-
break;
|
|
317
|
-
case '<':
|
|
318
|
-
this.avancar();
|
|
319
|
-
if (this.simboloAtual() === '=') {
|
|
320
|
-
this.adicionarSimbolo(delegua_1.default.MENOR_IGUAL);
|
|
321
|
-
this.avancar();
|
|
322
|
-
}
|
|
323
|
-
else if (this.simboloAtual() === '<') {
|
|
324
|
-
this.adicionarSimbolo(delegua_1.default.MENOR_MENOR);
|
|
325
|
-
this.avancar();
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
this.adicionarSimbolo(delegua_1.default.MENOR);
|
|
329
|
-
}
|
|
330
|
-
break;
|
|
331
|
-
case '>':
|
|
332
|
-
this.avancar();
|
|
333
|
-
if (this.simboloAtual() === '=') {
|
|
334
|
-
this.adicionarSimbolo(delegua_1.default.MAIOR_IGUAL);
|
|
335
|
-
this.avancar();
|
|
336
|
-
}
|
|
337
|
-
else if (this.simboloAtual() === '>') {
|
|
338
|
-
this.adicionarSimbolo(delegua_1.default.MAIOR_MAIOR);
|
|
339
|
-
this.avancar();
|
|
340
|
-
}
|
|
341
|
-
else {
|
|
342
|
-
this.adicionarSimbolo(delegua_1.default.MAIOR);
|
|
343
|
-
}
|
|
344
|
-
break;
|
|
345
|
-
case '/':
|
|
346
|
-
this.avancar();
|
|
347
|
-
switch (this.simboloAtual()) {
|
|
348
|
-
case '/':
|
|
349
|
-
this.comentarioUmaLinha();
|
|
350
|
-
break;
|
|
351
|
-
case '*':
|
|
352
|
-
this.comentarioMultilinha();
|
|
353
|
-
break;
|
|
354
|
-
case '=':
|
|
355
|
-
this.adicionarSimbolo(delegua_1.default.DIVISAO_IGUAL);
|
|
356
|
-
this.avancar();
|
|
357
|
-
break;
|
|
358
|
-
default:
|
|
359
|
-
this.adicionarSimbolo(delegua_1.default.DIVISAO);
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
break;
|
|
363
|
-
case '\\':
|
|
364
|
-
this.inicioSimbolo = this.atual;
|
|
365
|
-
this.avancar();
|
|
366
|
-
switch (this.simboloAtual()) {
|
|
367
|
-
case '=':
|
|
368
|
-
this.adicionarSimbolo(delegua_1.default.DIVISAO_INTEIRA_IGUAL);
|
|
369
|
-
this.avancar();
|
|
370
|
-
break;
|
|
371
|
-
default:
|
|
372
|
-
this.adicionarSimbolo(delegua_1.default.DIVISAO_INTEIRA);
|
|
373
|
-
break;
|
|
374
|
-
}
|
|
375
|
-
break;
|
|
376
|
-
// Esta sessão ignora espaços em branco na tokenização.
|
|
377
|
-
case ' ':
|
|
378
|
-
case '\0':
|
|
379
|
-
case '\r':
|
|
380
|
-
case '\t':
|
|
381
|
-
this.avancar();
|
|
382
|
-
break;
|
|
383
|
-
// Ponto-e-vírgula é opcional em Delégua, mas em alguns casos pode ser
|
|
384
|
-
// necessário. Por exemplo, declaração de `para` sem inicializador.
|
|
385
|
-
case ';':
|
|
386
|
-
this.adicionarSimbolo(delegua_1.default.PONTO_E_VIRGULA);
|
|
387
|
-
this.avancar();
|
|
388
|
-
break;
|
|
389
|
-
case '"':
|
|
390
|
-
this.avancar();
|
|
391
|
-
this.analisarTexto('"');
|
|
392
|
-
this.avancar();
|
|
393
|
-
break;
|
|
394
|
-
case "'":
|
|
395
|
-
this.avancar();
|
|
396
|
-
this.analisarTexto("'");
|
|
397
|
-
this.avancar();
|
|
398
|
-
break;
|
|
399
|
-
default:
|
|
400
|
-
if (this.eDigito(caractere))
|
|
401
|
-
this.analisarNumero();
|
|
402
|
-
else if (this.eAlfabeto(caractere))
|
|
403
|
-
this.identificarPalavraChave();
|
|
404
|
-
else {
|
|
405
|
-
this.erros.push({
|
|
406
|
-
linha: this.linha + 1,
|
|
407
|
-
caractere: caractere,
|
|
408
|
-
mensagem: 'Caractere inesperado.',
|
|
409
|
-
});
|
|
410
|
-
this.avancar();
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
mapear(codigo, hashArquivo) {
|
|
415
|
-
const inicioMapeamento = (0, browser_process_hrtime_1.default)();
|
|
416
|
-
this.erros = [];
|
|
417
|
-
this.simbolos = [];
|
|
418
|
-
this.inicioSimbolo = 0;
|
|
419
|
-
this.atual = 0;
|
|
420
|
-
this.linha = 0;
|
|
421
|
-
this.codigo = codigo || [''];
|
|
422
|
-
this.hashArquivo = hashArquivo;
|
|
423
|
-
for (let iterador = 0; iterador < this.codigo.length; iterador++) {
|
|
424
|
-
this.codigo[iterador] += '\0';
|
|
425
|
-
}
|
|
426
|
-
while (!this.eFinalDoCodigo()) {
|
|
427
|
-
this.inicioSimbolo = this.atual;
|
|
428
|
-
this.analisarToken();
|
|
429
|
-
}
|
|
430
|
-
if (this.performance) {
|
|
431
|
-
const deltaMapeamento = (0, browser_process_hrtime_1.default)(inicioMapeamento);
|
|
432
|
-
console.log(`[Lexador] Tempo para mapeamento: ${deltaMapeamento[0] * 1e9 + deltaMapeamento[1]}ns`);
|
|
433
|
-
}
|
|
434
|
-
return {
|
|
435
|
-
simbolos: this.simbolos,
|
|
436
|
-
erros: this.erros,
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
exports.Lexador = Lexador;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Lexador = void 0;
|
|
7
|
+
const browser_process_hrtime_1 = __importDefault(require("browser-process-hrtime"));
|
|
8
|
+
const simbolo_1 = require("./simbolo");
|
|
9
|
+
const palavras_reservadas_1 = require("./palavras-reservadas");
|
|
10
|
+
const delegua_1 = __importDefault(require("../tipos-de-simbolos/delegua"));
|
|
11
|
+
/**
|
|
12
|
+
* O Lexador é responsável por transformar o código em uma coleção de tokens de linguagem.
|
|
13
|
+
* Cada token de linguagem é representado por um tipo, um lexema e informações da linha de código em que foi expresso.
|
|
14
|
+
* Também é responsável por mapear as palavras reservadas da linguagem, que não podem ser usadas por outras
|
|
15
|
+
* estruturas, tais como nomes de variáveis, funções, literais, classes e assim por diante.
|
|
16
|
+
*/
|
|
17
|
+
class Lexador {
|
|
18
|
+
constructor(performance = false) {
|
|
19
|
+
this.performance = performance;
|
|
20
|
+
this.simbolos = [];
|
|
21
|
+
this.erros = [];
|
|
22
|
+
this.hashArquivo = -1;
|
|
23
|
+
this.inicioSimbolo = 0;
|
|
24
|
+
this.atual = 0;
|
|
25
|
+
this.linha = 0;
|
|
26
|
+
}
|
|
27
|
+
eDigito(caractere) {
|
|
28
|
+
return caractere >= '0' && caractere <= '9';
|
|
29
|
+
}
|
|
30
|
+
eAlfabeto(caractere) {
|
|
31
|
+
const acentuacoes = [
|
|
32
|
+
'á',
|
|
33
|
+
'Á',
|
|
34
|
+
'ã',
|
|
35
|
+
'Ã',
|
|
36
|
+
'â',
|
|
37
|
+
'Â',
|
|
38
|
+
'à',
|
|
39
|
+
'À',
|
|
40
|
+
'é',
|
|
41
|
+
'É',
|
|
42
|
+
'ê',
|
|
43
|
+
'Ê',
|
|
44
|
+
'í',
|
|
45
|
+
'Í',
|
|
46
|
+
'ó',
|
|
47
|
+
'Ó',
|
|
48
|
+
'õ',
|
|
49
|
+
'Õ',
|
|
50
|
+
'ô',
|
|
51
|
+
'Ô',
|
|
52
|
+
'ú',
|
|
53
|
+
'Ú',
|
|
54
|
+
'ç',
|
|
55
|
+
'Ç',
|
|
56
|
+
'_',
|
|
57
|
+
];
|
|
58
|
+
return ((caractere >= 'a' && caractere <= 'z') ||
|
|
59
|
+
(caractere >= 'A' && caractere <= 'Z') ||
|
|
60
|
+
acentuacoes.includes(caractere));
|
|
61
|
+
}
|
|
62
|
+
eAlfabetoOuDigito(caractere) {
|
|
63
|
+
return this.eDigito(caractere) || this.eAlfabeto(caractere);
|
|
64
|
+
}
|
|
65
|
+
eFinalDaLinha() {
|
|
66
|
+
if (this.codigo.length === this.linha) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return this.atual >= this.codigo[this.linha].length;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Indica se o código está na última linha.
|
|
73
|
+
* @returns Verdadeiro se contador de linhas está na última linha.
|
|
74
|
+
* Falso caso contrário.
|
|
75
|
+
*/
|
|
76
|
+
eUltimaLinha() {
|
|
77
|
+
return this.linha >= this.codigo.length - 1;
|
|
78
|
+
}
|
|
79
|
+
eFinalDoCodigo() {
|
|
80
|
+
return this.eUltimaLinha() && this.codigo[this.codigo.length - 1].length <= this.atual;
|
|
81
|
+
}
|
|
82
|
+
avancar() {
|
|
83
|
+
this.atual += 1;
|
|
84
|
+
if (this.eFinalDaLinha() && !this.eUltimaLinha()) {
|
|
85
|
+
this.linha++;
|
|
86
|
+
this.atual = 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
adicionarSimbolo(tipo, literal = null) {
|
|
90
|
+
const texto = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
91
|
+
this.simbolos.push(new simbolo_1.Simbolo(tipo, literal || texto, literal, this.linha + 1, this.hashArquivo));
|
|
92
|
+
}
|
|
93
|
+
simboloAtual() {
|
|
94
|
+
if (this.eFinalDaLinha())
|
|
95
|
+
return '\0';
|
|
96
|
+
return this.codigo[this.linha].charAt(this.atual);
|
|
97
|
+
}
|
|
98
|
+
comentarioMultilinha() {
|
|
99
|
+
let conteudo = '';
|
|
100
|
+
while (!this.eFinalDoCodigo()) {
|
|
101
|
+
this.avancar();
|
|
102
|
+
conteudo += this.codigo[this.linha].charAt(this.atual);
|
|
103
|
+
if (this.simboloAtual() === '*' && this.proximoSimbolo() === '/') {
|
|
104
|
+
const linhas = conteudo.split('\0');
|
|
105
|
+
for (let linha of linhas) {
|
|
106
|
+
this.adicionarSimbolo(delegua_1.default.LINHA_COMENTARIO, linha.trim());
|
|
107
|
+
}
|
|
108
|
+
// Remove o asterisco da última linha
|
|
109
|
+
let lexemaUltimaLinha = this.simbolos[this.simbolos.length - 1].lexema;
|
|
110
|
+
lexemaUltimaLinha = lexemaUltimaLinha.substring(0, lexemaUltimaLinha.length - 1);
|
|
111
|
+
this.simbolos[this.simbolos.length - 1].lexema = lexemaUltimaLinha;
|
|
112
|
+
this.simbolos[this.simbolos.length - 1].literal = lexemaUltimaLinha;
|
|
113
|
+
this.avancar();
|
|
114
|
+
this.avancar();
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
comentarioUmaLinha() {
|
|
120
|
+
this.avancar();
|
|
121
|
+
const linhaAtual = this.linha;
|
|
122
|
+
let ultimoAtual = this.atual;
|
|
123
|
+
while (linhaAtual === this.linha && !this.eFinalDoCodigo()) {
|
|
124
|
+
ultimoAtual = this.atual;
|
|
125
|
+
this.avancar();
|
|
126
|
+
}
|
|
127
|
+
const conteudo = this.codigo[linhaAtual].substring(this.inicioSimbolo + 2, ultimoAtual);
|
|
128
|
+
this.adicionarSimbolo(delegua_1.default.COMENTARIO, conteudo.trim());
|
|
129
|
+
}
|
|
130
|
+
proximoSimbolo() {
|
|
131
|
+
return this.codigo[this.linha].charAt(this.atual + 1);
|
|
132
|
+
}
|
|
133
|
+
simboloAnterior() {
|
|
134
|
+
return this.codigo[this.linha].charAt(this.atual - 1);
|
|
135
|
+
}
|
|
136
|
+
analisarTexto(delimitador = '"') {
|
|
137
|
+
while (this.simboloAtual() !== delimitador && !this.eFinalDoCodigo()) {
|
|
138
|
+
this.avancar();
|
|
139
|
+
}
|
|
140
|
+
if (this.eFinalDoCodigo()) {
|
|
141
|
+
this.erros.push({
|
|
142
|
+
linha: this.linha + 1,
|
|
143
|
+
caractere: this.simboloAnterior(),
|
|
144
|
+
mensagem: 'Texto não finalizado.',
|
|
145
|
+
});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const valor = this.codigo[this.linha].substring(this.inicioSimbolo + 1, this.atual);
|
|
149
|
+
this.adicionarSimbolo(delegua_1.default.TEXTO, valor);
|
|
150
|
+
}
|
|
151
|
+
analisarNumero() {
|
|
152
|
+
while (this.eDigito(this.simboloAtual())) {
|
|
153
|
+
this.avancar();
|
|
154
|
+
}
|
|
155
|
+
if (this.simboloAtual() == '.' && this.eDigito(this.proximoSimbolo())) {
|
|
156
|
+
this.avancar();
|
|
157
|
+
while (this.eDigito(this.simboloAtual())) {
|
|
158
|
+
this.avancar();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const numeroCompleto = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
162
|
+
this.adicionarSimbolo(delegua_1.default.NUMERO, parseFloat(numeroCompleto));
|
|
163
|
+
}
|
|
164
|
+
identificarPalavraChave() {
|
|
165
|
+
while (this.eAlfabetoOuDigito(this.simboloAtual())) {
|
|
166
|
+
this.avancar();
|
|
167
|
+
}
|
|
168
|
+
const codigo = this.codigo[this.linha].substring(this.inicioSimbolo, this.atual);
|
|
169
|
+
const tipo = codigo in palavras_reservadas_1.palavrasReservadas ? palavras_reservadas_1.palavrasReservadas[codigo] : delegua_1.default.IDENTIFICADOR;
|
|
170
|
+
this.adicionarSimbolo(tipo);
|
|
171
|
+
}
|
|
172
|
+
analisarToken() {
|
|
173
|
+
const caractere = this.simboloAtual();
|
|
174
|
+
switch (caractere) {
|
|
175
|
+
case '@':
|
|
176
|
+
this.adicionarSimbolo(delegua_1.default.ARROBA, '@');
|
|
177
|
+
this.avancar();
|
|
178
|
+
break;
|
|
179
|
+
case '[':
|
|
180
|
+
this.adicionarSimbolo(delegua_1.default.COLCHETE_ESQUERDO);
|
|
181
|
+
this.avancar();
|
|
182
|
+
break;
|
|
183
|
+
case ']':
|
|
184
|
+
this.adicionarSimbolo(delegua_1.default.COLCHETE_DIREITO);
|
|
185
|
+
this.avancar();
|
|
186
|
+
break;
|
|
187
|
+
case '(':
|
|
188
|
+
this.adicionarSimbolo(delegua_1.default.PARENTESE_ESQUERDO);
|
|
189
|
+
this.avancar();
|
|
190
|
+
break;
|
|
191
|
+
case ')':
|
|
192
|
+
this.adicionarSimbolo(delegua_1.default.PARENTESE_DIREITO);
|
|
193
|
+
this.avancar();
|
|
194
|
+
break;
|
|
195
|
+
case '{':
|
|
196
|
+
this.adicionarSimbolo(delegua_1.default.CHAVE_ESQUERDA);
|
|
197
|
+
this.avancar();
|
|
198
|
+
break;
|
|
199
|
+
case '}':
|
|
200
|
+
this.adicionarSimbolo(delegua_1.default.CHAVE_DIREITA);
|
|
201
|
+
this.avancar();
|
|
202
|
+
break;
|
|
203
|
+
case ',':
|
|
204
|
+
this.adicionarSimbolo(delegua_1.default.VIRGULA);
|
|
205
|
+
this.avancar();
|
|
206
|
+
break;
|
|
207
|
+
case '.':
|
|
208
|
+
this.adicionarSimbolo(delegua_1.default.PONTO);
|
|
209
|
+
this.avancar();
|
|
210
|
+
break;
|
|
211
|
+
case '-':
|
|
212
|
+
this.inicioSimbolo = this.atual;
|
|
213
|
+
this.avancar();
|
|
214
|
+
if (this.simboloAtual() === '=') {
|
|
215
|
+
this.adicionarSimbolo(delegua_1.default.MENOS_IGUAL);
|
|
216
|
+
this.avancar();
|
|
217
|
+
}
|
|
218
|
+
else if (this.simboloAtual() === '-') {
|
|
219
|
+
this.adicionarSimbolo(delegua_1.default.DECREMENTAR);
|
|
220
|
+
this.avancar();
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
this.adicionarSimbolo(delegua_1.default.SUBTRACAO);
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
case '+':
|
|
227
|
+
this.inicioSimbolo = this.atual;
|
|
228
|
+
this.avancar();
|
|
229
|
+
if (this.simboloAtual() === '=') {
|
|
230
|
+
this.adicionarSimbolo(delegua_1.default.MAIS_IGUAL);
|
|
231
|
+
this.avancar();
|
|
232
|
+
}
|
|
233
|
+
else if (this.simboloAtual() === '+') {
|
|
234
|
+
this.adicionarSimbolo(delegua_1.default.INCREMENTAR);
|
|
235
|
+
this.avancar();
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
this.adicionarSimbolo(delegua_1.default.ADICAO);
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
case ':':
|
|
242
|
+
this.adicionarSimbolo(delegua_1.default.DOIS_PONTOS);
|
|
243
|
+
this.avancar();
|
|
244
|
+
break;
|
|
245
|
+
case '%':
|
|
246
|
+
this.inicioSimbolo = this.atual;
|
|
247
|
+
this.avancar();
|
|
248
|
+
switch (this.simboloAtual()) {
|
|
249
|
+
case '=':
|
|
250
|
+
this.avancar();
|
|
251
|
+
this.adicionarSimbolo(delegua_1.default.MODULO_IGUAL);
|
|
252
|
+
break;
|
|
253
|
+
default:
|
|
254
|
+
this.adicionarSimbolo(delegua_1.default.MODULO);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
break;
|
|
258
|
+
case '*':
|
|
259
|
+
this.inicioSimbolo = this.atual;
|
|
260
|
+
this.avancar();
|
|
261
|
+
switch (this.simboloAtual()) {
|
|
262
|
+
case '*':
|
|
263
|
+
this.avancar();
|
|
264
|
+
this.adicionarSimbolo(delegua_1.default.EXPONENCIACAO);
|
|
265
|
+
break;
|
|
266
|
+
case '=':
|
|
267
|
+
this.avancar();
|
|
268
|
+
this.adicionarSimbolo(delegua_1.default.MULTIPLICACAO_IGUAL);
|
|
269
|
+
break;
|
|
270
|
+
default:
|
|
271
|
+
this.adicionarSimbolo(delegua_1.default.MULTIPLICACAO);
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
break;
|
|
275
|
+
case '!':
|
|
276
|
+
this.avancar();
|
|
277
|
+
if (this.simboloAtual() === '=') {
|
|
278
|
+
this.adicionarSimbolo(delegua_1.default.DIFERENTE);
|
|
279
|
+
this.avancar();
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
this.adicionarSimbolo(delegua_1.default.NEGACAO);
|
|
283
|
+
}
|
|
284
|
+
break;
|
|
285
|
+
case '=':
|
|
286
|
+
this.avancar();
|
|
287
|
+
if (this.simboloAtual() === '=') {
|
|
288
|
+
this.adicionarSimbolo(delegua_1.default.IGUAL_IGUAL);
|
|
289
|
+
this.avancar();
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
this.adicionarSimbolo(delegua_1.default.IGUAL);
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
case '&':
|
|
296
|
+
this.adicionarSimbolo(delegua_1.default.BIT_AND);
|
|
297
|
+
this.avancar();
|
|
298
|
+
break;
|
|
299
|
+
case '~':
|
|
300
|
+
this.adicionarSimbolo(delegua_1.default.BIT_NOT);
|
|
301
|
+
this.avancar();
|
|
302
|
+
break;
|
|
303
|
+
case '|':
|
|
304
|
+
this.avancar();
|
|
305
|
+
if (this.simboloAtual() === '|') {
|
|
306
|
+
this.adicionarSimbolo(delegua_1.default.EXPRESSAO_REGULAR, '||');
|
|
307
|
+
this.avancar();
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
this.adicionarSimbolo(delegua_1.default.BIT_OR);
|
|
311
|
+
}
|
|
312
|
+
break;
|
|
313
|
+
case '^':
|
|
314
|
+
this.adicionarSimbolo(delegua_1.default.BIT_XOR);
|
|
315
|
+
this.avancar();
|
|
316
|
+
break;
|
|
317
|
+
case '<':
|
|
318
|
+
this.avancar();
|
|
319
|
+
if (this.simboloAtual() === '=') {
|
|
320
|
+
this.adicionarSimbolo(delegua_1.default.MENOR_IGUAL);
|
|
321
|
+
this.avancar();
|
|
322
|
+
}
|
|
323
|
+
else if (this.simboloAtual() === '<') {
|
|
324
|
+
this.adicionarSimbolo(delegua_1.default.MENOR_MENOR);
|
|
325
|
+
this.avancar();
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
this.adicionarSimbolo(delegua_1.default.MENOR);
|
|
329
|
+
}
|
|
330
|
+
break;
|
|
331
|
+
case '>':
|
|
332
|
+
this.avancar();
|
|
333
|
+
if (this.simboloAtual() === '=') {
|
|
334
|
+
this.adicionarSimbolo(delegua_1.default.MAIOR_IGUAL);
|
|
335
|
+
this.avancar();
|
|
336
|
+
}
|
|
337
|
+
else if (this.simboloAtual() === '>') {
|
|
338
|
+
this.adicionarSimbolo(delegua_1.default.MAIOR_MAIOR);
|
|
339
|
+
this.avancar();
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
this.adicionarSimbolo(delegua_1.default.MAIOR);
|
|
343
|
+
}
|
|
344
|
+
break;
|
|
345
|
+
case '/':
|
|
346
|
+
this.avancar();
|
|
347
|
+
switch (this.simboloAtual()) {
|
|
348
|
+
case '/':
|
|
349
|
+
this.comentarioUmaLinha();
|
|
350
|
+
break;
|
|
351
|
+
case '*':
|
|
352
|
+
this.comentarioMultilinha();
|
|
353
|
+
break;
|
|
354
|
+
case '=':
|
|
355
|
+
this.adicionarSimbolo(delegua_1.default.DIVISAO_IGUAL);
|
|
356
|
+
this.avancar();
|
|
357
|
+
break;
|
|
358
|
+
default:
|
|
359
|
+
this.adicionarSimbolo(delegua_1.default.DIVISAO);
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
break;
|
|
363
|
+
case '\\':
|
|
364
|
+
this.inicioSimbolo = this.atual;
|
|
365
|
+
this.avancar();
|
|
366
|
+
switch (this.simboloAtual()) {
|
|
367
|
+
case '=':
|
|
368
|
+
this.adicionarSimbolo(delegua_1.default.DIVISAO_INTEIRA_IGUAL);
|
|
369
|
+
this.avancar();
|
|
370
|
+
break;
|
|
371
|
+
default:
|
|
372
|
+
this.adicionarSimbolo(delegua_1.default.DIVISAO_INTEIRA);
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
break;
|
|
376
|
+
// Esta sessão ignora espaços em branco na tokenização.
|
|
377
|
+
case ' ':
|
|
378
|
+
case '\0':
|
|
379
|
+
case '\r':
|
|
380
|
+
case '\t':
|
|
381
|
+
this.avancar();
|
|
382
|
+
break;
|
|
383
|
+
// Ponto-e-vírgula é opcional em Delégua, mas em alguns casos pode ser
|
|
384
|
+
// necessário. Por exemplo, declaração de `para` sem inicializador.
|
|
385
|
+
case ';':
|
|
386
|
+
this.adicionarSimbolo(delegua_1.default.PONTO_E_VIRGULA);
|
|
387
|
+
this.avancar();
|
|
388
|
+
break;
|
|
389
|
+
case '"':
|
|
390
|
+
this.avancar();
|
|
391
|
+
this.analisarTexto('"');
|
|
392
|
+
this.avancar();
|
|
393
|
+
break;
|
|
394
|
+
case "'":
|
|
395
|
+
this.avancar();
|
|
396
|
+
this.analisarTexto("'");
|
|
397
|
+
this.avancar();
|
|
398
|
+
break;
|
|
399
|
+
default:
|
|
400
|
+
if (this.eDigito(caractere))
|
|
401
|
+
this.analisarNumero();
|
|
402
|
+
else if (this.eAlfabeto(caractere))
|
|
403
|
+
this.identificarPalavraChave();
|
|
404
|
+
else {
|
|
405
|
+
this.erros.push({
|
|
406
|
+
linha: this.linha + 1,
|
|
407
|
+
caractere: caractere,
|
|
408
|
+
mensagem: 'Caractere inesperado.',
|
|
409
|
+
});
|
|
410
|
+
this.avancar();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
mapear(codigo, hashArquivo) {
|
|
415
|
+
const inicioMapeamento = (0, browser_process_hrtime_1.default)();
|
|
416
|
+
this.erros = [];
|
|
417
|
+
this.simbolos = [];
|
|
418
|
+
this.inicioSimbolo = 0;
|
|
419
|
+
this.atual = 0;
|
|
420
|
+
this.linha = 0;
|
|
421
|
+
this.codigo = codigo || [''];
|
|
422
|
+
this.hashArquivo = hashArquivo;
|
|
423
|
+
for (let iterador = 0; iterador < this.codigo.length; iterador++) {
|
|
424
|
+
this.codigo[iterador] += '\0';
|
|
425
|
+
}
|
|
426
|
+
while (!this.eFinalDoCodigo()) {
|
|
427
|
+
this.inicioSimbolo = this.atual;
|
|
428
|
+
this.analisarToken();
|
|
429
|
+
}
|
|
430
|
+
if (this.performance) {
|
|
431
|
+
const deltaMapeamento = (0, browser_process_hrtime_1.default)(inicioMapeamento);
|
|
432
|
+
console.log(`[Lexador] Tempo para mapeamento: ${deltaMapeamento[0] * 1e9 + deltaMapeamento[1]}ns`);
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
simbolos: this.simbolos,
|
|
436
|
+
erros: this.erros,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
exports.Lexador = Lexador;
|
|
441
441
|
//# sourceMappingURL=lexador.js.map
|