Skip to content

Commit

Permalink
Merge branch 'principal' into melhoria-validacao-tupla
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelrvg committed Feb 8, 2024
2 parents 90c1d52 + 44c5a4e commit 177314f
Show file tree
Hide file tree
Showing 27 changed files with 204 additions and 61 deletions.
7 changes: 7 additions & 0 deletions fontes/analisador-semantico/analisador-semantico.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
Var,
VarMultiplo,
} from '../declaracoes';
import { InicioAlgoritmo } from '../declaracoes/inicio-algoritmo';
import { SimboloInterface } from '../interfaces';
import { AnalisadorSemanticoInterface } from '../interfaces/analisador-semantico-interface';
import { DiagnosticoAnalisadorSemantico, DiagnosticoSeveridade } from '../interfaces/erros';
Expand Down Expand Up @@ -77,13 +78,19 @@ export class AnalisadorSemantico implements AnalisadorSemanticoInterface {
visitarExpressaoAcessoElementoMatriz(expressao: any) {
return Promise.resolve();
}

visitarExpressaoAtribuicaoPorIndicesMatriz(expressao: any): Promise<any> {
return Promise.resolve();
}

visitarExpressaoExpressaoRegular(expressao: ExpressaoRegular): Promise<any> {
return Promise.resolve();
}

visitarDeclaracaoInicioAlgoritmo(declaracao: InicioAlgoritmo): Promise<any> {
return Promise.resolve();
}

erro(simbolo: SimboloInterface, mensagem: string): void {
this.diagnosticos.push({
simbolo: simbolo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Var,
VarMultiplo,
} from '../../declaracoes';
import { InicioAlgoritmo } from '../../declaracoes/inicio-algoritmo';
import { AnalisadorSemanticoInterface } from '../../interfaces/analisador-semantico-interface';
import { DiagnosticoAnalisadorSemantico, DiagnosticoSeveridade } from '../../interfaces/erros';
import { RetornoAnalisadorSemantico } from '../../interfaces/retornos/retorno-analisador-semantico';
Expand Down Expand Up @@ -62,6 +63,10 @@ export class AnalisadorSemanticoBirl implements AnalisadorSemanticoInterface {
this.atual = 0;
this.diagnosticos = [];
}

visitarDeclaracaoInicioAlgoritmo(declaracao: InicioAlgoritmo): Promise<any> {
return Promise.resolve();
}

visitarDeclaracaoCabecalhoPrograma(declaracao: CabecalhoPrograma): Promise<any> {
return Promise.resolve();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
Var,
VarMultiplo,
} from '../../declaracoes';
import { InicioAlgoritmo } from '../../declaracoes/inicio-algoritmo';
import { SimboloInterface } from '../../interfaces';
import { AnalisadorSemanticoInterface } from '../../interfaces/analisador-semantico-interface';
import { DiagnosticoAnalisadorSemantico, DiagnosticoSeveridade } from '../../interfaces/erros';
Expand All @@ -51,6 +52,10 @@ export class AnalisadorSemanticoMapler implements AnalisadorSemanticoInterface {
this.atual = 0;
this.diagnosticos = [];
}

visitarDeclaracaoInicioAlgoritmo(declaracao: InicioAlgoritmo): Promise<any> {
return Promise.resolve();
}

visitarDeclaracaoCabecalhoPrograma(declaracao: CabecalhoPrograma): Promise<any> {
return Promise.resolve();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Var,
VarMultiplo
} from "../../declaracoes";
import { InicioAlgoritmo } from "../../declaracoes/inicio-algoritmo";
import { SimboloInterface } from "../../interfaces";
import { AnalisadorSemanticoInterface } from "../../interfaces/analisador-semantico-interface";
import { DiagnosticoAnalisadorSemantico, DiagnosticoSeveridade } from "../../interfaces/erros";
Expand All @@ -51,6 +52,10 @@ export class AnalisadorSemanticoVisuAlg implements AnalisadorSemanticoInterface
this.atual = 0;
this.diagnosticos = [];
}

visitarDeclaracaoInicioAlgoritmo(declaracao: InicioAlgoritmo): Promise<any> {
return Promise.resolve();
}

visitarDeclaracaoCabecalhoPrograma(declaracao: CabecalhoPrograma): Promise<any> {
return Promise.resolve();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import tiposDeSimbolos from '../../../tipos-de-simbolos/visualg';
import { ParametroVisuAlg } from './parametro-visualg';
import { TiposDadosInterface } from '../../../interfaces/tipos-dados-interface';
import { ErroAvaliadorSintatico } from '../../erro-avaliador-sintatico';
import { InicioAlgoritmo } from '../../../declaracoes/inicio-algoritmo';

export class AvaliadorSintaticoVisuAlg extends AvaliadorSintaticoBase {
blocoPrincipalIniciado: boolean;
Expand Down Expand Up @@ -276,11 +277,12 @@ export class AvaliadorSintaticoVisuAlg extends AvaliadorSintaticoBase {
return inicializacoes;
}

private validarSegmentoInicio(algoritmoOuFuncao: string): void {
this.consumir(
private validarSegmentoInicio(algoritmoOuFuncao: string): SimboloInterface {
const simboloInicio = this.consumir(
tiposDeSimbolos.INICIO,
`Esperada expressão 'inicio' para marcar escopo de ${algoritmoOuFuncao}.`
);
return simboloInicio;
}

estaNoFinal(): boolean {
Expand Down Expand Up @@ -1182,8 +1184,8 @@ export class AvaliadorSintaticoVisuAlg extends AvaliadorSintaticoBase {
case tiposDeSimbolos.FUNCAO:
return this.funcao('funcao');
case tiposDeSimbolos.INICIO:
this.validarSegmentoInicio('algoritmo');
return null;
const simboloInicio = this.validarSegmentoInicio('algoritmo');
return new InicioAlgoritmo(simboloInicio.linha, simboloInicio.hashArquivo);
case tiposDeSimbolos.INTERROMPA:
return this.declaracaoInterrompa();
case tiposDeSimbolos.LEIA:
Expand Down
1 change: 1 addition & 0 deletions fontes/declaracoes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export * from './falhar';
export * from './fazer';
export * from './funcao';
export * from './importar';
export * from './inicio-algoritmo';
export * from './leia';
export * from './leia-multiplo';
export * from './para';
Expand Down
13 changes: 13 additions & 0 deletions fontes/declaracoes/inicio-algoritmo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { VisitanteComumInterface } from "../interfaces";
import { Declaracao } from "./declaracao";

export class InicioAlgoritmo extends Declaracao {

constructor(linha: number, hashArquivo: number) {
super(linha, hashArquivo);
}

async aceitar(visitante: VisitanteComumInterface): Promise<any> {
return visitante.visitarDeclaracaoInicioAlgoritmo(this);
}
}
5 changes: 5 additions & 0 deletions fontes/formatadores/formatador-delegua.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
Aleatorio,
CabecalhoPrograma,
} from '../declaracoes';
import { InicioAlgoritmo } from '../declaracoes/inicio-algoritmo';
import { VisitanteComumInterface } from '../interfaces';

import tiposDeSimbolos from '../tipos-de-simbolos/delegua';
Expand All @@ -78,6 +79,10 @@ export class FormatadorDelegua implements VisitanteComumInterface {
this.deveIndentar = true;
}

visitarDeclaracaoInicioAlgoritmo(declaracao: InicioAlgoritmo): Promise<any> {
throw new Error('Método não implementado.');
}

visitarDeclaracaoCabecalhoPrograma(declaracao: CabecalhoPrograma): Promise<any> {
throw new Error('Método não implementado.');
}
Expand Down
5 changes: 5 additions & 0 deletions fontes/formatadores/formatador-portugol-studio.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AcessoIndiceVariavel, AcessoMetodoOuPropriedade, Agrupamento, AtribuicaoPorIndice, Atribuir, Binario, Chamada, Construto, DefinirValor, Dicionario, ExpressaoRegular, FimPara, FormatacaoEscrita, FuncaoConstruto, Isto, Literal, Logico, Super, TipoDe, Tupla, Unario, Variavel, Vetor } from "../construtos";
import { Classe, Const, ConstMultiplo, Expressao, FuncaoDeclaracao, Enquanto, Escolha, Escreva, Fazer, Importar, Para, ParaCada, Se, Tente, Var, VarMultiplo, Bloco, Continua, EscrevaMesmaLinha, Leia, LeiaMultiplo, Retorna, Sustar, Declaracao, Falhar, Aleatorio, CabecalhoPrograma } from "../declaracoes";
import { InicioAlgoritmo } from "../declaracoes/inicio-algoritmo";
import { VisitanteComumInterface } from "../interfaces";
import { ContinuarQuebra, RetornoQuebra, SustarQuebra } from "../quebras";

Expand All @@ -21,6 +22,10 @@ export class FormatadorPortugolStudio implements VisitanteComumInterface {
this.deveIndentar = true;
}

visitarDeclaracaoInicioAlgoritmo(declaracao: InicioAlgoritmo): Promise<any> {
throw new Error("Método não implementado.");
}

visitarDeclaracaoCabecalhoPrograma(declaracao: CabecalhoPrograma): Promise<any> {
throw new Error("Método não implementado.");
}
Expand Down
Loading

0 comments on commit 177314f

Please sign in to comment.