aboutsummaryrefslogtreecommitdiff
path: root/compilador/errors.py
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-11-16 20:45:03 -0600
committerIván Ávalos <avalos@disroot.org>2022-11-16 20:45:03 -0600
commit4b562e5608bde5b2a25be62cd2013683b1216bb1 (patch)
treece9ee30f936faed3c3b9091581df5a1953e4fa22 /compilador/errors.py
parentd810c8779b6417dcf418d9837bb5b04376eaa7f9 (diff)
downloadjavanol-4b562e5608bde5b2a25be62cd2013683b1216bb1.tar.gz
javanol-4b562e5608bde5b2a25be62cd2013683b1216bb1.tar.bz2
javanol-4b562e5608bde5b2a25be62cd2013683b1216bb1.zip
Se mejora la impresión de errores
Diffstat (limited to 'compilador/errors.py')
-rw-r--r--compilador/errors.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/compilador/errors.py b/compilador/errors.py
new file mode 100644
index 0000000..f5b4203
--- /dev/null
+++ b/compilador/errors.py
@@ -0,0 +1,16 @@
+import sys
+
+class Error:
+ errors = {
+ 'L_CAR_LARGO': 'Más de un caracter en una literal de caracter',
+ 'L_CAR_VACIO': 'Literal de caracter vacía',
+ 'S_ESPERA_EXPR': 'Se esperaba una expresión',
+ 'S_ESPERA_IDENT': 'Se esperaba un identificador',
+ 'S_ESPERA_IDENT_O_LIT': 'Se esperaba un identificador o una literal',
+ 'S_ESPERA_OPER': 'Se esperaba un operador',
+ 'S_ESPERA_PC_O_IGUAL': 'Se esperaba `;` o `=`',
+ 'S_ESPERA_PC': 'Se esperaba `;`',
+ }
+
+ def __init__(self, error, numlinea):
+ print("Error en línea %d: %s" % (numlinea, self.errors[error]), file=sys.stderr)