@designliquido/delegua 0.1.3 → 0.1.7
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/bin/package.json +4 -3
- package/package.json +4 -3
- package/src/avaliador-sintatico/dialetos/egua-classico.js +116 -116
- package/src/avaliador-sintatico/dialetos/egua-classico.js.map +1 -1
- package/src/avaliador-sintatico/{parser-error.js → erros-avaliador.js} +1 -1
- package/src/avaliador-sintatico/erros-avaliador.js.map +1 -0
- package/src/avaliador-sintatico/index.js +123 -123
- package/src/avaliador-sintatico/index.js.map +1 -1
- package/src/construtos/assign-subscript.js +1 -1
- package/src/construtos/assign-subscript.js.map +1 -1
- package/src/construtos/atribuir.js +1 -1
- package/src/construtos/atribuir.js.map +1 -1
- package/src/construtos/binario.js +1 -1
- package/src/construtos/binario.js.map +1 -1
- package/src/construtos/call.js +1 -1
- package/src/construtos/call.js.map +1 -1
- package/src/construtos/conjunto.js +1 -1
- package/src/construtos/conjunto.js.map +1 -1
- package/src/construtos/dicionario.js +1 -1
- package/src/construtos/dicionario.js.map +1 -1
- package/src/construtos/funcao.js +1 -1
- package/src/construtos/funcao.js.map +1 -1
- package/src/construtos/get.js +1 -1
- package/src/construtos/get.js.map +1 -1
- package/src/construtos/grouping.js +1 -1
- package/src/construtos/grouping.js.map +1 -1
- package/src/construtos/isto.js +1 -1
- package/src/construtos/isto.js.map +1 -1
- package/src/construtos/literal.js +1 -1
- package/src/construtos/literal.js.map +1 -1
- package/src/construtos/logical.js +1 -1
- package/src/construtos/logical.js.map +1 -1
- package/src/construtos/subscript.js +1 -1
- package/src/construtos/subscript.js.map +1 -1
- package/src/construtos/super.js +1 -1
- package/src/construtos/super.js.map +1 -1
- package/src/construtos/unario.js +1 -1
- package/src/construtos/unario.js.map +1 -1
- package/src/construtos/variavel.js +1 -1
- package/src/construtos/variavel.js.map +1 -1
- package/src/construtos/vetor.js +1 -1
- package/src/construtos/vetor.js.map +1 -1
- package/src/declaracoes/block.js +33 -0
- package/src/declaracoes/block.js.map +1 -0
- package/src/declaracoes/classe.js +35 -0
- package/src/declaracoes/classe.js.map +1 -0
- package/src/declaracoes/continua.js +31 -0
- package/src/declaracoes/continua.js.map +1 -0
- package/src/declaracoes/enquanto.js +34 -0
- package/src/declaracoes/enquanto.js.map +1 -0
- package/src/declaracoes/escolha.js +35 -0
- package/src/declaracoes/escolha.js.map +1 -0
- package/src/declaracoes/escreva.js +33 -0
- package/src/declaracoes/escreva.js.map +1 -0
- package/src/declaracoes/expressao.js +33 -0
- package/src/declaracoes/expressao.js.map +1 -0
- package/src/declaracoes/fazer.js +34 -0
- package/src/declaracoes/fazer.js.map +1 -0
- package/src/declaracoes/funcao.js +34 -0
- package/src/declaracoes/funcao.js.map +1 -0
- package/src/declaracoes/importar.js +34 -0
- package/src/declaracoes/importar.js.map +1 -0
- package/src/declaracoes/index.js +27 -246
- package/src/declaracoes/index.js.map +1 -1
- package/src/declaracoes/para.js +36 -0
- package/src/declaracoes/para.js.map +1 -0
- package/src/declaracoes/pausa.js +31 -0
- package/src/declaracoes/pausa.js.map +1 -0
- package/src/declaracoes/retorna.js +34 -0
- package/src/declaracoes/retorna.js.map +1 -0
- package/src/declaracoes/se.js +36 -0
- package/src/declaracoes/se.js.map +1 -0
- package/src/declaracoes/stmt.js +11 -0
- package/src/declaracoes/stmt.js.map +1 -0
- package/src/declaracoes/tente.js +36 -0
- package/src/declaracoes/tente.js.map +1 -0
- package/src/declaracoes/var.js +34 -0
- package/src/declaracoes/var.js.map +1 -0
- package/src/delegua.js +11 -6
- package/src/delegua.js.map +1 -1
- package/src/estruturas/funcao.js +1 -1
- package/src/estruturas/funcao.js.map +1 -1
- package/src/interpretador/dialetos/egua-classico.js +64 -68
- package/src/interpretador/dialetos/egua-classico.js.map +1 -1
- package/src/interpretador/index.js +74 -75
- package/src/interpretador/index.js.map +1 -1
- package/src/lexador/dialetos/egua-classico.js +5 -7
- package/src/lexador/dialetos/egua-classico.js.map +1 -1
- package/src/lexador/index.js +7 -10
- package/src/lexador/index.js.map +1 -1
- package/src/resolvedor/dialetos/egua-classico.js +39 -39
- package/src/resolvedor/dialetos/egua-classico.js.map +1 -1
- package/src/resolvedor/index.js +39 -39
- package/src/resolvedor/index.js.map +1 -1
- package/src/tiposDeSimbolos.js +1 -1
- package/src/tiposDeSimbolos.js.map +1 -1
- package/src/avaliador-sintatico/parser-error.js.map +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.Tente = void 0;
|
|
19
|
+
var stmt_1 = require("./stmt");
|
|
20
|
+
var Tente = /** @class */ (function (_super) {
|
|
21
|
+
__extends(Tente, _super);
|
|
22
|
+
function Tente(tryBranch, catchBranch, elseBranch, finallyBranch) {
|
|
23
|
+
var _this = _super.call(this) || this;
|
|
24
|
+
_this.tryBranch = tryBranch;
|
|
25
|
+
_this.catchBranch = catchBranch;
|
|
26
|
+
_this.elseBranch = elseBranch;
|
|
27
|
+
_this.finallyBranch = finallyBranch;
|
|
28
|
+
return _this;
|
|
29
|
+
}
|
|
30
|
+
Tente.prototype.aceitar = function (visitor) {
|
|
31
|
+
return visitor.visitarExpressaoTente(this);
|
|
32
|
+
};
|
|
33
|
+
return Tente;
|
|
34
|
+
}(stmt_1.Stmt));
|
|
35
|
+
exports.Tente = Tente;
|
|
36
|
+
//# sourceMappingURL=tente.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tente.js","sourceRoot":"","sources":["../../../src/declaracoes/tente.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAG9B;IAA2B,yBAAI;IAM3B,eAAY,SAAc,EAAE,WAAgB,EAAE,UAAe,EAAE,aAAkB;QAAjF,YACI,iBAAO,SAKV;QAJG,KAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,KAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,KAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,KAAI,CAAC,aAAa,GAAG,aAAa,CAAC;;IACvC,CAAC;IAED,uBAAO,GAAP,UAAQ,OAAY;QAChB,OAAO,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IACL,YAAC;AAAD,CAAC,AAjBD,CAA2B,WAAI,GAiB9B;AAjBY,sBAAK"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.Var = void 0;
|
|
19
|
+
var stmt_1 = require("./stmt");
|
|
20
|
+
var Var = /** @class */ (function (_super) {
|
|
21
|
+
__extends(Var, _super);
|
|
22
|
+
function Var(nome, inicializador) {
|
|
23
|
+
var _this = _super.call(this) || this;
|
|
24
|
+
_this.nome = nome;
|
|
25
|
+
_this.inicializador = inicializador;
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
Var.prototype.aceitar = function (visitor) {
|
|
29
|
+
return visitor.visitarExpressaoVar(this);
|
|
30
|
+
};
|
|
31
|
+
return Var;
|
|
32
|
+
}(stmt_1.Stmt));
|
|
33
|
+
exports.Var = Var;
|
|
34
|
+
//# sourceMappingURL=var.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"var.js","sourceRoot":"","sources":["../../../src/declaracoes/var.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAG9B;IAAyB,uBAAI;IAIzB,aAAY,IAAS,EAAE,aAAkB;QAAzC,YACI,iBAAO,SAGV;QAFG,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,aAAa,GAAG,aAAa,CAAC;;IACvC,CAAC;IAED,qBAAO,GAAP,UAAQ,OAAY;QAChB,OAAO,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IACL,UAAC;AAAD,CAAC,AAbD,CAAyB,WAAI,GAa5B;AAbY,kBAAG"}
|
package/src/delegua.js
CHANGED
|
@@ -53,11 +53,16 @@ var Delegua = /** @class */ (function () {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
Delegua.prototype.versao = function () {
|
|
56
|
-
|
|
56
|
+
try {
|
|
57
|
+
var manifesto = caminho.resolve(__dirname, 'package.json');
|
|
58
|
+
return JSON.parse(fs.readFileSync(manifesto, { encoding: 'utf8' })).version || '0.1';
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return '0.1 (desenvolvimento)';
|
|
62
|
+
}
|
|
57
63
|
};
|
|
58
64
|
Delegua.prototype.iniciarDelegua = function () {
|
|
59
65
|
var _this = this;
|
|
60
|
-
var interpretador = new interpretador_1.Interpretador(this, process.cwd());
|
|
61
66
|
console.log("Console da Linguagem Del\u00E9gua v".concat(this.versao()));
|
|
62
67
|
var leiaLinha = readline.createInterface({
|
|
63
68
|
input: process.stdin,
|
|
@@ -68,20 +73,20 @@ var Delegua = /** @class */ (function () {
|
|
|
68
73
|
leiaLinha.on("line", function (linha) {
|
|
69
74
|
_this.teveErro = false;
|
|
70
75
|
_this.teveErroEmTempoDeExecucao = false;
|
|
71
|
-
_this.
|
|
76
|
+
_this.executar(linha);
|
|
72
77
|
leiaLinha.prompt();
|
|
73
78
|
});
|
|
74
79
|
};
|
|
75
80
|
Delegua.prototype.carregarArquivo = function (nomeArquivo) {
|
|
76
81
|
this.nomeArquivo = caminho.basename(nomeArquivo);
|
|
77
82
|
var dadosDoArquivo = fs.readFileSync(nomeArquivo).toString();
|
|
78
|
-
this.
|
|
83
|
+
this.executar(dadosDoArquivo);
|
|
79
84
|
if (this.teveErro)
|
|
80
85
|
process.exit(65);
|
|
81
86
|
if (this.teveErroEmTempoDeExecucao)
|
|
82
87
|
process.exit(70);
|
|
83
88
|
};
|
|
84
|
-
Delegua.prototype.
|
|
89
|
+
Delegua.prototype.executar = function (codigo) {
|
|
85
90
|
var simbolos = this.lexador.scan(codigo);
|
|
86
91
|
if (this.teveErro === true)
|
|
87
92
|
return;
|
|
@@ -108,7 +113,7 @@ var Delegua = /** @class */ (function () {
|
|
|
108
113
|
this.reportar(simbolo.line, " no '".concat(simbolo.lexema, "'"), mensagemDeErro);
|
|
109
114
|
}
|
|
110
115
|
};
|
|
111
|
-
Delegua.prototype.
|
|
116
|
+
Delegua.prototype.erroNoLexador = function (linha, caractere, mensagem) {
|
|
112
117
|
this.reportar(linha, " no '".concat(caractere, "'"), mensagem);
|
|
113
118
|
};
|
|
114
119
|
Delegua.prototype.erroEmTempoDeExecucao = function (erro) {
|
package/src/delegua.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegua.js","sourceRoot":"","sources":["../../src/delegua.ts"],"names":[],"mappings":";;;AAAA,uBAAyB;AACzB,8BAAgC;AAChC,mCAAqC;AAErC,qCAAkC;AAClC,6DAA+C;AAC/C,2CAAwC;AACxC,iDAAgD;AAChD,qDAAgD;AAEhD,uCAA6C;AAG7C,wEAAmF;AACnF,qEAA2E;AAC3E,8EAAkF;AAClF,kEAAqE;AAErE;IAWI,iBAAY,OAA2B,EAAE,WAAoB;QAAjD,wBAAA,EAAA,mBAA2B;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,yBAAyB,GAAG,KAAK,CAAC;QAEvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,QAAQ,IAAI,CAAC,OAAO,EAAE;YAClB,KAAK,MAAM;gBACP,IAAI,CAAC,aAAa,GAAG,IAAI,yCAAyB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;gBACxE,IAAI,CAAC,OAAO,GAAG,IAAI,iCAAiB,CAAC,IAAI,CAAC,CAAC;gBAC3C,IAAI,CAAC,kBAAkB,GAAG,IAAI,kCAAkB,CAAC,IAAI,CAAC,CAAC;gBACvD,IAAI,CAAC,UAAU,GAAG,IAAI,oCAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;gBACrE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;gBACpC,MAAM;YACV,KAAK,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,CAAC,CAAC;IACzD,CAAC;IAED,uCAAqB,GAArB,UAAsB,IAAS;QAC3B,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YAC3C,IAAI,IAAI,CAAC,WAAW;gBAChB,OAAO,CAAC,KAAK,CACT,0BAAmB,IAAI,CAAC,WAAW,uBAAa,IAAI,CAAC,OAAO,CAAC,KAAK,eAAK,IAAI,CAAC,QAAQ,CAAE,CACzF,CAAC;;gBACD,OAAO,CAAC,KAAK,CAAC,wBAAiB,IAAI,CAAC,OAAO,CAAC,KAAK,eAAK,IAAI,CAAC,QAAQ,CAAE,CAAC,CAAC;SAC/E;aAAM,IAAI,CAAC,CAAC,IAAI,YAAY,0BAAe,CAAC,EAAE,EAAE,uDAAuD;YACpG,OAAO,CAAC,KAAK,CAAC,gBAAS,IAAI,CAAC,QAAQ,CAAE,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAC1C,CAAC;IACL,cAAC;AAAD,CAAC,AA1ID,IA0IC;AA1IY,0BAAO"}
|
package/src/estruturas/funcao.js
CHANGED
|
@@ -54,7 +54,7 @@ var DeleguaFuncao = /** @class */ (function (_super) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
try {
|
|
57
|
-
interpretador.
|
|
57
|
+
interpretador.executarBloco(this.declaracao.funcao, ambiente);
|
|
58
58
|
}
|
|
59
59
|
catch (erro) {
|
|
60
60
|
if (erro instanceof excecoes_1.ReturnException) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funcao.js","sourceRoot":"","sources":["../../../src/estruturas/funcao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAsC;AACtC,wCAAuC;AACvC,wCAA8C;AAE9C;IAAmC,iCAAQ;IAMvC,uBAAY,IAAS,EAAE,UAAe,EAAE,OAAY,EAAE,cAAsB;QAAtB,+BAAA,EAAA,sB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guaClassico = /** @class */ (function () {
|
|
|
31
31
|
InterpretadorEguaClassico.prototype.resolver = function (expr, depth) {
|
|
32
32
|
this.locais.set(expr, depth);
|
|
33
33
|
};
|
|
34
|
-
InterpretadorEguaClassico.prototype.
|
|
34
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoLiteral = function (expr) {
|
|
35
35
|
return expr.valor;
|
|
36
36
|
};
|
|
37
37
|
InterpretadorEguaClassico.prototype.avaliar = function (expr) {
|
|
@@ -39,7 +39,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
39
39
|
return expr.aceitar(this);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
InterpretadorEguaClassico.prototype.
|
|
42
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoAgrupamento = function (expr) {
|
|
43
43
|
return this.avaliar(expr.expressao);
|
|
44
44
|
};
|
|
45
45
|
InterpretadorEguaClassico.prototype.eVerdadeiro = function (objeto) {
|
|
@@ -49,16 +49,16 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
49
49
|
return Boolean(objeto);
|
|
50
50
|
return true;
|
|
51
51
|
};
|
|
52
|
-
InterpretadorEguaClassico.prototype.
|
|
52
|
+
InterpretadorEguaClassico.prototype.verificarOperandoNumero = function (operador, operand) {
|
|
53
53
|
if (typeof operand === "number")
|
|
54
54
|
return;
|
|
55
55
|
throw new excecoes_1.ErroEmTempoDeExecucao(operador, "Operador precisa ser um número.");
|
|
56
56
|
};
|
|
57
|
-
InterpretadorEguaClassico.prototype.
|
|
57
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoUnaria = function (expr) {
|
|
58
58
|
var direita = this.avaliar(expr.direita);
|
|
59
59
|
switch (expr.operador.tipo) {
|
|
60
60
|
case tiposDeSimbolos_1.default.SUBTRACAO:
|
|
61
|
-
this.
|
|
61
|
+
this.verificarOperandoNumero(expr.operador, direita);
|
|
62
62
|
return -direita;
|
|
63
63
|
case tiposDeSimbolos_1.default.NEGACAO:
|
|
64
64
|
return !this.eVerdadeiro(direita);
|
|
@@ -74,32 +74,32 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
74
74
|
return false;
|
|
75
75
|
return esquerda === direita;
|
|
76
76
|
};
|
|
77
|
-
InterpretadorEguaClassico.prototype.
|
|
77
|
+
InterpretadorEguaClassico.prototype.verificarOperandosNumeros = function (operador, direita, esquerda) {
|
|
78
78
|
if (typeof direita === "number" && typeof esquerda === "number")
|
|
79
79
|
return;
|
|
80
80
|
throw new excecoes_1.ErroEmTempoDeExecucao(operador, "Operadores precisam ser números.");
|
|
81
81
|
};
|
|
82
|
-
InterpretadorEguaClassico.prototype.
|
|
82
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoBinaria = function (expr) {
|
|
83
83
|
var esquerda = this.avaliar(expr.esquerda);
|
|
84
84
|
var direita = this.avaliar(expr.direita);
|
|
85
85
|
switch (expr.operador.tipo) {
|
|
86
86
|
case tiposDeSimbolos_1.default.EXPONENCIACAO:
|
|
87
|
-
this.
|
|
87
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
88
88
|
return Math.pow(esquerda, direita);
|
|
89
89
|
case tiposDeSimbolos_1.default.MAIOR:
|
|
90
|
-
this.
|
|
90
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
91
91
|
return Number(esquerda) > Number(direita);
|
|
92
92
|
case tiposDeSimbolos_1.default.MAIOR_IGUAL:
|
|
93
|
-
this.
|
|
93
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
94
94
|
return Number(esquerda) >= Number(direita);
|
|
95
95
|
case tiposDeSimbolos_1.default.MENOR:
|
|
96
|
-
this.
|
|
96
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
97
97
|
return Number(esquerda) < Number(direita);
|
|
98
98
|
case tiposDeSimbolos_1.default.MENOR_IGUAL:
|
|
99
|
-
this.
|
|
99
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
100
100
|
return Number(esquerda) <= Number(direita);
|
|
101
101
|
case tiposDeSimbolos_1.default.SUBTRACAO:
|
|
102
|
-
this.
|
|
102
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
103
103
|
return Number(esquerda) - Number(direita);
|
|
104
104
|
case tiposDeSimbolos_1.default.ADICAO:
|
|
105
105
|
if (typeof esquerda === "number" && typeof direita === "number") {
|
|
@@ -111,28 +111,28 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
111
111
|
}
|
|
112
112
|
throw new excecoes_1.ErroEmTempoDeExecucao(expr.operador, "Operadores precisam ser dois números ou duas strings.");
|
|
113
113
|
case tiposDeSimbolos_1.default.DIVISAO:
|
|
114
|
-
this.
|
|
114
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
115
115
|
return Number(esquerda) / Number(direita);
|
|
116
116
|
case tiposDeSimbolos_1.default.MULTIPLICACAO:
|
|
117
|
-
this.
|
|
117
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
118
118
|
return Number(esquerda) * Number(direita);
|
|
119
119
|
case tiposDeSimbolos_1.default.MODULO:
|
|
120
|
-
this.
|
|
120
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
121
121
|
return Number(esquerda) % Number(direita);
|
|
122
122
|
case tiposDeSimbolos_1.default.BIT_AND:
|
|
123
|
-
this.
|
|
123
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
124
124
|
return Number(esquerda) & Number(direita);
|
|
125
125
|
case tiposDeSimbolos_1.default.BIT_XOR:
|
|
126
|
-
this.
|
|
126
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
127
127
|
return Number(esquerda) ^ Number(direita);
|
|
128
128
|
case tiposDeSimbolos_1.default.BIT_OR:
|
|
129
|
-
this.
|
|
129
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
130
130
|
return Number(esquerda) | Number(direita);
|
|
131
131
|
case tiposDeSimbolos_1.default.MENOR_MENOR:
|
|
132
|
-
this.
|
|
132
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
133
133
|
return Number(esquerda) << Number(direita);
|
|
134
134
|
case tiposDeSimbolos_1.default.MAIOR_MAIOR:
|
|
135
|
-
this.
|
|
135
|
+
this.verificarOperandosNumeros(expr.operador, esquerda, direita);
|
|
136
136
|
return Number(esquerda) >> Number(direita);
|
|
137
137
|
case tiposDeSimbolos_1.default.DIFERENTE:
|
|
138
138
|
return !this.eIgual(esquerda, direita);
|
|
@@ -141,7 +141,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
141
141
|
}
|
|
142
142
|
return null;
|
|
143
143
|
};
|
|
144
|
-
InterpretadorEguaClassico.prototype.
|
|
144
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDeChamada = function (expr) {
|
|
145
145
|
var callee = this.avaliar(expr.callee);
|
|
146
146
|
var argumentos = [];
|
|
147
147
|
for (var i = 0; i < expr.argumentos.length; i++) {
|
|
@@ -183,7 +183,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
183
183
|
}
|
|
184
184
|
return callee.chamar(this, argumentos);
|
|
185
185
|
};
|
|
186
|
-
InterpretadorEguaClassico.prototype.
|
|
186
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDeAtribuicao = function (expr) {
|
|
187
187
|
var valor = this.avaliar(expr.valor);
|
|
188
188
|
var distancia = this.locais.get(expr);
|
|
189
189
|
if (distancia !== undefined) {
|
|
@@ -203,13 +203,13 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
203
203
|
return this.global.obterVariavel(nome);
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
|
-
InterpretadorEguaClassico.prototype.
|
|
206
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDeVariavel = function (expr) {
|
|
207
207
|
return this.procurarVariavel(expr.nome, expr);
|
|
208
208
|
};
|
|
209
|
-
InterpretadorEguaClassico.prototype.
|
|
209
|
+
InterpretadorEguaClassico.prototype.visitarDeclaracaoDeExpressao = function (stmt) {
|
|
210
210
|
return this.avaliar(stmt.expressao);
|
|
211
211
|
};
|
|
212
|
-
InterpretadorEguaClassico.prototype.
|
|
212
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoLogica = function (expr) {
|
|
213
213
|
var esquerda = this.avaliar(expr.esquerda);
|
|
214
214
|
if (expr.operador.tipo === tiposDeSimbolos_1.default.EM) {
|
|
215
215
|
var direita = this.avaliar(expr.direita);
|
|
@@ -235,7 +235,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
235
235
|
}
|
|
236
236
|
return this.avaliar(expr.direita);
|
|
237
237
|
};
|
|
238
|
-
InterpretadorEguaClassico.prototype.
|
|
238
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoSe = function (stmt) {
|
|
239
239
|
if (this.eVerdadeiro(this.avaliar(stmt.condicao))) {
|
|
240
240
|
this.executar(stmt.thenBranch);
|
|
241
241
|
return null;
|
|
@@ -252,7 +252,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
252
252
|
}
|
|
253
253
|
return null;
|
|
254
254
|
};
|
|
255
|
-
InterpretadorEguaClassico.prototype.
|
|
255
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoPara = function (stmt) {
|
|
256
256
|
if (stmt.inicializador !== null) {
|
|
257
257
|
this.avaliar(stmt.inicializador);
|
|
258
258
|
}
|
|
@@ -281,7 +281,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
281
281
|
}
|
|
282
282
|
return null;
|
|
283
283
|
};
|
|
284
|
-
InterpretadorEguaClassico.prototype.
|
|
284
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoFazer = function (stmt) {
|
|
285
285
|
do {
|
|
286
286
|
try {
|
|
287
287
|
this.executar(stmt.doBranch);
|
|
@@ -298,7 +298,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
298
298
|
}
|
|
299
299
|
} while (this.eVerdadeiro(this.avaliar(stmt.whileCondition)));
|
|
300
300
|
};
|
|
301
|
-
InterpretadorEguaClassico.prototype.
|
|
301
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoEscolha = function (stmt) {
|
|
302
302
|
var switchCondition = this.avaliar(stmt.condicao);
|
|
303
303
|
var branches = stmt.branches;
|
|
304
304
|
var defaultBranch = stmt.defaultBranch;
|
|
@@ -338,28 +338,28 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
};
|
|
341
|
-
InterpretadorEguaClassico.prototype.
|
|
341
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoTente = function (stmt) {
|
|
342
342
|
try {
|
|
343
343
|
var sucesso = true;
|
|
344
344
|
try {
|
|
345
|
-
this.
|
|
345
|
+
this.executarBloco(stmt.tryBranch, new ambiente_1.Ambiente(this.ambiente));
|
|
346
346
|
}
|
|
347
347
|
catch (erro) {
|
|
348
348
|
sucesso = false;
|
|
349
349
|
if (stmt.catchBranch !== null) {
|
|
350
|
-
this.
|
|
350
|
+
this.executarBloco(stmt.catchBranch, new ambiente_1.Ambiente(this.ambiente));
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
if (sucesso && stmt.elseBranch !== null) {
|
|
354
|
-
this.
|
|
354
|
+
this.executarBloco(stmt.elseBranch, new ambiente_1.Ambiente(this.ambiente));
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
finally {
|
|
358
358
|
if (stmt.finallyBranch !== null)
|
|
359
|
-
this.
|
|
359
|
+
this.executarBloco(stmt.finallyBranch, new ambiente_1.Ambiente(this.ambiente));
|
|
360
360
|
}
|
|
361
361
|
};
|
|
362
|
-
InterpretadorEguaClassico.prototype.
|
|
362
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoEnquanto = function (stmt) {
|
|
363
363
|
while (this.eVerdadeiro(this.avaliar(stmt.condicao))) {
|
|
364
364
|
try {
|
|
365
365
|
this.executar(stmt.corpo);
|
|
@@ -377,10 +377,10 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
377
377
|
}
|
|
378
378
|
return null;
|
|
379
379
|
};
|
|
380
|
-
InterpretadorEguaClassico.prototype.
|
|
380
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoImportar = function (stmt) {
|
|
381
381
|
var caminhoRelativo = this.avaliar(stmt.caminho);
|
|
382
382
|
var caminhoTotal = caminho.join(this.diretorioBase, caminhoRelativo);
|
|
383
|
-
|
|
383
|
+
// const pastaTotal = caminho.dirname(caminhoTotal);
|
|
384
384
|
var nomeArquivo = caminho.basename(caminhoTotal);
|
|
385
385
|
var dados = (0, importarBiblioteca_1.default)(caminhoRelativo);
|
|
386
386
|
if (dados)
|
|
@@ -395,8 +395,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
395
395
|
}
|
|
396
396
|
dados = fs.readFileSync(caminhoTotal).toString();
|
|
397
397
|
var delegua = new delegua_1.Delegua(this.Delegua.dialeto, nomeArquivo);
|
|
398
|
-
|
|
399
|
-
delegua.run(dados);
|
|
398
|
+
delegua.executar(dados);
|
|
400
399
|
var exportar = delegua.interpretador.global.valores.exports;
|
|
401
400
|
var eDicionario = function (objeto) { return objeto.constructor === Object; };
|
|
402
401
|
if (eDicionario(exportar)) {
|
|
@@ -409,12 +408,12 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
409
408
|
}
|
|
410
409
|
return exportar;
|
|
411
410
|
};
|
|
412
|
-
InterpretadorEguaClassico.prototype.
|
|
411
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoEscreva = function (stmt) {
|
|
413
412
|
var valor = this.avaliar(stmt.expressao);
|
|
414
|
-
console.log(this.
|
|
413
|
+
console.log(this.paraTexto(valor));
|
|
415
414
|
return null;
|
|
416
415
|
};
|
|
417
|
-
InterpretadorEguaClassico.prototype.
|
|
416
|
+
InterpretadorEguaClassico.prototype.executarBloco = function (declaracoes, ambiente) {
|
|
418
417
|
var anterior = this.ambiente;
|
|
419
418
|
try {
|
|
420
419
|
this.ambiente = ambiente;
|
|
@@ -432,11 +431,11 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
432
431
|
this.ambiente = anterior;
|
|
433
432
|
}
|
|
434
433
|
};
|
|
435
|
-
InterpretadorEguaClassico.prototype.
|
|
436
|
-
this.
|
|
434
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoBloco = function (stmt) {
|
|
435
|
+
this.executarBloco(stmt.declaracoes, new ambiente_1.Ambiente(this.ambiente));
|
|
437
436
|
return null;
|
|
438
437
|
};
|
|
439
|
-
InterpretadorEguaClassico.prototype.
|
|
438
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoVar = function (stmt) {
|
|
440
439
|
var valor = null;
|
|
441
440
|
if (stmt.inicializador !== null) {
|
|
442
441
|
valor = this.avaliar(stmt.inicializador);
|
|
@@ -444,22 +443,22 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
444
443
|
this.ambiente.definirVariavel(stmt.nome.lexema, valor);
|
|
445
444
|
return null;
|
|
446
445
|
};
|
|
447
|
-
InterpretadorEguaClassico.prototype.
|
|
446
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoContinua = function (stmt) {
|
|
448
447
|
throw new excecoes_1.ContinueException();
|
|
449
448
|
};
|
|
450
|
-
InterpretadorEguaClassico.prototype.
|
|
449
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoPausa = function (stmt) {
|
|
451
450
|
throw new excecoes_1.BreakException();
|
|
452
451
|
};
|
|
453
|
-
InterpretadorEguaClassico.prototype.
|
|
452
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoRetornar = function (stmt) {
|
|
454
453
|
var valor = null;
|
|
455
454
|
if (stmt.valor != null)
|
|
456
455
|
valor = this.avaliar(stmt.valor);
|
|
457
456
|
throw new excecoes_1.ReturnException(valor);
|
|
458
457
|
};
|
|
459
|
-
InterpretadorEguaClassico.prototype.
|
|
458
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDeleguaFuncao = function (expr) {
|
|
460
459
|
return new funcao_1.DeleguaFuncao(null, expr, this.ambiente, false);
|
|
461
460
|
};
|
|
462
|
-
InterpretadorEguaClassico.prototype.
|
|
461
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoAtribuicaoSobrescrita = function (expr) {
|
|
463
462
|
var objeto = this.avaliar(expr.objeto);
|
|
464
463
|
var indice = this.avaliar(expr.indice);
|
|
465
464
|
var valor = this.avaliar(expr.valor);
|
|
@@ -485,7 +484,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
485
484
|
throw new excecoes_1.ErroEmTempoDeExecucao(expr.objeto.nome, "Somente listas, dicionários, classes e objetos podem ser mudados por sobrescrita.");
|
|
486
485
|
}
|
|
487
486
|
};
|
|
488
|
-
InterpretadorEguaClassico.prototype.
|
|
487
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoVetorIndice = function (expressao) {
|
|
489
488
|
var objeto = this.avaliar(expressao.callee);
|
|
490
489
|
var indice = this.avaliar(expressao.indice);
|
|
491
490
|
if (Array.isArray(objeto)) {
|
|
@@ -527,7 +526,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
527
526
|
throw new excecoes_1.ErroEmTempoDeExecucao(expressao.callee.nome, "Somente listas, dicionários, classes e objetos podem ser mudados por sobrescrita.");
|
|
528
527
|
}
|
|
529
528
|
};
|
|
530
|
-
InterpretadorEguaClassico.prototype.
|
|
529
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDefinir = function (expr) {
|
|
531
530
|
var objeto = this.avaliar(expr.objeto);
|
|
532
531
|
if (!(objeto instanceof instancia_1.DeleguaInstancia) &&
|
|
533
532
|
objeto.constructor !== Object) {
|
|
@@ -542,11 +541,11 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
542
541
|
objeto[expr.nome.lexema] = valor;
|
|
543
542
|
}
|
|
544
543
|
};
|
|
545
|
-
InterpretadorEguaClassico.prototype.
|
|
544
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoFuncao = function (stmt) {
|
|
546
545
|
var funcao = new funcao_1.DeleguaFuncao(stmt.nome.lexema, stmt.funcao, this.ambiente, false);
|
|
547
546
|
this.ambiente.definirVariavel(stmt.nome.lexema, funcao);
|
|
548
547
|
};
|
|
549
|
-
InterpretadorEguaClassico.prototype.
|
|
548
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoClasse = function (stmt) {
|
|
550
549
|
var superClasse = null;
|
|
551
550
|
if (stmt.superClasse !== null) {
|
|
552
551
|
superClasse = this.avaliar(stmt.superClasse);
|
|
@@ -574,7 +573,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
574
573
|
this.ambiente.atribuirVariavel(stmt.nome, criado);
|
|
575
574
|
return null;
|
|
576
575
|
};
|
|
577
|
-
InterpretadorEguaClassico.prototype.
|
|
576
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoObter = function (expr) {
|
|
578
577
|
var objeto = this.avaliar(expr.objeto);
|
|
579
578
|
if (objeto instanceof instancia_1.DeleguaInstancia) {
|
|
580
579
|
return objeto.get(expr.nome) || null;
|
|
@@ -587,24 +586,24 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
587
586
|
}
|
|
588
587
|
throw new excecoes_1.ErroEmTempoDeExecucao(expr.nome, "Você só pode acessar métodos do objeto e dicionários.");
|
|
589
588
|
};
|
|
590
|
-
InterpretadorEguaClassico.prototype.
|
|
589
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoIsto = function (expr) {
|
|
591
590
|
return this.procurarVariavel(expr.palavraChave, expr);
|
|
592
591
|
};
|
|
593
|
-
InterpretadorEguaClassico.prototype.
|
|
592
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoDicionario = function (expr) {
|
|
594
593
|
var dicionario = {};
|
|
595
594
|
for (var i = 0; i < expr.chaves.length; i++) {
|
|
596
595
|
dicionario[this.avaliar(expr.chaves[i])] = this.avaliar(expr.valores[i]);
|
|
597
596
|
}
|
|
598
597
|
return dicionario;
|
|
599
598
|
};
|
|
600
|
-
InterpretadorEguaClassico.prototype.
|
|
599
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoVetor = function (expr) {
|
|
601
600
|
var valores = [];
|
|
602
601
|
for (var i = 0; i < expr.valores.length; i++) {
|
|
603
602
|
valores.push(this.avaliar(expr.valores[i]));
|
|
604
603
|
}
|
|
605
604
|
return valores;
|
|
606
605
|
};
|
|
607
|
-
InterpretadorEguaClassico.prototype.
|
|
606
|
+
InterpretadorEguaClassico.prototype.visitarExpressaoSuper = function (expr) {
|
|
608
607
|
var distancia = this.locais.get(expr);
|
|
609
608
|
var superClasse = this.ambiente.obterVariavelEm(distancia, "super");
|
|
610
609
|
var objeto = this.ambiente.obterVariavelEm(distancia - 1, "isto");
|
|
@@ -614,7 +613,7 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
614
613
|
}
|
|
615
614
|
return metodo.bind(objeto);
|
|
616
615
|
};
|
|
617
|
-
InterpretadorEguaClassico.prototype.
|
|
616
|
+
InterpretadorEguaClassico.prototype.paraTexto = function (objeto) {
|
|
618
617
|
if (objeto === null)
|
|
619
618
|
return "nulo";
|
|
620
619
|
if (typeof objeto === "boolean") {
|
|
@@ -633,17 +632,14 @@ var InterpretadorEguaClassico = /** @class */ (function () {
|
|
|
633
632
|
return JSON.stringify(objeto);
|
|
634
633
|
return objeto.toString();
|
|
635
634
|
};
|
|
636
|
-
InterpretadorEguaClassico.prototype.executar = function (stmt,
|
|
637
|
-
if (
|
|
638
|
-
|
|
639
|
-
if (imprimirResultado) {
|
|
640
|
-
console.log(this.stringify(resultado));
|
|
641
|
-
}
|
|
635
|
+
InterpretadorEguaClassico.prototype.executar = function (stmt, mostrarResultado) {
|
|
636
|
+
if (mostrarResultado === void 0) { mostrarResultado = false; }
|
|
637
|
+
stmt.aceitar(this);
|
|
642
638
|
};
|
|
643
639
|
InterpretadorEguaClassico.prototype.interpretar = function (declaracoes) {
|
|
644
640
|
try {
|
|
645
641
|
for (var i = 0; i < declaracoes.length; i++) {
|
|
646
|
-
this.executar(declaracoes[i]);
|
|
642
|
+
this.executar(declaracoes[i], false);
|
|
647
643
|
}
|
|
648
644
|
}
|
|
649
645
|
catch (erro) {
|