From 430b663fde119dc7c74484900cdb722c25b4653c Mon Sep 17 00:00:00 2001 From: "Pablo T. de Vargas" Date: Sat, 28 Oct 2023 19:15:36 -0300 Subject: [PATCH] [potigol] - adicionada interface para interpretador --- fontes/construtos/qual-tipo.ts | 6 ++++-- fontes/interfaces/interpretador-interface-potigol.ts | 7 +++++++ fontes/interfaces/visitante-comum-interface.ts | 1 - .../dialetos/potigol/interpretador-potigol.ts | 3 ++- 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 fontes/interfaces/interpretador-interface-potigol.ts diff --git a/fontes/construtos/qual-tipo.ts b/fontes/construtos/qual-tipo.ts index 306e114c..f3365781 100644 --- a/fontes/construtos/qual-tipo.ts +++ b/fontes/construtos/qual-tipo.ts @@ -1,4 +1,5 @@ -import { VisitanteComumInterface, SimboloInterface, VariavelInterface } from '../interfaces'; +import { SimboloInterface } from '../interfaces'; +import { InterpretadorInterfacePotigol } from '../interfaces/interpretador-interface-potigol'; import { Construto } from './construto'; @@ -16,7 +17,8 @@ export class QualTipo implements Construto { this.simbolo = simbolo; } - async aceitar(visitante: VisitanteComumInterface): Promise { + async aceitar(visitante: InterpretadorInterfacePotigol): Promise { return Promise.resolve(visitante.visitarExpressaoQualTipo(this)); } } + diff --git a/fontes/interfaces/interpretador-interface-potigol.ts b/fontes/interfaces/interpretador-interface-potigol.ts new file mode 100644 index 00000000..b4fc386a --- /dev/null +++ b/fontes/interfaces/interpretador-interface-potigol.ts @@ -0,0 +1,7 @@ +import { QualTipo } from '../construtos'; + +import { VisitanteComumInterface } from './visitante-comum-interface'; + +export interface InterpretadorInterfacePotigol extends VisitanteComumInterface { + visitarExpressaoQualTipo(expressao: QualTipo): Promise; +} diff --git a/fontes/interfaces/visitante-comum-interface.ts b/fontes/interfaces/visitante-comum-interface.ts index 45571c25..00276d81 100644 --- a/fontes/interfaces/visitante-comum-interface.ts +++ b/fontes/interfaces/visitante-comum-interface.ts @@ -74,5 +74,4 @@ export interface VisitanteComumInterface { visitarExpressaoTipoDe(expressao: TipoDe): Promise; visitarExpressaoUnaria(expressao: any): any; visitarExpressaoVetor(expressao: any): any; - visitarExpressaoQualTipo(expressao: any): Promise; } diff --git a/fontes/interpretador/dialetos/potigol/interpretador-potigol.ts b/fontes/interpretador/dialetos/potigol/interpretador-potigol.ts index 8cffd821..3038b9aa 100644 --- a/fontes/interpretador/dialetos/potigol/interpretador-potigol.ts +++ b/fontes/interpretador/dialetos/potigol/interpretador-potigol.ts @@ -6,11 +6,12 @@ import { AcessoMetodo, Binario, QualTipo, Unario, Variavel } from '../../../cons import * as comum from './comum'; import { ObjetoPadrao } from '../../../estruturas'; import { inferirTipoVariavel } from './inferenciador'; +import { InterpretadorInterfacePotigol } from '../../../interfaces/interpretador-interface-potigol'; /** * Uma implementaĆ§Ć£o do interpretador de Potigol. */ -export class InterpretadorPotigol extends InterpretadorBase { +export class InterpretadorPotigol extends InterpretadorBase implements InterpretadorInterfacePotigol { constructor( diretorioBase: string, performance = false,