@designliquido/delegua
Advanced tools
Comparing version 0.30.8 to 0.31.0
{ | ||
"name": "@designliquido/delegua", | ||
"version": "0.30.7", | ||
"version": "0.30.8", | ||
"description": "Linguagem de programação simples e moderna usando português estruturado, com suporte a múltiplos dialetos", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -658,9 +658,20 @@ "use strict"; | ||
let nomeDecorador = ''; | ||
let linha = this.simbolos[this.atual].linha; | ||
let linha; | ||
let parametros = []; | ||
let parenteseEsquerdo = false; | ||
linha = this.simbolos[this.atual].linha; | ||
let simbolosLinhaAtual = this.simbolos.filter((l) => l.linha === linha); | ||
nomeDecorador += simbolosLinhaAtual.map(l => { | ||
for (let simbolo of simbolosLinhaAtual) { | ||
parenteseEsquerdo = this.verificarSeSimboloAtualEIgualA(delegua_1.default.PARENTESE_ESQUERDO); | ||
if (parenteseEsquerdo) { | ||
if (!this.verificarTipoSimboloAtual(delegua_1.default.PARENTESE_DIREITO)) { | ||
parametros = this.logicaComumParametros(); | ||
} | ||
this.consumir(delegua_1.default.PARENTESE_DIREITO, "Esperado ')' após parâmetros."); | ||
break; | ||
} | ||
this.avancarEDevolverAnterior(); | ||
return l.lexema || '.'; | ||
}).join(''); | ||
this.pilhaDecoradores.push(new construtos_1.Decorador(this.hashArquivo, linha, nomeDecorador)); | ||
nomeDecorador += simbolo.lexema || '.'; | ||
} | ||
this.pilhaDecoradores.push(new construtos_1.Decorador(this.hashArquivo, linha, nomeDecorador, parametros)); | ||
} | ||
@@ -841,6 +852,6 @@ } | ||
let simbolo; | ||
this.resolverDecorador(); | ||
switch (this.simbolos[this.atual].tipo) { | ||
case delegua_1.default.CONSTRUTOR: | ||
simbolo = this.avancarEDevolverAnterior(); | ||
this.pilhaDecoradores = []; | ||
break; | ||
@@ -910,2 +921,3 @@ default: | ||
this.consumir(delegua_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo da classe."); | ||
this.pilhaDecoradores = []; | ||
const metodos = []; | ||
@@ -926,2 +938,3 @@ const propriedades = []; | ||
metodos.push(this.funcao('método')); | ||
this.pilhaDecoradores = []; | ||
break; | ||
@@ -932,3 +945,4 @@ case delegua_1.default.DOIS_PONTOS: | ||
const tipoPropriedade = this.avancarEDevolverAnterior(); | ||
propriedades.push(new declaracoes_1.PropriedadeClasse(nomePropriedade, tipoPropriedade.lexema)); | ||
propriedades.push(new declaracoes_1.PropriedadeClasse(nomePropriedade, tipoPropriedade.lexema, this.pilhaDecoradores)); | ||
this.pilhaDecoradores = []; | ||
break; | ||
@@ -935,0 +949,0 @@ default: |
@@ -173,3 +173,61 @@ "use strict"; | ||
declaracaoEscolha() { | ||
throw new Error('Método não implementado.'); | ||
try { | ||
this.avancarEDevolverAnterior(); | ||
this.blocos += 1; | ||
const condicao = this.expressao(); | ||
this.consumir(portugol_studio_1.default.CHAVE_ESQUERDA, "Esperado '{' antes do escopo do 'escolha'."); | ||
const caminhos = []; | ||
let caminhoPadrao = null; | ||
while (!this.verificarSeSimboloAtualEIgualA(portugol_studio_1.default.CHAVE_DIREITA) && !this.estaNoFinal()) { | ||
if (this.verificarSeSimboloAtualEIgualA(portugol_studio_1.default.CASO)) { | ||
if (this.verificarSeSimboloAtualEIgualA(portugol_studio_1.default.CONTRARIO)) { | ||
if (caminhoPadrao !== null) { | ||
const excecao = new erro_avaliador_sintatico_1.ErroAvaliadorSintatico(this.simbolos[this.atual], "Você só pode ter um 'contrario' em cada declaração de 'escolha'."); | ||
this.erros.push(excecao); | ||
throw excecao; | ||
} | ||
this.consumir(portugol_studio_1.default.DOIS_PONTOS, "Esperado ':' após declaração do 'contrario'."); | ||
const declaracoes = []; | ||
do { | ||
declaracoes.push(this.resolverDeclaracaoForaDeBloco()); | ||
this.verificarSeSimboloAtualEIgualA(portugol_studio_1.default.PARE); | ||
} while (!this.verificarTipoSimboloAtual(portugol_studio_1.default.CASO) && | ||
!this.verificarTipoSimboloAtual(portugol_studio_1.default.CONTRARIO) && | ||
!this.verificarTipoSimboloAtual(portugol_studio_1.default.CHAVE_DIREITA)); | ||
caminhoPadrao = { | ||
declaracoes, | ||
}; | ||
break; | ||
} | ||
const caminhoCondicoes = [this.expressao()]; | ||
this.consumir(portugol_studio_1.default.DOIS_PONTOS, "Esperado ':' após o 'caso'."); | ||
while (this.verificarTipoSimboloAtual(portugol_studio_1.default.CASO)) { | ||
this.consumir(portugol_studio_1.default.CASO, null); | ||
caminhoCondicoes.push(this.expressao()); | ||
this.consumir(portugol_studio_1.default.DOIS_PONTOS, "Esperado ':' após declaração do 'caso'."); | ||
} | ||
let declaracoes = []; | ||
do { | ||
const retornoDeclaracao = this.resolverDeclaracaoForaDeBloco(); | ||
if (Array.isArray(retornoDeclaracao)) { | ||
declaracoes = declaracoes.concat(retornoDeclaracao); | ||
} | ||
else { | ||
declaracoes.push(retornoDeclaracao); | ||
} | ||
this.verificarSeSimboloAtualEIgualA(portugol_studio_1.default.PARE); | ||
} while (!this.verificarTipoSimboloAtual(portugol_studio_1.default.CASO) && | ||
!this.verificarTipoSimboloAtual(portugol_studio_1.default.CONTRARIO) && | ||
!this.verificarTipoSimboloAtual(portugol_studio_1.default.CHAVE_DIREITA)); | ||
caminhos.push({ | ||
condicoes: caminhoCondicoes, | ||
declaracoes, | ||
}); | ||
} | ||
} | ||
return new declaracoes_1.Escolha(condicao, caminhos, caminhoPadrao); | ||
} | ||
finally { | ||
this.blocos -= 1; | ||
} | ||
} | ||
@@ -479,2 +537,4 @@ /** | ||
return this.declaracaoEnquanto(); | ||
case portugol_studio_1.default.ESCOLHA: | ||
return this.declaracaoEscolha(); | ||
case portugol_studio_1.default.ESCREVA: | ||
@@ -481,0 +541,0 @@ return this.declaracaoEscrevaMesmaLinha(); |
@@ -7,4 +7,5 @@ import { VisitanteComumInterface } from '../interfaces'; | ||
nome: string; | ||
constructor(hashArquivo: number, linha: number, nome: string); | ||
parametros?: any; | ||
constructor(hashArquivo: number, linha: number, nome: string, parametros?: any); | ||
aceitar(visitante: VisitanteComumInterface): Promise<any>; | ||
} |
@@ -5,6 +5,7 @@ "use strict"; | ||
class Decorador { | ||
constructor(hashArquivo, linha, nome) { | ||
constructor(hashArquivo, linha, nome, parametros) { | ||
this.linha = linha; | ||
this.hashArquivo = hashArquivo; | ||
this.nome = nome; | ||
this.parametros = parametros; | ||
} | ||
@@ -11,0 +12,0 @@ async aceitar(visitante) { |
@@ -0,1 +1,2 @@ | ||
import { Decorador } from '../construtos'; | ||
import { SimboloInterface, VisitanteComumInterface } from '../interfaces'; | ||
@@ -6,4 +7,5 @@ import { Declaracao } from './declaracao'; | ||
tipo?: string; | ||
constructor(nome: SimboloInterface, tipo?: string); | ||
decoradores: Decorador[]; | ||
constructor(nome: SimboloInterface, tipo?: string, decoradores?: Decorador[]); | ||
aceitar(visitante: VisitanteComumInterface): Promise<any>; | ||
} |
@@ -6,6 +6,7 @@ "use strict"; | ||
class PropriedadeClasse extends declaracao_1.Declaracao { | ||
constructor(nome, tipo) { | ||
constructor(nome, tipo, decoradores = []) { | ||
super(Number(nome.linha), nome.hashArquivo); | ||
this.nome = nome; | ||
this.tipo = tipo; | ||
this.decoradores = decoradores; | ||
} | ||
@@ -12,0 +13,0 @@ async aceitar(visitante) { |
@@ -39,3 +39,3 @@ import { EspacoVariaveis } from '../espaco-variaveis'; | ||
visitarExpressaoAcessoElementoMatriz(expressao: any): void; | ||
textoParaRegex(texto: any): any; | ||
protected textoParaRegex(texto: string): RegExp; | ||
visitarExpressaoExpressaoRegular(expressao: ExpressaoRegular): Promise<RegExp>; | ||
@@ -42,0 +42,0 @@ visitarExpressaoTipoDe(expressao: TipoDe): Promise<string>; |
@@ -85,3 +85,3 @@ "use strict"; | ||
visitarExpressaoExpressaoRegular(expressao) { | ||
return this.textoParaRegex(expressao.valor); | ||
return Promise.resolve(this.textoParaRegex(expressao.valor)); | ||
} | ||
@@ -88,0 +88,0 @@ async visitarExpressaoTipoDe(expressao) { |
@@ -132,2 +132,6 @@ "use strict"; | ||
break; | ||
case ':': | ||
this.adicionarSimbolo(portugol_studio_2.default.DOIS_PONTOS); | ||
this.avancar(); | ||
break; | ||
case '%': | ||
@@ -134,0 +138,0 @@ this.adicionarSimbolo(portugol_studio_2.default.MODULO); |
export declare const palavrasReservadas: { | ||
cadeia: string; | ||
caracter: string; | ||
caso: string; | ||
const: string; | ||
contrario: string; | ||
enquanto: string; | ||
escolha: string; | ||
escreva: string; | ||
@@ -17,2 +20,3 @@ e: string; | ||
para: string; | ||
pare: string; | ||
programa: string; | ||
@@ -19,0 +23,0 @@ real: string; |
@@ -11,4 +11,7 @@ "use strict"; | ||
caracter: portugol_studio_1.default.CARACTER, | ||
caso: portugol_studio_1.default.CASO, | ||
const: portugol_studio_1.default.CONSTANTE, | ||
contrario: portugol_studio_1.default.CONTRARIO, | ||
enquanto: portugol_studio_1.default.ENQUANTO, | ||
escolha: portugol_studio_1.default.ESCOLHA, | ||
escreva: portugol_studio_1.default.ESCREVA, | ||
@@ -25,2 +28,3 @@ e: portugol_studio_1.default.E, | ||
para: portugol_studio_1.default.PARA, | ||
pare: portugol_studio_1.default.PARE, | ||
programa: portugol_studio_1.default.PROGRAMA, | ||
@@ -27,0 +31,0 @@ real: portugol_studio_1.default.REAL, |
@@ -5,2 +5,3 @@ declare const _default: { | ||
CARACTER: string; | ||
CASO: string; | ||
CHAVE_ESQUERDA: string; | ||
@@ -11,2 +12,3 @@ CHAVE_DIREITA: string; | ||
CONSTANTE: string; | ||
CONTRARIO: string; | ||
DECREMENTAR: string; | ||
@@ -17,4 +19,6 @@ DIFERENTE: string; | ||
DIVISAO_INTEIRA: string; | ||
DOIS_PONTOS: string; | ||
E: string; | ||
ENQUANTO: string; | ||
ESCOLHA: string; | ||
ESCREVA: string; | ||
@@ -43,2 +47,3 @@ FACA: string; | ||
PARA: string; | ||
PARE: string; | ||
PARENTESE_ESQUERDO: string; | ||
@@ -45,0 +50,0 @@ PARENTESE_DIREITO: string; |
@@ -7,2 +7,3 @@ "use strict"; | ||
CARACTER: 'CARACTER', | ||
CASO: 'CASO', | ||
CHAVE_ESQUERDA: 'CHAVE_ESQUERDA', | ||
@@ -13,2 +14,3 @@ CHAVE_DIREITA: 'CHAVE_DIREITA', | ||
CONSTANTE: 'CONSTANTE', | ||
CONTRARIO: 'CONTRARIO', | ||
DECREMENTAR: 'DECREMENTAR', | ||
@@ -19,4 +21,6 @@ DIFERENTE: 'DIFERENTE', | ||
DIVISAO_INTEIRA: 'DIVISAO_INTEIRA', | ||
DOIS_PONTOS: 'DOIS_PONTOS', | ||
E: 'E', | ||
ENQUANTO: 'ENQUANTO', | ||
ESCOLHA: 'ESCOLHA', | ||
ESCREVA: 'ESCREVA', | ||
@@ -45,2 +49,3 @@ FACA: 'FACA', | ||
PARA: 'PARA', | ||
PARE: 'PARE', | ||
PARENTESE_ESQUERDO: 'PARENTESE_ESQUERDO', | ||
@@ -47,0 +52,0 @@ PARENTESE_DIREITO: 'PARENTESE_DIREITO', |
{ | ||
"name": "@designliquido/delegua", | ||
"version": "0.30.8", | ||
"version": "0.31.0", | ||
"description": "Linguagem de programação simples e moderna usando português estruturado, com suporte a múltiplos dialetos", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3280598
48163