-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContextErrors.rb
92 lines (78 loc) · 2.32 KB
/
ContextErrors.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# -*- coding: utf-8 -*-
class ContextError < RuntimeError
end
class ErrorDeTipo < ContextError
def initialize(linea, columna, operacion, tipo_izq, tipo_der)
@linea = linea
@columna = columna
@operacion = operacion
@tipo_izq = tipo_izq
@tipo_der = tipo_der
end
def to_s
"Error cerca de la línea #{@linea} y columna #{@columna}: se intenta hacer la operacion #{@operacion} entre operandos de tipos \"#{@tipo_izq}\" y \"#{@tipo_der}\""
end
end
class ErrorDeTipoUnario < ContextError
def initialize(linea, columna, operacion, tipo)
@linea = linea
@columna = columna
@operacion = operacion
@tipo = tipo
end
def to_s
"Error cerca de la línea #{@linea} y columna #{@columna}: se intenta hacer la operacion #{@operacion} a un operando de tipo \"#{@tipo}\""
end
end
class NoDeclarada < ContextError
def initialize(linea, columna, nombre)
@linea = linea
@columna = columna
@nombre = nombre
end
def to_s
"Error cerca de la línea #{@linea} y columna #{@columna}: la variable \"#{@nombre}\" no se encuentra declarada"
end
end
class ErrorDeTipoAsignacion < ContextError
def initialize(linea, columna, tipo_asig, nombre, tipo_var)
@linea = linea
@columna = columna
@tipo_asig = tipo_asig
@nombre = nombre
@tipo_var = tipo_var
end
def to_s
"Error cerca de la línea #{@linea} y columna #{@columna}: se intenta asignar algo del tipo \"#{@tipo_asig}\" a la variable \"#{@nombre}\" de tipo \"#{@tipo_var}\""
end
end
class ErrorCondicionCondicional < ContextError
def initialize(linea, columna, tipo)
@linea = linea
@columna = columna
@tipo = tipo
end
def to_s
"Error cerca de la línea #{@linea} y columna #{@columna}: la condición es de tipo \"#{@tipo}\""
end
end
class ErrorCondicionIteracion < ContextError
def initialize(linea, columna, tipo)
@linea = linea
@columna = columna
@tipo = tipo
end
def to_s
"Error cerca de la línea #{@linea} y columna #{@columna}: la condición de la iteración es de tipo \"#{@tipo}\""
end
end
class ErrorLimiteIteracion < ContextError
def initialize(linea, columna, tipo)
@linea = linea
@columna = columna
@tipo = tipo
end
def to_s
"Error cerca de la línea #{@linea} y columna #{@columna}: el limite la iteración es de tipo \"#{@tipo}\""
end
end