hispano-lang 1.0.7 → 1.0.8

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/dist/evaluator.js CHANGED
@@ -22,7 +22,7 @@ class Evaluator {
22
22
  this.execute(statement);
23
23
  }
24
24
  } catch (error) {
25
- throw new Error(`Execution error: ${error.message}`);
25
+ throw new Error(`Error de ejecución: ${error.message}`);
26
26
  }
27
27
 
28
28
  return this.output;
@@ -358,7 +358,7 @@ class Evaluator {
358
358
  );
359
359
 
360
360
  default:
361
- throw new Error(`Unrecognized expression type: ${expression.type}`);
361
+ throw new Error(`Tipo de expresión no reconocido: ${expression.type}`);
362
362
  }
363
363
  }
364
364
 
@@ -378,7 +378,7 @@ class Evaluator {
378
378
  return !this.isTruthy(right);
379
379
 
380
380
  default:
381
- throw new Error(`Unrecognized unary operator: ${operator}`);
381
+ throw new Error(`Operador unario no reconocido: ${operator}`);
382
382
  }
383
383
  }
384
384
 
@@ -407,7 +407,7 @@ class Evaluator {
407
407
  case 'SLASH':
408
408
  this.checkNumberOperands(operator, left, right);
409
409
  if (right === 0) {
410
- throw new Error('Division by zero');
410
+ throw new Error('División por cero');
411
411
  }
412
412
  return left / right;
413
413
 
@@ -418,7 +418,7 @@ class Evaluator {
418
418
  case 'PERCENT':
419
419
  this.checkNumberOperands(operator, left, right);
420
420
  if (right === 0) {
421
- throw new Error('Modulo by zero');
421
+ throw new Error('Módulo por cero');
422
422
  }
423
423
  return left % right;
424
424
 
@@ -457,7 +457,7 @@ class Evaluator {
457
457
  return !this.isEqual(left, right);
458
458
 
459
459
  default:
460
- throw new Error(`Unrecognized binary operator: ${operator}`);
460
+ throw new Error(`Operador binario no reconocido: ${operator}`);
461
461
  }
462
462
  }
463
463
 
@@ -490,7 +490,7 @@ class Evaluator {
490
490
  */
491
491
  checkNumberOperand(operator, operand) {
492
492
  if (typeof operand === 'number') return;
493
- throw new Error(`Operator ${operator} requires a number`);
493
+ throw new Error(`El operador ${operator} requiere un número`);
494
494
  }
495
495
 
496
496
  /**
@@ -501,7 +501,7 @@ class Evaluator {
501
501
  */
502
502
  checkNumberOperands(operator, left, right) {
503
503
  if (typeof left === 'number' && typeof right === 'number') return;
504
- throw new Error(`Operator ${operator} requires two numbers`);
504
+ throw new Error(`El operador ${operator} requiere dos números`);
505
505
  }
506
506
 
507
507
  /**
@@ -530,12 +530,12 @@ class Evaluator {
530
530
  }
531
531
 
532
532
  if (callee.type !== 'Function') {
533
- throw new Error('Can only call functions');
533
+ throw new Error('Solo se pueden llamar funciones');
534
534
  }
535
535
 
536
536
  if (args.length !== callee.parameters.length) {
537
537
  throw new Error(
538
- `Expected ${callee.parameters.length} arguments but got ${args.length}`
538
+ `Se esperaban ${callee.parameters.length} argumentos pero se recibieron ${args.length}`
539
539
  );
540
540
  }
541
541
 
@@ -584,13 +584,13 @@ class Evaluator {
584
584
  expression.method === 'recorrer'
585
585
  ) {
586
586
  throw new Error(
587
- `Method ${expression.method}() can only be called on arrays`
587
+ `El método ${expression.method}() solo se puede llamar en arreglos`
588
588
  );
589
589
  }
590
590
  return this.evaluateStringMethod(object, expression.method);
591
591
  } else {
592
592
  throw new Error(
593
- `Can only call methods on arrays or strings, got ${typeof object}`
593
+ `Solo se pueden llamar métodos en arreglos o cadenas, se recibió ${typeof object}`
594
594
  );
595
595
  }
596
596
  }
@@ -609,13 +609,13 @@ class Evaluator {
609
609
 
610
610
  case 'primero':
611
611
  if (array.length === 0) {
612
- throw new Error('Cannot get first element of empty array');
612
+ throw new Error('No se puede obtener el primer elemento de un arreglo vacío');
613
613
  }
614
614
  return array[0];
615
615
 
616
616
  case 'ultimo':
617
617
  if (array.length === 0) {
618
- throw new Error('Cannot get last element of empty array');
618
+ throw new Error('No se puede obtener el último elemento de un arreglo vacío');
619
619
  }
620
620
  return array[array.length - 1];
621
621
 
@@ -630,14 +630,14 @@ class Evaluator {
630
630
  case 'remover':
631
631
  // Remove and return the last element
632
632
  if (array.length === 0) {
633
- throw new Error('Cannot remove element from empty array');
633
+ throw new Error('No se puede eliminar un elemento de un arreglo vacío');
634
634
  }
635
635
  return array.pop(); // Return the removed element
636
636
 
637
637
  case 'contiene':
638
638
  // Check if array contains the specified element
639
639
  if (args.length !== 1) {
640
- throw new Error('Method contiene() requires exactly one argument');
640
+ throw new Error('El método contiene() requiere exactamente un argumento');
641
641
  }
642
642
  const searchElement = this.evaluateExpression(args[0]);
643
643
  return array.includes(searchElement);
@@ -645,11 +645,11 @@ class Evaluator {
645
645
  case 'recorrer':
646
646
  // Iterate through array and call function for each element
647
647
  if (args.length !== 1) {
648
- throw new Error('Method recorrer() requires exactly one argument');
648
+ throw new Error('El método recorrer() requiere exactamente un argumento');
649
649
  }
650
650
  const callback = this.evaluateExpression(args[0]);
651
651
  if (callback.type !== 'Function') {
652
- throw new Error('Method recorrer() requires a function as argument');
652
+ throw new Error('El método recorrer() requiere una función como argumento');
653
653
  }
654
654
 
655
655
  // Call the function for each element
@@ -672,7 +672,7 @@ class Evaluator {
672
672
  callbackEnv.define(callback.parameters[1], i);
673
673
  } else {
674
674
  throw new Error(
675
- 'Function in recorrer() can have at most 2 parameters'
675
+ 'La función en recorrer() puede tener máximo 2 parámetros'
676
676
  );
677
677
  }
678
678
 
@@ -688,7 +688,7 @@ class Evaluator {
688
688
  return null; // forEach doesn't return anything
689
689
 
690
690
  default:
691
- throw new Error(`Unknown array method: ${method}`);
691
+ throw new Error(`Método de arreglo desconocido: ${method}`);
692
692
  }
693
693
  }
694
694
 
@@ -710,7 +710,7 @@ class Evaluator {
710
710
  return string.toLowerCase();
711
711
 
712
712
  default:
713
- throw new Error(`Unknown string method: ${method}`);
713
+ throw new Error(`Método de cadena desconocido: ${method}`);
714
714
  }
715
715
  }
716
716
 
@@ -750,97 +750,97 @@ class Evaluator {
750
750
  switch (name) {
751
751
  case 'raiz':
752
752
  if (args.length !== 1) {
753
- throw new Error('raiz() requires exactly 1 argument');
753
+ throw new Error('raiz() requiere exactamente 1 argumento');
754
754
  }
755
755
  if (typeof args[0] !== 'number') {
756
- throw new Error('raiz() requires a number argument');
756
+ throw new Error('raiz() requiere un argumento numérico');
757
757
  }
758
758
  if (args[0] < 0) {
759
- throw new Error('Cannot take square root of negative number');
759
+ throw new Error('No se puede calcular la raíz cuadrada de un número negativo');
760
760
  }
761
761
  return Math.sqrt(args[0]);
762
762
 
763
763
  case 'potencia':
764
764
  if (args.length !== 2) {
765
- throw new Error('potencia() requires exactly 2 arguments');
765
+ throw new Error('potencia() requiere exactamente 2 argumentos');
766
766
  }
767
767
  if (typeof args[0] !== 'number' || typeof args[1] !== 'number') {
768
- throw new Error('potencia() requires number arguments');
768
+ throw new Error('potencia() requiere argumentos numéricos');
769
769
  }
770
770
  return Math.pow(args[0], args[1]);
771
771
 
772
772
  case 'seno':
773
773
  if (args.length !== 1) {
774
- throw new Error('seno() requires exactly 1 argument');
774
+ throw new Error('seno() requiere exactamente 1 argumento');
775
775
  }
776
776
  if (typeof args[0] !== 'number') {
777
- throw new Error('seno() requires a number argument');
777
+ throw new Error('seno() requiere un argumento numérico');
778
778
  }
779
779
  return Math.sin(args[0]);
780
780
 
781
781
  case 'coseno':
782
782
  if (args.length !== 1) {
783
- throw new Error('coseno() requires exactly 1 argument');
783
+ throw new Error('coseno() requiere exactamente 1 argumento');
784
784
  }
785
785
  if (typeof args[0] !== 'number') {
786
- throw new Error('coseno() requires a number argument');
786
+ throw new Error('coseno() requiere un argumento numérico');
787
787
  }
788
788
  return Math.cos(args[0]);
789
789
 
790
790
  case 'tangente':
791
791
  if (args.length !== 1) {
792
- throw new Error('tangente() requires exactly 1 argument');
792
+ throw new Error('tangente() requiere exactamente 1 argumento');
793
793
  }
794
794
  if (typeof args[0] !== 'number') {
795
- throw new Error('tangente() requires a number argument');
795
+ throw new Error('tangente() requiere un argumento numérico');
796
796
  }
797
797
  return Math.tan(args[0]);
798
798
 
799
799
  case 'logaritmo':
800
800
  if (args.length !== 1) {
801
- throw new Error('logaritmo() requires exactly 1 argument');
801
+ throw new Error('logaritmo() requiere exactamente 1 argumento');
802
802
  }
803
803
  if (typeof args[0] !== 'number') {
804
- throw new Error('logaritmo() requires a number argument');
804
+ throw new Error('logaritmo() requiere un argumento numérico');
805
805
  }
806
806
  if (args[0] <= 0) {
807
- throw new Error('Cannot take logarithm of non-positive number');
807
+ throw new Error('No se puede calcular el logaritmo de un número no positivo');
808
808
  }
809
809
  return Math.log(args[0]);
810
810
 
811
811
  case 'valorAbsoluto':
812
812
  if (args.length !== 1) {
813
- throw new Error('valorAbsoluto() requires exactly 1 argument');
813
+ throw new Error('valorAbsoluto() requiere exactamente 1 argumento');
814
814
  }
815
815
  if (typeof args[0] !== 'number') {
816
- throw new Error('valorAbsoluto() requires a number argument');
816
+ throw new Error('valorAbsoluto() requiere un argumento numérico');
817
817
  }
818
818
  return Math.abs(args[0]);
819
819
 
820
820
  case 'redondear':
821
821
  if (args.length !== 1) {
822
- throw new Error('redondear() requires exactly 1 argument');
822
+ throw new Error('redondear() requiere exactamente 1 argumento');
823
823
  }
824
824
  if (typeof args[0] !== 'number') {
825
- throw new Error('redondear() requires a number argument');
825
+ throw new Error('redondear() requiere un argumento numérico');
826
826
  }
827
827
  return Math.round(args[0]);
828
828
 
829
829
  case 'techo':
830
830
  if (args.length !== 1) {
831
- throw new Error('techo() requires exactly 1 argument');
831
+ throw new Error('techo() requiere exactamente 1 argumento');
832
832
  }
833
833
  if (typeof args[0] !== 'number') {
834
- throw new Error('techo() requires a number argument');
834
+ throw new Error('techo() requiere un argumento numérico');
835
835
  }
836
836
  return Math.ceil(args[0]);
837
837
 
838
838
  case 'piso':
839
839
  if (args.length !== 1) {
840
- throw new Error('piso() requires exactly 1 argument');
840
+ throw new Error('piso() requiere exactamente 1 argumento');
841
841
  }
842
842
  if (typeof args[0] !== 'number') {
843
- throw new Error('piso() requires a number argument');
843
+ throw new Error('piso() requiere un argumento numérico');
844
844
  }
845
845
  return Math.floor(args[0]);
846
846
 
@@ -849,64 +849,64 @@ class Evaluator {
849
849
  return Math.random();
850
850
  } else if (args.length === 1) {
851
851
  if (typeof args[0] !== 'number') {
852
- throw new Error('aleatorio() requires a number argument');
852
+ throw new Error('aleatorio() requiere un argumento numérico');
853
853
  }
854
854
  return Math.random() * args[0];
855
855
  } else if (args.length === 2) {
856
856
  if (typeof args[0] !== 'number' || typeof args[1] !== 'number') {
857
- throw new Error('aleatorio() requires number arguments');
857
+ throw new Error('aleatorio() requiere argumentos numéricos');
858
858
  }
859
859
  return Math.random() * (args[1] - args[0]) + args[0];
860
860
  } else {
861
- throw new Error('aleatorio() accepts 0, 1, or 2 arguments');
861
+ throw new Error('aleatorio() acepta 0, 1, o 2 argumentos');
862
862
  }
863
863
 
864
864
  case 'maximo':
865
865
  if (args.length < 1) {
866
- throw new Error('maximo() requires at least 1 argument');
866
+ throw new Error('maximo() requiere al menos 1 argumento');
867
867
  }
868
868
  for (const arg of args) {
869
869
  if (typeof arg !== 'number') {
870
- throw new Error('maximo() requires number arguments');
870
+ throw new Error('maximo() requiere argumentos numéricos');
871
871
  }
872
872
  }
873
873
  return Math.max(...args);
874
874
 
875
875
  case 'minimo':
876
876
  if (args.length < 1) {
877
- throw new Error('minimo() requires at least 1 argument');
877
+ throw new Error('minimo() requiere al menos 1 argumento');
878
878
  }
879
879
  for (const arg of args) {
880
880
  if (typeof arg !== 'number') {
881
- throw new Error('minimo() requires number arguments');
881
+ throw new Error('minimo() requiere argumentos numéricos');
882
882
  }
883
883
  }
884
884
  return Math.min(...args);
885
885
 
886
886
  case 'suma':
887
887
  if (args.length < 1) {
888
- throw new Error('suma() requires at least 1 argument');
888
+ throw new Error('suma() requiere al menos 1 argumento');
889
889
  }
890
890
  for (const arg of args) {
891
891
  if (typeof arg !== 'number') {
892
- throw new Error('suma() requires number arguments');
892
+ throw new Error('suma() requiere argumentos numéricos');
893
893
  }
894
894
  }
895
895
  return args.reduce((sum, arg) => sum + arg, 0);
896
896
 
897
897
  case 'promedio':
898
898
  if (args.length < 1) {
899
- throw new Error('promedio() requires at least 1 argument');
899
+ throw new Error('promedio() requiere al menos 1 argumento');
900
900
  }
901
901
  for (const arg of args) {
902
902
  if (typeof arg !== 'number') {
903
- throw new Error('promedio() requires number arguments');
903
+ throw new Error('promedio() requiere argumentos numéricos');
904
904
  }
905
905
  }
906
906
  return args.reduce((sum, arg) => sum + arg, 0) / args.length;
907
907
 
908
908
  default:
909
- throw new Error(`Unknown mathematical function: ${name}`);
909
+ throw new Error(`Función matemática desconocida: ${name}`);
910
910
  }
911
911
  }
912
912
 
@@ -933,15 +933,15 @@ class Evaluator {
933
933
  const index = this.evaluateExpression(expression.index);
934
934
 
935
935
  if (!Array.isArray(array)) {
936
- throw new Error('Can only access elements of arrays');
936
+ throw new Error('Solo se pueden acceder elementos de arreglos');
937
937
  }
938
938
 
939
939
  if (typeof index !== 'number') {
940
- throw new Error('Array index must be a number');
940
+ throw new Error('El índice del arreglo debe ser un número');
941
941
  }
942
942
 
943
943
  if (index < 0 || index >= array.length) {
944
- throw new Error('Array index out of bounds');
944
+ throw new Error('Índice del arreglo fuera de rango');
945
945
  }
946
946
 
947
947
  return array[index];
@@ -958,15 +958,15 @@ class Evaluator {
958
958
  const value = this.evaluateExpression(expression.value);
959
959
 
960
960
  if (!Array.isArray(array)) {
961
- throw new Error('Can only assign to elements of arrays');
961
+ throw new Error('Solo se pueden asignar elementos de arreglos');
962
962
  }
963
963
 
964
964
  if (typeof index !== 'number') {
965
- throw new Error('Array index must be a number');
965
+ throw new Error('El índice del arreglo debe ser un número');
966
966
  }
967
967
 
968
968
  if (index < 0 || index >= array.length) {
969
- throw new Error('Array index out of bounds');
969
+ throw new Error('Índice del arreglo fuera de rango');
970
970
  }
971
971
 
972
972
  array[index] = value;
@@ -998,7 +998,7 @@ class Evaluator {
998
998
  const object = this.evaluateExpression(expression.object);
999
999
 
1000
1000
  if (typeof object !== 'object' || object === null) {
1001
- throw new Error('Can only access properties of objects');
1001
+ throw new Error('Solo se pueden acceder propiedades de objetos');
1002
1002
  }
1003
1003
 
1004
1004
  return object[expression.name];
@@ -1014,7 +1014,7 @@ class Evaluator {
1014
1014
  const value = this.evaluateExpression(expression.value);
1015
1015
 
1016
1016
  if (typeof object !== 'object' || object === null) {
1017
- throw new Error('Can only assign to properties of objects');
1017
+ throw new Error('Solo se pueden asignar propiedades de objetos');
1018
1018
  }
1019
1019
 
1020
1020
  object[expression.name] = value;
@@ -1045,7 +1045,7 @@ class Evaluator {
1045
1045
  return this.evaluateExpression(expression.right);
1046
1046
  }
1047
1047
 
1048
- throw new Error(`Unknown logical operator: ${expression.operator}`);
1048
+ throw new Error(`Operador lógico desconocido: ${expression.operator}`);
1049
1049
  }
1050
1050
 
1051
1051
  /**
@@ -1077,13 +1077,13 @@ class Evaluator {
1077
1077
  const rightValue = this.evaluateExpression(expression.value);
1078
1078
 
1079
1079
  if (!Array.isArray(array)) {
1080
- throw new Error('Can only assign to elements of arrays');
1080
+ throw new Error('Solo se pueden asignar elementos de arreglos');
1081
1081
  }
1082
1082
  if (typeof index !== 'number') {
1083
- throw new Error('Array index must be a number');
1083
+ throw new Error('El índice del arreglo debe ser un número');
1084
1084
  }
1085
1085
  if (index < 0 || index >= array.length) {
1086
- throw new Error('Array index out of bounds');
1086
+ throw new Error('Índice del arreglo fuera de rango');
1087
1087
  }
1088
1088
 
1089
1089
  const currentValue = array[index];
@@ -1107,7 +1107,7 @@ class Evaluator {
1107
1107
  const rightValue = this.evaluateExpression(expression.value);
1108
1108
 
1109
1109
  if (typeof object !== 'object' || object === null) {
1110
- throw new Error('Can only assign to properties of objects');
1110
+ throw new Error('Solo se pueden asignar propiedades de objetos');
1111
1111
  }
1112
1112
 
1113
1113
  const currentValue = object[expression.name];
@@ -1137,40 +1137,40 @@ class Evaluator {
1137
1137
  if (typeof left === 'string' || typeof right === 'string') {
1138
1138
  return String(left) + String(right);
1139
1139
  }
1140
- throw new Error('Cannot add non-numeric values');
1140
+ throw new Error('No se pueden sumar valores no numéricos');
1141
1141
 
1142
1142
  case 'MINUS_EQUAL':
1143
1143
  if (typeof left !== 'number' || typeof right !== 'number') {
1144
- throw new Error('Can only subtract numbers');
1144
+ throw new Error('Solo se pueden restar números');
1145
1145
  }
1146
1146
  return left - right;
1147
1147
 
1148
1148
  case 'STAR_EQUAL':
1149
1149
  if (typeof left !== 'number' || typeof right !== 'number') {
1150
- throw new Error('Can only multiply numbers');
1150
+ throw new Error('Solo se pueden multiplicar números');
1151
1151
  }
1152
1152
  return left * right;
1153
1153
 
1154
1154
  case 'SLASH_EQUAL':
1155
1155
  if (typeof left !== 'number' || typeof right !== 'number') {
1156
- throw new Error('Can only divide numbers');
1156
+ throw new Error('Solo se pueden dividir números');
1157
1157
  }
1158
1158
  if (right === 0) {
1159
- throw new Error('Division by zero');
1159
+ throw new Error('División por cero');
1160
1160
  }
1161
1161
  return left / right;
1162
1162
 
1163
1163
  case 'PERCENT_EQUAL':
1164
1164
  if (typeof left !== 'number' || typeof right !== 'number') {
1165
- throw new Error('Can only modulo numbers');
1165
+ throw new Error('Solo se puede hacer módulo con números');
1166
1166
  }
1167
1167
  if (right === 0) {
1168
- throw new Error('Modulo by zero');
1168
+ throw new Error('Módulo por cero');
1169
1169
  }
1170
1170
  return left % right;
1171
1171
 
1172
1172
  default:
1173
- throw new Error(`Unknown compound operator: ${operator}`);
1173
+ throw new Error(`Operador compuesto desconocido: ${operator}`);
1174
1174
  }
1175
1175
  }
1176
1176
 
@@ -1184,7 +1184,7 @@ class Evaluator {
1184
1184
 
1185
1185
  if (expression.operator === 'PLUS_PLUS') {
1186
1186
  if (typeof operand !== 'number') {
1187
- throw new Error('Can only increment numbers');
1187
+ throw new Error('Solo se pueden incrementar números');
1188
1188
  }
1189
1189
  const newValue = operand + 1;
1190
1190
 
@@ -1194,24 +1194,24 @@ class Evaluator {
1194
1194
  } else if (expression.operand.type === 'PropertyAccess') {
1195
1195
  const object = this.evaluateExpression(expression.operand.object);
1196
1196
  if (typeof object !== 'object' || object === null) {
1197
- throw new Error('Can only increment properties of objects');
1197
+ throw new Error('Solo se pueden incrementar propiedades de objetos');
1198
1198
  }
1199
1199
  object[expression.operand.name] = newValue;
1200
1200
  } else if (expression.operand.type === 'ArrayAccess') {
1201
1201
  const array = this.evaluateExpression(expression.operand.array);
1202
1202
  const index = this.evaluateExpression(expression.operand.index);
1203
1203
  if (!Array.isArray(array)) {
1204
- throw new Error('Can only increment elements of arrays');
1204
+ throw new Error('Solo se pueden incrementar elementos de arreglos');
1205
1205
  }
1206
1206
  if (typeof index !== 'number') {
1207
- throw new Error('Array index must be a number');
1207
+ throw new Error('El índice del arreglo debe ser un número');
1208
1208
  }
1209
1209
  if (index < 0 || index >= array.length) {
1210
- throw new Error('Array index out of bounds');
1210
+ throw new Error('Índice del arreglo fuera de rango');
1211
1211
  }
1212
1212
  array[index] = newValue;
1213
1213
  } else {
1214
- throw new Error('Invalid increment target');
1214
+ throw new Error('Objetivo de incremento inválido');
1215
1215
  }
1216
1216
 
1217
1217
  return operand; // Return the original value (postfix behavior)
@@ -1219,7 +1219,7 @@ class Evaluator {
1219
1219
 
1220
1220
  if (expression.operator === 'MINUS_MINUS') {
1221
1221
  if (typeof operand !== 'number') {
1222
- throw new Error('Can only decrement numbers');
1222
+ throw new Error('Solo se pueden decrementar números');
1223
1223
  }
1224
1224
  const newValue = operand - 1;
1225
1225
 
@@ -1229,30 +1229,30 @@ class Evaluator {
1229
1229
  } else if (expression.operand.type === 'PropertyAccess') {
1230
1230
  const object = this.evaluateExpression(expression.operand.object);
1231
1231
  if (typeof object !== 'object' || object === null) {
1232
- throw new Error('Can only decrement properties of objects');
1232
+ throw new Error('Solo se pueden decrementar propiedades de objetos');
1233
1233
  }
1234
1234
  object[expression.operand.name] = newValue;
1235
1235
  } else if (expression.operand.type === 'ArrayAccess') {
1236
1236
  const array = this.evaluateExpression(expression.operand.array);
1237
1237
  const index = this.evaluateExpression(expression.operand.index);
1238
1238
  if (!Array.isArray(array)) {
1239
- throw new Error('Can only decrement elements of arrays');
1239
+ throw new Error('Solo se pueden decrementar elementos de arreglos');
1240
1240
  }
1241
1241
  if (typeof index !== 'number') {
1242
- throw new Error('Array index must be a number');
1242
+ throw new Error('El índice del arreglo debe ser un número');
1243
1243
  }
1244
1244
  if (index < 0 || index >= array.length) {
1245
- throw new Error('Array index out of bounds');
1245
+ throw new Error('Índice del arreglo fuera de rango');
1246
1246
  }
1247
1247
  array[index] = newValue;
1248
1248
  } else {
1249
- throw new Error('Invalid decrement target');
1249
+ throw new Error('Objetivo de decremento inválido');
1250
1250
  }
1251
1251
 
1252
1252
  return operand; // Return the original value (postfix behavior)
1253
1253
  }
1254
1254
 
1255
- throw new Error(`Unknown postfix operator: ${expression.operator}`);
1255
+ throw new Error(`Operador postfijo desconocido: ${expression.operator}`);
1256
1256
  }
1257
1257
 
1258
1258
  /**
@@ -1330,7 +1330,7 @@ class Environment {
1330
1330
  return;
1331
1331
  }
1332
1332
 
1333
- throw new Error(`Undefined variable: ${name}`);
1333
+ throw new Error(`Variable no definida: ${name}`);
1334
1334
  }
1335
1335
 
1336
1336
  /**
@@ -1347,7 +1347,7 @@ class Environment {
1347
1347
  return this.enclosing.get(name);
1348
1348
  }
1349
1349
 
1350
- throw new Error(`Undefined variable: ${name}`);
1350
+ throw new Error(`Variable no definida: ${name}`);
1351
1351
  }
1352
1352
  }
1353
1353
 
package/dist/parser.js CHANGED
@@ -96,7 +96,7 @@ class Parser {
96
96
  } else if (this.match('AND')) {
97
97
  name = this.previous();
98
98
  } else {
99
- throw new Error('Expected variable name');
99
+ throw new Error('Se esperaba un nombre de variable');
100
100
  }
101
101
 
102
102
  let initializer = null;
@@ -123,7 +123,7 @@ class Parser {
123
123
  if (!this.check('RIGHT_PAREN')) {
124
124
  do {
125
125
  if (parameters.length >= 255) {
126
- throw new Error('Cannot have more than 255 parameters');
126
+ throw new Error('No se pueden tener más de 255 parámetros');
127
127
  }
128
128
  let param;
129
129
  if (this.match('IDENTIFIER')) {
@@ -131,7 +131,7 @@ class Parser {
131
131
  } else if (this.match('AND')) {
132
132
  param = this.previous();
133
133
  } else {
134
- throw new Error('Expected parameter name');
134
+ throw new Error('Se esperaba un nombre de parámetro');
135
135
  }
136
136
  parameters.push(param.lexeme);
137
137
  } while (this.match('COMMA'));
@@ -406,7 +406,7 @@ class Parser {
406
406
  };
407
407
  }
408
408
 
409
- throw new Error('Invalid assignment target');
409
+ throw new Error('Objetivo de asignación inválido');
410
410
  }
411
411
 
412
412
  // Handle compound assignment operators
@@ -452,7 +452,7 @@ class Parser {
452
452
  };
453
453
  }
454
454
 
455
- throw new Error('Invalid compound assignment target');
455
+ throw new Error('Objetivo de asignación compuesta inválido');
456
456
  }
457
457
 
458
458
  return expr;
@@ -699,7 +699,7 @@ class Parser {
699
699
  return this.anonymousFunction();
700
700
  }
701
701
 
702
- throw new Error('Expected expression');
702
+ throw new Error('Se esperaba una expresión');
703
703
  }
704
704
 
705
705
  /**
@@ -713,7 +713,7 @@ class Parser {
713
713
  if (!this.check('RIGHT_PAREN')) {
714
714
  do {
715
715
  if (parameters.length >= 255) {
716
- throw new Error('Cannot have more than 255 parameters');
716
+ throw new Error('No se pueden tener más de 255 parámetros');
717
717
  }
718
718
  let param;
719
719
  if (this.match('IDENTIFIER')) {
@@ -721,7 +721,7 @@ class Parser {
721
721
  } else if (this.match('AND')) {
722
722
  param = this.previous();
723
723
  } else {
724
- throw new Error('Expected parameter name');
724
+ throw new Error('Se esperaba un nombre de parámetro');
725
725
  }
726
726
  parameters.push(param.lexeme);
727
727
  } while (this.match('COMMA'));
@@ -801,7 +801,7 @@ class Parser {
801
801
  };
802
802
  } else {
803
803
  throw new Error(
804
- `Method ${name.lexeme}() does not accept arguments`
804
+ `El método ${name.lexeme}() no acepta argumentos`
805
805
  );
806
806
  }
807
807
  }
@@ -889,7 +889,7 @@ class Parser {
889
889
  } else if (this.match('STRING')) {
890
890
  name = this.previous().literal;
891
891
  } else {
892
- throw new Error('Expected property name');
892
+ throw new Error('Se esperaba un nombre de propiedad');
893
893
  }
894
894
 
895
895
  this.consume('COLON', 'Expected : after property name');
@@ -978,7 +978,7 @@ class Parser {
978
978
  consume(type, message) {
979
979
  if (this.check(type)) return this.advance();
980
980
 
981
- throw new Error(`${message} at line ${this.peek().line}`);
981
+ throw new Error(`${message} en la línea ${this.peek().line}`);
982
982
  }
983
983
 
984
984
  /**
@@ -1042,7 +1042,7 @@ class Parser {
1042
1042
  errorVariable: errorVariable.lexeme,
1043
1043
  };
1044
1044
  } else {
1045
- throw new Error('Expected capturar after intentar block');
1045
+ throw new Error('Se esperaba capturar después del bloque intentar');
1046
1046
  }
1047
1047
  }
1048
1048
  }
package/dist/tokenizer.js CHANGED
@@ -213,7 +213,7 @@ class Tokenizer {
213
213
  this.identifier();
214
214
  } else {
215
215
  throw new Error(
216
- `Unexpected character: ${char} at line ${this.currentLine}`
216
+ `Carácter inesperado: ${char} en la línea ${this.currentLine}`
217
217
  );
218
218
  }
219
219
  break;
@@ -231,7 +231,7 @@ class Tokenizer {
231
231
  }
232
232
 
233
233
  if (this.isAtEnd()) {
234
- throw new Error('Unterminated string');
234
+ throw new Error('Cadena no terminada');
235
235
  }
236
236
 
237
237
  // Consume the closing quote
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hispano-lang",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Un lenguaje de programación educativo en español para enseñar programación sin barreras de idioma",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",