bahasa-simpl 1.0.20 → 1.0.22

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.
Files changed (2) hide show
  1. package/dist/simpl.js +7 -5
  2. package/package.json +1 -1
package/dist/simpl.js CHANGED
@@ -90,6 +90,8 @@ class Stipe extends Variable {
90
90
  }
91
91
 
92
92
  function kePetik(v, thing) {
93
+ if (!thing || (thing.data === null && !thing.member)) return "nihil";
94
+
93
95
  if (thing.type === logisSymbol) {
94
96
  return thing.data ? "benar" : "salah";
95
97
  } else if (thing.type === barisSymbol) {
@@ -833,8 +835,8 @@ class Interpreter {
833
835
  // a real TODO would've been to implement real iterables
834
836
  let iterable = indexExpr.iterable.accept(this);
835
837
  if (!iterable || iterable.data === null) {
836
- this.error("Objek bernilai nihil, tidak dapat mengindeksnya.");
837
- }
838
+ this.error("Objek tidak dapat diindeks, bernilai nihil atau bukan sebuah baris/petik.");
839
+ }
838
840
 
839
841
  if (iterable.type === petikSymbol) {
840
842
  iterable = new Value(barisSymbol, iterable.data.split("").map(str => new Value(petikSymbol, str)));
@@ -934,7 +936,7 @@ class Interpreter {
934
936
  let type = callable.parameters[i][0];
935
937
 
936
938
  if (type === null) continue;
937
- if (args[i].data !== null) continue;
939
+ if (args[i].data === null) continue;
938
940
  if (args[i].type !== type) {
939
941
  this.line = callLineNum;
940
942
  this.error(`Tipe argumen tidak sama dengan parameter. Menemukan ${args[i].type.description}, harusnya ${type.description}`);
@@ -1054,7 +1056,7 @@ class Interpreter {
1054
1056
  let willBeCalled = this.exprWillBeCalled;
1055
1057
  this.exprWillBeCalled = false;
1056
1058
  let main = memberExpr.main.accept(this);
1057
- if (!main || main.data === null) {
1059
+ if (!main || (main.data === null && !main.member)) {
1058
1060
  this.error("Objek bernilai nihil, tidak dapat mengaksesnya.");
1059
1061
  }
1060
1062
  let name = memberExpr.member.token.lexeme;
@@ -1385,7 +1387,7 @@ class Interpreter {
1385
1387
  }
1386
1388
 
1387
1389
  error(message) {
1388
- throw new SimplErrorEksekusi(`Error Eksekusi => ${message}`, this.line, this.output.join('\n'));
1390
+ throw new SimplErrorEksekusi(`Error Eksekusi => ${message}`, this.line, this.output.join(''));
1389
1391
  }
1390
1392
 
1391
1393
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bahasa-simpl",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "Bahasa pemrograman mini berbasis kata bahasa Indonesia",
5
5
  "exports": {
6
6
  ".": {