Skip to content
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

analisa fator #41

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compilador/js/erros.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const messages = {
sxs5: "Erro sintático: Esperado ':'",
sxs6: "Erro sintático: Tipo de variável inválido",
sxs7: "Erro sintático: Esperado 'inicio'",
sxs8: "Erro sintático: Esperado 'fim'",
sxs9: "Erro sintático: Parenteses não fechados",
sxs10: "Erro sintático: Simbolo não esperado",
};

export class ErroLexico extends Error {
Expand Down
53 changes: 53 additions & 0 deletions compilador/js/sintatico.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,59 @@ function analisaComandoCondicional() {}
function analisaComandoEnquanto() {}
function analisaComandoLeitura() {}
function analisaComandoEscrita() {}
function analisaTermo() {}
function analisaFator() {
/**
* <fator> ::= (<variável> |
* <número> |
* <chamada de função> |
* (<expressão>) | verdadeiro | falso |
* nao <fator>)
*
*/
if (lexico.tokenAtual.simbolo == "Sidentificador") {
//semantico
// if (pesquisaTabela(lexico.tokenAtual.lexema, nível, ind)) {
// if (
// tabelaSimbolos[ind].tipo == "funcao int" ||
// tabelaSimbolos[ind].tipo == "funcao booleano"
// ) {
// analisaChamadaFuncao();
// }else lexico.proximoToken();
// }
// else{ ERRO}
} else if (lexico.tokenAtual.simbolo == "Snumero") {
lexico.proximoToken();
} else if (lexico.tokenAtual.simbolo == "Snao") {
lexico.proximoToken();
analisaFator();
} else if (lexico.tokenAtual.simbolo == "Sabre_parenteses") {
lexico.proximoToken();
analisaExpressao();
if (lexico.tokenAtual.simbolo == "Sfecha_parenteses") {
lexico.proximoToken();
} else {
throw new ErroSintatico(
"sxs9",
lexico.tokenAtual.lexema,
lexico.tokenAtual.linha,
lexico.tokenAtual.coluna
);
}
} else if (
lexico.tokenAtual.simbolo == "Sverdadeiro" ||
lexico.tokenAtual.simbolo == "Sfalso"
) {
lexico.proximoToken();
} else {
throw new ErroSintatico(
"sxs10",
lexico.tokenAtual.lexema,
lexico.tokenAtual.linha,
lexico.tokenAtual.coluna
);
}
}

function analisaTipo() {
/**
Expand Down