@designliquido/potigol 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/avaliador-sintatico/avaliador-sintatico-potigol.d.ts +22 -6
- package/avaliador-sintatico/avaliador-sintatico-potigol.d.ts.map +1 -1
- package/avaliador-sintatico/avaliador-sintatico-potigol.js +114 -32
- package/avaliador-sintatico/avaliador-sintatico-potigol.js.map +1 -1
- package/avaliador-sintatico/micro-avaliador-sintatico-potigol.d.ts.map +1 -1
- package/avaliador-sintatico/micro-avaliador-sintatico-potigol.js +2 -2
- package/avaliador-sintatico/micro-avaliador-sintatico-potigol.js.map +1 -1
- package/avaliador-sintatico/pilha-escopos-variaveis-conhecidas.d.ts +11 -0
- package/avaliador-sintatico/pilha-escopos-variaveis-conhecidas.d.ts.map +1 -0
- package/avaliador-sintatico/pilha-escopos-variaveis-conhecidas.js +34 -0
- package/avaliador-sintatico/pilha-escopos-variaveis-conhecidas.js.map +1 -0
- package/bibliotecas/biblioteca-global.d.ts +11 -11
- package/construtos/constante-ou-variavel.d.ts +20 -0
- package/construtos/constante-ou-variavel.d.ts.map +1 -0
- package/construtos/constante-ou-variavel.js +26 -0
- package/construtos/constante-ou-variavel.js.map +1 -0
- package/construtos/index.d.ts +2 -0
- package/construtos/index.d.ts.map +1 -0
- package/construtos/index.js +18 -0
- package/construtos/index.js.map +1 -0
- package/declaracoes/index.d.ts +2 -0
- package/declaracoes/index.d.ts.map +1 -0
- package/declaracoes/index.js +18 -0
- package/declaracoes/index.js.map +1 -0
- package/declaracoes/reatribuicao-variavel.d.ts +18 -0
- package/declaracoes/reatribuicao-variavel.d.ts.map +1 -0
- package/declaracoes/reatribuicao-variavel.js +22 -0
- package/declaracoes/reatribuicao-variavel.js.map +1 -0
- package/estruturas/potigol-funcao.d.ts +4 -0
- package/estruturas/potigol-funcao.d.ts.map +1 -0
- package/estruturas/potigol-funcao.js +8 -0
- package/estruturas/potigol-funcao.js.map +1 -0
- package/formatador/formatador-potigol.d.ts +26 -23
- package/formatador/formatador-potigol.d.ts.map +1 -1
- package/formatador/formatador-potigol.js +76 -33
- package/formatador/formatador-potigol.js.map +1 -1
- package/interfaces/index.d.ts +2 -1
- package/interfaces/index.d.ts.map +1 -1
- package/interfaces/index.js +2 -1
- package/interfaces/index.js.map +1 -1
- package/interfaces/interpretador-potigol-interface.d.ts +14 -0
- package/interfaces/interpretador-potigol-interface.d.ts.map +1 -0
- package/interfaces/{interpretador-interface-potigol.js → interpretador-potigol-interface.js} +1 -1
- package/interfaces/interpretador-potigol-interface.js.map +1 -0
- package/interfaces/visitante-comum-potigol-interface.d.ts +8 -0
- package/interfaces/visitante-comum-potigol-interface.d.ts.map +1 -0
- package/interfaces/visitante-comum-potigol-interface.js +3 -0
- package/interfaces/visitante-comum-potigol-interface.js.map +1 -0
- package/interpretador/comum.d.ts +10 -7
- package/interpretador/comum.d.ts.map +1 -1
- package/interpretador/comum.js +75 -2
- package/interpretador/comum.js.map +1 -1
- package/interpretador/interpretador-potigol-com-depuracao.d.ts +5 -1
- package/interpretador/interpretador-potigol-com-depuracao.d.ts.map +1 -1
- package/interpretador/interpretador-potigol-com-depuracao.js +6 -0
- package/interpretador/interpretador-potigol-com-depuracao.js.map +1 -1
- package/interpretador/interpretador-potigol.d.ts +7 -4
- package/interpretador/interpretador-potigol.d.ts.map +1 -1
- package/interpretador/interpretador-potigol.js +8 -2
- package/interpretador/interpretador-potigol.js.map +1 -1
- package/lexador/lexador-potigol.d.ts +1 -1
- package/lexador/lexador-potigol.d.ts.map +1 -1
- package/lexador/lexador-potigol.js +3 -3
- package/lexador/lexador-potigol.js.map +1 -1
- package/lexador/micro-lexador-potigol.d.ts +2 -1
- package/lexador/micro-lexador-potigol.d.ts.map +1 -1
- package/lexador/micro-lexador-potigol.js +2 -2
- package/lexador/micro-lexador-potigol.js.map +1 -1
- package/package.json +2 -2
- package/tipos-de-simbolos/lexico-regular.d.ts +1 -0
- package/tipos-de-simbolos/lexico-regular.d.ts.map +1 -1
- package/tipos-de-simbolos/lexico-regular.js +1 -0
- package/tipos-de-simbolos/lexico-regular.js.map +1 -1
- package/interfaces/interpretador-interface-potigol.d.ts +0 -6
- package/interfaces/interpretador-interface-potigol.d.ts.map +0 -1
- package/interfaces/interpretador-interface-potigol.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function abs(interpretador:
|
|
1
|
+
import { InterpretadorPotigolInterface } from '../interfaces';
|
|
2
|
+
export declare function abs(interpretador: InterpretadorPotigolInterface, valor: number): Promise<number>;
|
|
3
3
|
export declare function aleatorio(): Promise<number>;
|
|
4
|
-
export declare function arccos(interpretador:
|
|
5
|
-
export declare function arcsen(interpretador:
|
|
6
|
-
export declare function arctg(interpretador:
|
|
7
|
-
export declare function cos(interpretador:
|
|
8
|
-
export declare function log(interpretador:
|
|
9
|
-
export declare function log10(interpretador:
|
|
4
|
+
export declare function arccos(interpretador: InterpretadorPotigolInterface, valor: number): Promise<number>;
|
|
5
|
+
export declare function arcsen(interpretador: InterpretadorPotigolInterface, valor: number): Promise<number>;
|
|
6
|
+
export declare function arctg(interpretador: InterpretadorPotigolInterface, valor: number): Promise<number>;
|
|
7
|
+
export declare function cos(interpretador: InterpretadorPotigolInterface, valor: number): Promise<number>;
|
|
8
|
+
export declare function log(interpretador: InterpretadorPotigolInterface, valor: number): Promise<number>;
|
|
9
|
+
export declare function log10(interpretador: InterpretadorPotigolInterface, valor: number): Promise<number>;
|
|
10
10
|
export declare function pi(): Promise<number>;
|
|
11
|
-
export declare function raiz(interpretador:
|
|
12
|
-
export declare function sen(interpretador:
|
|
13
|
-
export declare function tg(interpretador:
|
|
11
|
+
export declare function raiz(interpretador: InterpretadorPotigolInterface, valor: number): Promise<number>;
|
|
12
|
+
export declare function sen(interpretador: InterpretadorPotigolInterface, valor: number): Promise<number>;
|
|
13
|
+
export declare function tg(interpretador: InterpretadorPotigolInterface, valor: number): Promise<number>;
|
|
14
14
|
//# sourceMappingURL=biblioteca-global.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Construto } from '@designliquido/delegua/construtos';
|
|
2
|
+
import { SimboloInterface, VariavelInterface, VisitanteComumInterface } from '@designliquido/delegua/interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Este construto existe para alguns dialetos, como Potigol, onde
|
|
5
|
+
* não é possível definir se um construto é constante, variável,
|
|
6
|
+
* identificador de função, tipo ou classe no momento da avaliação
|
|
7
|
+
* primária.
|
|
8
|
+
*
|
|
9
|
+
* Durante o restante da avaliação sintática, esse construto deve **obrigatoriamente**
|
|
10
|
+
* resolver para `Constante`, `Variavel` ou algum construto de chamada/declaração de
|
|
11
|
+
* função.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ConstanteOuVariavel<TTipoSimbolo extends string = string> implements Construto {
|
|
14
|
+
linha: number;
|
|
15
|
+
hashArquivo: number;
|
|
16
|
+
simbolo: SimboloInterface<TTipoSimbolo>;
|
|
17
|
+
constructor(hashArquivo: number, simbolo: SimboloInterface<TTipoSimbolo>);
|
|
18
|
+
aceitar(visitante: VisitanteComumInterface): Promise<VariavelInterface>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=constante-ou-variavel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constante-ou-variavel.d.ts","sourceRoot":"","sources":["../../fontes/construtos/constante-ou-variavel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAEjH;;;;;;;;;GASG;AACH,qBAAa,mBAAmB,CAAC,YAAY,SAAS,MAAM,GAAG,MAAM,CAAE,YAAW,SAAS;IACvF,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IAEpB,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGpC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC;IAQrC,OAAO,CAAC,SAAS,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAQhF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConstanteOuVariavel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Este construto existe para alguns dialetos, como Potigol, onde
|
|
6
|
+
* não é possível definir se um construto é constante, variável,
|
|
7
|
+
* identificador de função, tipo ou classe no momento da avaliação
|
|
8
|
+
* primária.
|
|
9
|
+
*
|
|
10
|
+
* Durante o restante da avaliação sintática, esse construto deve **obrigatoriamente**
|
|
11
|
+
* resolver para `Constante`, `Variavel` ou algum construto de chamada/declaração de
|
|
12
|
+
* função.
|
|
13
|
+
*/
|
|
14
|
+
class ConstanteOuVariavel {
|
|
15
|
+
constructor(hashArquivo, simbolo) {
|
|
16
|
+
this.linha = Number(simbolo.linha);
|
|
17
|
+
this.hashArquivo = hashArquivo;
|
|
18
|
+
this.simbolo = simbolo;
|
|
19
|
+
}
|
|
20
|
+
async aceitar(visitante) {
|
|
21
|
+
return Promise.reject(new Error('Este método não deveria ser chamado. ' +
|
|
22
|
+
'O construto deve resolver como constante ou variável ainda na avaliação sintática.'));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ConstanteOuVariavel = ConstanteOuVariavel;
|
|
26
|
+
//# sourceMappingURL=constante-ou-variavel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constante-ou-variavel.js","sourceRoot":"","sources":["../../fontes/construtos/constante-ou-variavel.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;GASG;AACH,MAAa,mBAAmB;IAM5B,YACI,WAAmB,EACnB,OAAuC;QAEvC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,SAAkC;QAC5C,OAAO,OAAO,CAAC,MAAM,CACjB,IAAI,KAAK,CACL,uCAAuC;YACnC,oFAAoF,CAC3F,CACJ,CAAC;IACN,CAAC;CACJ;AAxBD,kDAwBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../fontes/construtos/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constante-ou-variavel"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../fontes/construtos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../fontes/declaracoes/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./reatribuicao-variavel"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../fontes/declaracoes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Construto } from "@designliquido/delegua/construtos";
|
|
2
|
+
import { Declaracao } from "@designliquido/delegua/declaracoes";
|
|
3
|
+
import { SimboloInterface } from "@designliquido/delegua/interfaces";
|
|
4
|
+
import { TipoDadosElementar } from "@designliquido/delegua/tipo-dados-elementar";
|
|
5
|
+
import { VisitanteComumPotigolInterface } from "../interfaces";
|
|
6
|
+
/**
|
|
7
|
+
* Uma declaração de reatribuição de variável.
|
|
8
|
+
* Em Potigol, para a correta formatação de código, precisamos separar as declarações.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ReatribuicaoVariavel extends Declaracao {
|
|
11
|
+
simbolo: SimboloInterface;
|
|
12
|
+
inicializador: Construto;
|
|
13
|
+
tipo: TipoDadosElementar;
|
|
14
|
+
referencia: boolean;
|
|
15
|
+
constructor(simbolo: SimboloInterface, inicializador: Construto, tipo?: TipoDadosElementar);
|
|
16
|
+
aceitar(visitante: VisitanteComumPotigolInterface): Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=reatribuicao-variavel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reatribuicao-variavel.d.ts","sourceRoot":"","sources":["../../fontes/declaracoes/reatribuicao-variavel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAE/D;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,UAAU;IAChD,OAAO,EAAE,gBAAgB,CAAC;IAC1B,aAAa,EAAE,SAAS,CAAC;IACzB,IAAI,EAAE,kBAAkB,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;gBAER,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,GAAE,kBAA8B;IAQ/F,OAAO,CAAC,SAAS,EAAE,8BAA8B,GAAG,OAAO,CAAC,GAAG,CAAC;CAGzE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReatribuicaoVariavel = void 0;
|
|
4
|
+
const declaracoes_1 = require("@designliquido/delegua/declaracoes");
|
|
5
|
+
/**
|
|
6
|
+
* Uma declaração de reatribuição de variável.
|
|
7
|
+
* Em Potigol, para a correta formatação de código, precisamos separar as declarações.
|
|
8
|
+
*/
|
|
9
|
+
class ReatribuicaoVariavel extends declaracoes_1.Declaracao {
|
|
10
|
+
constructor(simbolo, inicializador, tipo = undefined) {
|
|
11
|
+
super(Number(simbolo.linha), simbolo.hashArquivo);
|
|
12
|
+
this.simbolo = simbolo;
|
|
13
|
+
this.inicializador = inicializador;
|
|
14
|
+
this.tipo = tipo;
|
|
15
|
+
this.referencia = false;
|
|
16
|
+
}
|
|
17
|
+
async aceitar(visitante) {
|
|
18
|
+
return await visitante.visitarDeclaracaoReatribuicaoVariavel(this);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ReatribuicaoVariavel = ReatribuicaoVariavel;
|
|
22
|
+
//# sourceMappingURL=reatribuicao-variavel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reatribuicao-variavel.js","sourceRoot":"","sources":["../../fontes/declaracoes/reatribuicao-variavel.ts"],"names":[],"mappings":";;;AACA,oEAAgE;AAMhE;;;GAGG;AACH,MAAa,oBAAqB,SAAQ,wBAAU;IAMhD,YAAY,OAAyB,EAAE,aAAwB,EAAE,OAA2B,SAAS;QACjG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,SAAyC;QACnD,OAAO,MAAM,SAAS,CAAC,qCAAqC,CAAC,IAAI,CAAC,CAAC;IACvE,CAAC;CACJ;AAjBD,oDAiBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"potigol-funcao.d.ts","sourceRoot":"","sources":["../../fontes/estruturas/potigol-funcao.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,qBAAa,aAAc,SAAQ,QAAQ;CAE1C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PotigolFuncao = void 0;
|
|
4
|
+
const estruturas_1 = require("@designliquido/delegua/estruturas");
|
|
5
|
+
class PotigolFuncao extends estruturas_1.Chamavel {
|
|
6
|
+
}
|
|
7
|
+
exports.PotigolFuncao = PotigolFuncao;
|
|
8
|
+
//# sourceMappingURL=potigol-funcao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"potigol-funcao.js","sourceRoot":"","sources":["../../fontes/estruturas/potigol-funcao.ts"],"names":[],"mappings":";;;AAAA,kEAA6D;AAE7D,MAAa,aAAc,SAAQ,qBAAQ;CAE1C;AAFD,sCAEC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Atribuir, Binario, Comentario, Constante, Construto, Deceto, Dupla, ExpressaoRegular, FimPara, FormatacaoEscrita, FuncaoConstruto, Literal, Noneto, Octeto, Quarteto, Quinteto, Septeto, Sexteto, Super, TipoDe, Trio, Tupla, Unario } from '@designliquido/delegua/construtos';
|
|
1
|
+
import { Atribuir, Binario, Comentario, Constante, Construto, Deceto, Dupla, ExpressaoRegular, FimPara, FormatacaoEscrita, FuncaoConstruto, Literal, Noneto, Octeto, QualTipo, Quarteto, Quinteto, Septeto, Sexteto, Super, TipoDe, Trio, Tupla, Unario, Variavel } from '@designliquido/delegua/construtos';
|
|
2
2
|
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, Aleatorio, CabecalhoPrograma, TendoComo, PropriedadeClasse, InicioAlgoritmo } from '@designliquido/delegua/declaracoes';
|
|
3
|
-
import { VisitanteComumInterface } from '@designliquido/delegua/interfaces';
|
|
4
3
|
import { ContinuarQuebra, SustarQuebra } from '@designliquido/delegua/quebras';
|
|
5
|
-
|
|
4
|
+
import { ReatribuicaoVariavel } from '../declaracoes';
|
|
5
|
+
import { VisitanteComumPotigolInterface } from '../interfaces';
|
|
6
|
+
export declare class FormatadorPotigol implements VisitanteComumPotigolInterface {
|
|
6
7
|
indentacaoAtual: number;
|
|
7
8
|
quebraLinha: string;
|
|
8
9
|
tamanhoIndentacao: number;
|
|
@@ -10,22 +11,24 @@ export declare class FormatadorPotigol implements VisitanteComumInterface {
|
|
|
10
11
|
devePularLinha: boolean;
|
|
11
12
|
deveIndentar: boolean;
|
|
12
13
|
constructor(quebraLinha: string, tamanhoIndentacao?: number);
|
|
14
|
+
visitarDeclaracaoReatribuicaoVariavel(declaracao: ReatribuicaoVariavel): void;
|
|
15
|
+
visitarExpressaoQualTipo(expressao: QualTipo<string>): void;
|
|
13
16
|
/**
|
|
14
17
|
* Aparentemente só existe comentário de uma linha só em Potigol.
|
|
15
18
|
* @param declaracao A declaração de comentário.
|
|
16
19
|
*/
|
|
17
20
|
visitarDeclaracaoComentario(declaracao: Comentario): void;
|
|
18
|
-
visitarDeclaracaoTendoComo(declaracao: TendoComo): void
|
|
19
|
-
visitarDeclaracaoInicioAlgoritmo(declaracao: InicioAlgoritmo):
|
|
20
|
-
visitarDeclaracaoCabecalhoPrograma(declaracao: CabecalhoPrograma):
|
|
21
|
-
visitarExpressaoTupla(expressao: Tupla):
|
|
21
|
+
visitarDeclaracaoTendoComo(declaracao: TendoComo): void;
|
|
22
|
+
visitarDeclaracaoInicioAlgoritmo(declaracao: InicioAlgoritmo): void;
|
|
23
|
+
visitarDeclaracaoCabecalhoPrograma(declaracao: CabecalhoPrograma): void;
|
|
24
|
+
visitarExpressaoTupla(expressao: Tupla): void;
|
|
22
25
|
visitarDeclaracaoClasse(declaracao: Classe): void;
|
|
23
|
-
visitarExpressaoPropriedadeClasse(expressao: PropriedadeClasse):
|
|
24
|
-
visitarDeclaracaoConst(declaracao: Const):
|
|
25
|
-
visitarDeclaracaoConstMultiplo(declaracao: ConstMultiplo):
|
|
26
|
+
visitarExpressaoPropriedadeClasse(expressao: PropriedadeClasse): void;
|
|
27
|
+
visitarDeclaracaoConst(declaracao: Const): void;
|
|
28
|
+
visitarDeclaracaoConstMultiplo(declaracao: ConstMultiplo): void;
|
|
26
29
|
visitarExpressaoDeAtribuicao(expressao: Atribuir): void;
|
|
27
30
|
visitarDeclaracaoDeExpressao(declaracao: Expressao): void;
|
|
28
|
-
visitarDeclaracaoAleatorio(declaracao: Aleatorio):
|
|
31
|
+
visitarDeclaracaoAleatorio(declaracao: Aleatorio): void;
|
|
29
32
|
visitarDeclaracaoDefinicaoFuncao(declaracao: FuncaoDeclaracao): void;
|
|
30
33
|
visitarDeclaracaoEnquanto(declaracao: Enquanto): void;
|
|
31
34
|
private formatarBlocoOuVetorDeclaracoes;
|
|
@@ -33,45 +36,45 @@ export declare class FormatadorPotigol implements VisitanteComumInterface {
|
|
|
33
36
|
visitarDeclaracaoEscreva(declaracao: Escreva): void;
|
|
34
37
|
visitarDeclaracaoFazer(declaracao: Fazer): void;
|
|
35
38
|
visitarDeclaracaoImportar(declaracao: Importar): void;
|
|
36
|
-
visitarDeclaracaoPara(declaracao: Para):
|
|
37
|
-
visitarDeclaracaoParaCada(declaracao: ParaCada):
|
|
39
|
+
visitarDeclaracaoPara(declaracao: Para): void;
|
|
40
|
+
visitarDeclaracaoParaCada(declaracao: ParaCada): void;
|
|
38
41
|
visitarDeclaracaoSe(declaracao: Se): void;
|
|
39
42
|
visitarDeclaracaoTente(declaracao: Tente): void;
|
|
40
|
-
visitarDeclaracaoVar(declaracao: Var):
|
|
41
|
-
visitarDeclaracaoVarMultiplo(declaracao: VarMultiplo):
|
|
43
|
+
visitarDeclaracaoVar(declaracao: Var): void;
|
|
44
|
+
visitarDeclaracaoVarMultiplo(declaracao: VarMultiplo): void;
|
|
42
45
|
visitarExpressaoAcessoIndiceVariavel(expressao: any): void;
|
|
43
46
|
visitarExpressaoAcessoElementoMatriz(expressao: any): void;
|
|
44
47
|
visitarExpressaoAcessoMetodo(expressao: any): void;
|
|
45
48
|
visitarExpressaoAgrupamento(expressao: any): any;
|
|
46
|
-
visitarExpressaoAtribuicaoPorIndice(expressao: any):
|
|
47
|
-
visitarExpressaoAtribuicaoPorIndicesMatriz(expressao: any):
|
|
49
|
+
visitarExpressaoAtribuicaoPorIndice(expressao: any): void;
|
|
50
|
+
visitarExpressaoAtribuicaoPorIndicesMatriz(expressao: any): void;
|
|
48
51
|
visitarExpressaoBinaria(expressao: Binario): void;
|
|
49
52
|
visitarExpressaoBloco(declaracao: Bloco): any;
|
|
50
53
|
visitarExpressaoContinua(declaracao?: Continua): ContinuarQuebra;
|
|
51
54
|
visitarExpressaoDeChamada(expressao: any): void;
|
|
52
55
|
visitarExpressaoDefinirValor(expressao: any): void;
|
|
53
56
|
visitarExpressaoDeleguaFuncao(expressao: any): void;
|
|
54
|
-
visitarExpressaoDeVariavel(expressao:
|
|
57
|
+
visitarExpressaoDeVariavel(expressao: Variavel): void;
|
|
55
58
|
visitarExpressaoDicionario(expressao: any): void;
|
|
56
59
|
visitarExpressaoExpressaoRegular(expressao: ExpressaoRegular): Promise<RegExp>;
|
|
57
60
|
visitarDeclaracaoEscrevaMesmaLinha(declaracao: EscrevaMesmaLinha): void;
|
|
58
|
-
visitarExpressaoFalhar(expressao: any):
|
|
61
|
+
visitarExpressaoFalhar(expressao: any): void;
|
|
59
62
|
visitarExpressaoFimPara(declaracao: FimPara): void;
|
|
60
63
|
visitarExpressaoFormatacaoEscrita(declaracao: FormatacaoEscrita): void;
|
|
61
64
|
visitarExpressaoFuncaoConstruto(expressao: FuncaoConstruto): void;
|
|
62
65
|
visitarExpressaoIsto(expressao: any): void;
|
|
63
|
-
visitarExpressaoLeia(expressao: Leia):
|
|
64
|
-
visitarExpressaoLeiaMultiplo(expressao: LeiaMultiplo):
|
|
66
|
+
visitarExpressaoLeia(expressao: Leia): void;
|
|
67
|
+
visitarExpressaoLeiaMultiplo(expressao: LeiaMultiplo): void;
|
|
65
68
|
visitarExpressaoLiteral(expressao: Literal): any;
|
|
66
69
|
visitarExpressaoLogica(expressao: any): void;
|
|
67
70
|
visitarExpressaoRetornar(declaracao: Retorna): any;
|
|
68
71
|
visitarExpressaoSuper(expressao: Super): void;
|
|
69
72
|
visitarExpressaoSustar(declaracao?: Sustar): SustarQuebra;
|
|
70
|
-
visitarExpressaoTipoDe(expressao: TipoDe):
|
|
73
|
+
visitarExpressaoTipoDe(expressao: TipoDe): void;
|
|
71
74
|
visitarExpressaoUnaria(expressao: Unario): void;
|
|
72
75
|
visitarExpressaoVetor(expressao: any): void;
|
|
73
76
|
visitarDeclaracaoConstante(expressao: Constante): any;
|
|
74
|
-
private
|
|
77
|
+
private formatarDeclaracaoTuplas;
|
|
75
78
|
visitarExpressaoDupla(expressao: Dupla): any;
|
|
76
79
|
visitarExpressaoTrio(expressao: Trio): any;
|
|
77
80
|
visitarExpressaoQuarteto(expressao: Quarteto): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatador-potigol.d.ts","sourceRoot":"","sources":["../../fontes/formatador/formatador-potigol.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,QAAQ,EACR,OAAO,EAEP,UAAU,EACV,SAAS,EACT,SAAS,EACT,MAAM,EAGN,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,eAAe,EAEf,OAAO,EAEP,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,EACN,IAAI,EACJ,KAAK,EACL,MAAM,
|
|
1
|
+
{"version":3,"file":"formatador-potigol.d.ts","sourceRoot":"","sources":["../../fontes/formatador/formatador-potigol.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,QAAQ,EACR,OAAO,EAEP,UAAU,EACV,SAAS,EACT,SAAS,EACT,MAAM,EAGN,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,eAAe,EAEf,OAAO,EAEP,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,EACN,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EAEX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,MAAM,EACN,KAAK,EACL,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,EAAE,EACF,KAAK,EACL,GAAG,EACH,WAAW,EACX,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,UAAU,EAEV,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,eAAe,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAG/D,qBAAa,iBAAkB,YAAW,8BAA8B;IACpE,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAA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{
|
|
|
15
15
|
this.devePularLinha = true;
|
|
16
16
|
this.deveIndentar = true;
|
|
17
17
|
}
|
|
18
|
+
visitarDeclaracaoReatribuicaoVariavel(declaracao) {
|
|
19
|
+
if (this.deveIndentar) {
|
|
20
|
+
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}`;
|
|
21
|
+
}
|
|
22
|
+
this.codigoFormatado += `${declaracao.simbolo.lexema}`;
|
|
23
|
+
if (declaracao.inicializador) {
|
|
24
|
+
this.codigoFormatado += ` := `;
|
|
25
|
+
this.deveIndentar = false;
|
|
26
|
+
this.formatarDeclaracaoOuConstruto(declaracao.inicializador);
|
|
27
|
+
this.deveIndentar = true;
|
|
28
|
+
}
|
|
29
|
+
// TODO: Talvez seja necessário mais futuramente.
|
|
30
|
+
/* if (this.devePularLinha) {
|
|
31
|
+
this.codigoFormatado += this.quebraLinha;
|
|
32
|
+
} */
|
|
33
|
+
}
|
|
34
|
+
visitarExpressaoQualTipo(expressao) {
|
|
35
|
+
throw new Error('Método não implementado.');
|
|
36
|
+
}
|
|
18
37
|
/**
|
|
19
38
|
* Aparentemente só existe comentário de uma linha só em Potigol.
|
|
20
39
|
* @param declaracao A declaração de comentário.
|
|
@@ -103,9 +122,9 @@ class FormatadorPotigol {
|
|
|
103
122
|
}
|
|
104
123
|
}
|
|
105
124
|
visitarDeclaracaoEnquanto(declaracao) {
|
|
106
|
-
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}enquanto
|
|
125
|
+
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}enquanto `;
|
|
107
126
|
this.formatarDeclaracaoOuConstruto(declaracao.condicao);
|
|
108
|
-
this.codigoFormatado += `
|
|
127
|
+
this.codigoFormatado += ` faca`;
|
|
109
128
|
this.codigoFormatado += this.quebraLinha;
|
|
110
129
|
this.devePularLinha = true;
|
|
111
130
|
this.formatarDeclaracaoOuConstruto(declaracao.corpo);
|
|
@@ -123,36 +142,44 @@ class FormatadorPotigol {
|
|
|
123
142
|
visitarDeclaracaoEscolha(declaracao) {
|
|
124
143
|
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}escolha `;
|
|
125
144
|
this.formatarDeclaracaoOuConstruto(declaracao.identificadorOuLiteral);
|
|
145
|
+
this.codigoFormatado += this.quebraLinha;
|
|
126
146
|
this.indentacaoAtual += this.tamanhoIndentacao;
|
|
147
|
+
this.deveIndentar = false;
|
|
127
148
|
for (let caminho of declaracao.caminhos) {
|
|
128
|
-
this.deveIndentar = false;
|
|
129
149
|
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}caso `;
|
|
130
150
|
this.formatarBlocoOuVetorDeclaracoes(caminho.condicoes);
|
|
131
151
|
this.codigoFormatado += ` => `;
|
|
152
|
+
this.devePularLinha = false;
|
|
153
|
+
this.deveIndentar = false;
|
|
132
154
|
this.formatarBlocoOuVetorDeclaracoes(caminho.declaracoes);
|
|
133
155
|
this.codigoFormatado += this.quebraLinha;
|
|
156
|
+
this.devePularLinha = true;
|
|
134
157
|
this.deveIndentar = true;
|
|
135
158
|
}
|
|
136
159
|
if (declaracao.caminhoPadrao.declaracoes.length > 0) {
|
|
137
|
-
this.deveIndentar = false;
|
|
138
160
|
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}caso _ => `;
|
|
161
|
+
this.devePularLinha = false;
|
|
162
|
+
this.deveIndentar = false;
|
|
139
163
|
this.formatarBlocoOuVetorDeclaracoes(declaracao.caminhoPadrao.declaracoes);
|
|
164
|
+
this.codigoFormatado += this.quebraLinha;
|
|
165
|
+
this.devePularLinha = true;
|
|
140
166
|
this.deveIndentar = true;
|
|
141
167
|
}
|
|
142
168
|
this.indentacaoAtual -= this.tamanhoIndentacao;
|
|
143
|
-
this.codigoFormatado += `${
|
|
169
|
+
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}fim${this.quebraLinha}`;
|
|
144
170
|
}
|
|
145
171
|
visitarDeclaracaoEscreva(declaracao) {
|
|
146
172
|
if (this.deveIndentar) {
|
|
147
|
-
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}escreva
|
|
173
|
+
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}escreva `;
|
|
148
174
|
}
|
|
149
175
|
else {
|
|
150
|
-
this.codigoFormatado += `escreva
|
|
176
|
+
this.codigoFormatado += `escreva `;
|
|
151
177
|
}
|
|
178
|
+
this.deveIndentar = false;
|
|
152
179
|
for (let argumento of declaracao.argumentos) {
|
|
153
180
|
this.formatarDeclaracaoOuConstruto(argumento);
|
|
154
181
|
}
|
|
155
|
-
this.
|
|
182
|
+
this.deveIndentar = true;
|
|
156
183
|
if (this.devePularLinha) {
|
|
157
184
|
this.codigoFormatado += this.quebraLinha;
|
|
158
185
|
}
|
|
@@ -165,7 +192,6 @@ class FormatadorPotigol {
|
|
|
165
192
|
}
|
|
166
193
|
visitarDeclaracaoPara(declaracao) {
|
|
167
194
|
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}para `;
|
|
168
|
-
this.indentacaoAtual += this.tamanhoIndentacao;
|
|
169
195
|
this.devePularLinha = false;
|
|
170
196
|
if (declaracao.inicializador) {
|
|
171
197
|
if (Array.isArray(declaracao.inicializador)) {
|
|
@@ -186,26 +212,25 @@ class FormatadorPotigol {
|
|
|
186
212
|
this.codigoFormatado += ` faca${this.quebraLinha}`;
|
|
187
213
|
this.formatarDeclaracaoOuConstruto(declaracao.incrementar);
|
|
188
214
|
this.formatarBlocoOuVetorDeclaracoes(declaracao.corpo.declaracoes);
|
|
189
|
-
this.indentacaoAtual -= this.tamanhoIndentacao;
|
|
190
215
|
this.codigoFormatado += `${this.quebraLinha}${' '.repeat(this.indentacaoAtual)}fim${this.quebraLinha}`;
|
|
191
216
|
}
|
|
192
217
|
visitarDeclaracaoParaCada(declaracao) {
|
|
193
218
|
throw new Error('Método não implementado');
|
|
194
219
|
}
|
|
195
220
|
visitarDeclaracaoSe(declaracao) {
|
|
196
|
-
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}se
|
|
221
|
+
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}se `;
|
|
197
222
|
this.formatarDeclaracaoOuConstruto(declaracao.condicao);
|
|
198
|
-
this.codigoFormatado += `
|
|
223
|
+
this.codigoFormatado += ` entao${this.quebraLinha}`;
|
|
199
224
|
this.indentacaoAtual += this.tamanhoIndentacao;
|
|
200
225
|
for (let declaracaoBloco of declaracao.caminhoEntao.declaracoes) {
|
|
201
226
|
this.formatarDeclaracaoOuConstruto(declaracaoBloco);
|
|
202
227
|
}
|
|
203
228
|
this.indentacaoAtual -= this.tamanhoIndentacao;
|
|
204
229
|
if (declaracao.caminhoSenao) {
|
|
205
|
-
this.codigoFormatado += `${
|
|
230
|
+
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}senao${this.quebraLinha}`;
|
|
206
231
|
this.formatarDeclaracaoOuConstruto(declaracao.caminhoSenao);
|
|
207
232
|
}
|
|
208
|
-
this.codigoFormatado += `${
|
|
233
|
+
this.codigoFormatado += `${' '.repeat(this.indentacaoAtual)}fim${this.quebraLinha}`;
|
|
209
234
|
}
|
|
210
235
|
visitarDeclaracaoTente(declaracao) {
|
|
211
236
|
throw new Error('Método não implementado');
|
|
@@ -247,12 +272,17 @@ class FormatadorPotigol {
|
|
|
247
272
|
throw new Error('Método não implementado');
|
|
248
273
|
}
|
|
249
274
|
visitarExpressaoBinaria(expressao) {
|
|
250
|
-
/* this.codigoFormatado += `${" ".repeat(this.indentacaoAtual)}` */
|
|
251
275
|
this.formatarDeclaracaoOuConstruto(expressao.esquerda);
|
|
252
276
|
switch (expressao.operador.tipo) {
|
|
253
277
|
case lexico_regular_1.default.ADICAO:
|
|
254
278
|
this.codigoFormatado += ' + ';
|
|
255
279
|
break;
|
|
280
|
+
case lexico_regular_1.default.CONCATENACAO_LISTA:
|
|
281
|
+
this.codigoFormatado += ` :: `;
|
|
282
|
+
break;
|
|
283
|
+
case lexico_regular_1.default.DIFERENTE:
|
|
284
|
+
this.codigoFormatado += ` <> `;
|
|
285
|
+
break;
|
|
256
286
|
case lexico_regular_1.default.DIVISAO:
|
|
257
287
|
this.codigoFormatado += ' / ';
|
|
258
288
|
break;
|
|
@@ -262,6 +292,9 @@ class FormatadorPotigol {
|
|
|
262
292
|
case lexico_regular_1.default.IGUAL:
|
|
263
293
|
this.codigoFormatado += ' = ';
|
|
264
294
|
break;
|
|
295
|
+
case lexico_regular_1.default.IGUAL_IGUAL:
|
|
296
|
+
this.codigoFormatado += ` == `;
|
|
297
|
+
break;
|
|
265
298
|
case lexico_regular_1.default.MAIOR:
|
|
266
299
|
this.codigoFormatado += ' > ';
|
|
267
300
|
break;
|
|
@@ -286,12 +319,6 @@ class FormatadorPotigol {
|
|
|
286
319
|
case lexico_regular_1.default.EXPONENCIACAO:
|
|
287
320
|
this.codigoFormatado += ` ^ `;
|
|
288
321
|
break;
|
|
289
|
-
case lexico_regular_1.default.IGUAL_IGUAL:
|
|
290
|
-
this.codigoFormatado += ` == `;
|
|
291
|
-
break;
|
|
292
|
-
case lexico_regular_1.default.DIFERENTE:
|
|
293
|
-
this.codigoFormatado += ` <> `;
|
|
294
|
-
break;
|
|
295
322
|
default:
|
|
296
323
|
console.log(expressao.operador.tipo);
|
|
297
324
|
break;
|
|
@@ -314,7 +341,10 @@ class FormatadorPotigol {
|
|
|
314
341
|
throw new Error('Método não implementado');
|
|
315
342
|
}
|
|
316
343
|
visitarExpressaoDeVariavel(expressao) {
|
|
317
|
-
|
|
344
|
+
if (this.deveIndentar) {
|
|
345
|
+
this.codigoFormatado += ' '.repeat(this.indentacaoAtual);
|
|
346
|
+
}
|
|
347
|
+
this.codigoFormatado += `${expressao.simbolo.lexema}`;
|
|
318
348
|
}
|
|
319
349
|
visitarExpressaoDicionario(expressao) {
|
|
320
350
|
throw new Error('Método não implementado');
|
|
@@ -364,11 +394,18 @@ class FormatadorPotigol {
|
|
|
364
394
|
this.codigoFormatado += `, `;
|
|
365
395
|
}
|
|
366
396
|
}
|
|
367
|
-
this.codigoFormatado = `${this.codigoFormatado.slice(0, -2)})
|
|
397
|
+
this.codigoFormatado = `${this.codigoFormatado.slice(0, -2)})`;
|
|
368
398
|
}
|
|
399
|
+
// Se há tipo de retorno definido
|
|
400
|
+
if (expressao.tipoRetorno) {
|
|
401
|
+
this.codigoFormatado += `: ${expressao.tipoRetorno}`;
|
|
402
|
+
}
|
|
403
|
+
this.codigoFormatado += ` = `;
|
|
404
|
+
this.deveIndentar = false;
|
|
369
405
|
for (let declaracaoCorpo of expressao.corpo) {
|
|
370
406
|
this.formatarDeclaracaoOuConstruto(declaracaoCorpo);
|
|
371
407
|
}
|
|
408
|
+
this.deveIndentar = true;
|
|
372
409
|
this.indentacaoAtual -= this.tamanhoIndentacao;
|
|
373
410
|
}
|
|
374
411
|
visitarExpressaoIsto(expressao) {
|
|
@@ -454,9 +491,12 @@ class FormatadorPotigol {
|
|
|
454
491
|
throw new Error('Método não implementado');
|
|
455
492
|
}
|
|
456
493
|
visitarDeclaracaoConstante(expressao) {
|
|
494
|
+
if (this.deveIndentar) {
|
|
495
|
+
this.codigoFormatado += ' '.repeat(this.indentacaoAtual);
|
|
496
|
+
}
|
|
457
497
|
this.codigoFormatado += `${expressao.simbolo.lexema}`;
|
|
458
498
|
}
|
|
459
|
-
|
|
499
|
+
formatarDeclaracaoTuplas(declaracao) {
|
|
460
500
|
const declaracoes = Object.keys(declaracao);
|
|
461
501
|
this.codigoFormatado += "(";
|
|
462
502
|
for (let chaveDeclaracao of declaracoes) {
|
|
@@ -467,31 +507,31 @@ class FormatadorPotigol {
|
|
|
467
507
|
this.codigoFormatado += ")";
|
|
468
508
|
}
|
|
469
509
|
visitarExpressaoDupla(expressao) {
|
|
470
|
-
this.
|
|
510
|
+
this.formatarDeclaracaoTuplas(expressao);
|
|
471
511
|
}
|
|
472
512
|
visitarExpressaoTrio(expressao) {
|
|
473
|
-
this.
|
|
513
|
+
this.formatarDeclaracaoTuplas(expressao);
|
|
474
514
|
}
|
|
475
515
|
visitarExpressaoQuarteto(expressao) {
|
|
476
|
-
this.
|
|
516
|
+
this.formatarDeclaracaoTuplas(expressao);
|
|
477
517
|
}
|
|
478
518
|
visitarExpressaoQuinteto(expressao) {
|
|
479
|
-
this.
|
|
519
|
+
this.formatarDeclaracaoTuplas(expressao);
|
|
480
520
|
}
|
|
481
521
|
visitarExpressaoSexteto(expressao) {
|
|
482
|
-
this.
|
|
522
|
+
this.formatarDeclaracaoTuplas(expressao);
|
|
483
523
|
}
|
|
484
524
|
visitarExpressaoSepteto(expressao) {
|
|
485
|
-
this.
|
|
525
|
+
this.formatarDeclaracaoTuplas(expressao);
|
|
486
526
|
}
|
|
487
527
|
visitarExpressaoOcteto(expressao) {
|
|
488
|
-
this.
|
|
528
|
+
this.formatarDeclaracaoTuplas(expressao);
|
|
489
529
|
}
|
|
490
530
|
visitarExpressaoNoneto(expressao) {
|
|
491
|
-
this.
|
|
531
|
+
this.formatarDeclaracaoTuplas(expressao);
|
|
492
532
|
}
|
|
493
533
|
visitarExpressaoDeceto(expressao) {
|
|
494
|
-
this.
|
|
534
|
+
this.formatarDeclaracaoTuplas(expressao);
|
|
495
535
|
}
|
|
496
536
|
formatarDeclaracaoOuConstruto(declaracaoOuConstruto) {
|
|
497
537
|
switch (declaracaoOuConstruto.constructor.name) {
|
|
@@ -609,6 +649,9 @@ class FormatadorPotigol {
|
|
|
609
649
|
case 'ParaCada':
|
|
610
650
|
this.visitarDeclaracaoParaCada(declaracaoOuConstruto);
|
|
611
651
|
break;
|
|
652
|
+
case 'ReatribuicaoVariavel':
|
|
653
|
+
this.visitarDeclaracaoReatribuicaoVariavel(declaracaoOuConstruto);
|
|
654
|
+
break;
|
|
612
655
|
case 'Retorna':
|
|
613
656
|
this.visitarExpressaoRetornar(declaracaoOuConstruto);
|
|
614
657
|
break;
|