-
Notifications
You must be signed in to change notification settings - Fork 46
Lexador emite token INVALIDO para caracteres não reconhecidos
#1373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: principal
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1745,6 +1745,22 @@ describe('Avaliador sintático', () => { | |
| const erro = retornoAvaliadorSintatico.erros[0]; | ||
| expect(erro.message).toBe("Função retorna valores com mais de um tipo. Tipo esperado: número. Tipos encontrados: texto, número."); | ||
| }); | ||
|
|
||
| it('Deve apontar erro ao utilizar `#` como retorno de função', async () => { | ||
| const retornoLexador = lexador.mapear( | ||
| [ | ||
| 'funcao teste() {', | ||
| ' retorna #', | ||
| '}', | ||
| 'escreva(teste())', | ||
| ], | ||
| -1 | ||
| ); | ||
| const retornoAvaliadorSintatico = await avaliadorSintatico.analisar(retornoLexador, -1); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quando há um erro léxico, essa etapa nem poderia executar. Isso está presente em todos os componentes que fazem parte de Delégua, como |
||
|
|
||
| expect(retornoAvaliadorSintatico.erros.length).toBeGreaterThan(0); | ||
| expect(retornoAvaliadorSintatico.erros[0].message).toBe("Esperado expressão."); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Laços de repetição', () => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5392,6 +5392,23 @@ describe('Interpretador', () => { | |
|
|
||
| expect(retornoInterpretador.erros).toHaveLength(1); | ||
| }); | ||
|
|
||
| it('Deve apontar erro ao utilizar `#`', async () => { | ||
| const codigo = [ | ||
| 'funcao teste() {', | ||
| ' retorna #', | ||
| '}', | ||
| 'escreva(teste())', | ||
| ]; | ||
| const retornoLexador = lexador.mapear(codigo, -1); | ||
| const retornoAvaliadorSintatico = await avaliadorSintatico.analisar(retornoLexador, -1); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idem. |
||
| const retornoInterpretador = await interpretador.interpretar( | ||
| retornoAvaliadorSintatico.declaracoes | ||
| ); | ||
|
|
||
| expect(retornoAvaliadorSintatico.erros).toHaveLength(1); | ||
| expect(retornoAvaliadorSintatico.erros[0].message).toBe('Esperado expressão.'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Verificação de tipos em atribuição', () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nào concordo com essa modificação. Aqui você está simplesmente se livrando de qualquer erro léxico, o que é previsto na arquitetura de Delégua. Quando há um erro léxico, as etapas seguintes não podem seguir. Por isso os testes unitários em outros arquivos não fazem sentido.