-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAST2.rb
63 lines (59 loc) · 3.86 KB
/
AST2.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
#AST
#Representacion del AST para crear todos las clases necesarias
require_relative 'Meta'
$as_tree = [
['AST', [], [
['Programa', %w[alcance], []] ,
['Alcance', %w[declaraciones secuenciacion], []],
['Declaracion', %w[lista tipo], []],
['Declaraciones', %w[lista_declaraciones], []],
['Instrucciones', %w[instrucciones], []],
['Instruccion', %w[], [
['Asignacion', %w[var value], []],
['Condicional', %w[], [
['CondicionalIf', %w[condicion exito], []],
['CondicionalElse', %w[condicion exito fracaso], []]
]],
['IteracionI', %w[condicion instruccion], []],
['Ejecucion', %w[cinta expresion], []],
['IteracionD', %w[condicionA condicionB instruccion], [
['IteracionDId', %w[identificador], []],
['IteracionDExpA', %w[], []]
]],
['ES', %w[operancion expresion], []],
['SecInterna', %w[alcance], []]
]],
['Expresion', %w[], [
['Entero', %w[numero], []],
['Variable', %w[var], []],
['Suma', %w[opIzq opDer], []],
['Resta', %w[opIzq opDer], []],
['Multiplicacion', %w[opIzq opDer], []],
['Division', %w[opIzq opDer], []],
['Modulo', %w[opIzq opDer], []],
['Menos_Unario', %w[op], []],
['True', %w[], []],
['False', %w[], []],
['Negacion', %w[op], []],
['Conjuncion', %w[opIzq opDer], []],
['Disyuncion', %w[opIzq opDer], []],
['Igual', %w[opIzq opDer], []],
['Inequivalencia', %w[opIzq opDer], []],
['Menor', %w[opIzq opDer], []],
['Mayor', %w[opIzq opDer], []],
['MenorOIgual', %w[opIzq opDer], []],
['MayorOIgual', %w[opIzq opDer], []],
['Concatenacion', %w[tape1 tape2], []],
['Inspeccion', %w[tape], []],
['ConstructorTape', %w[length], []]
]]
]]
]
#Se Recorre el arbol, creando las clases
def create_tree(father,tree)
tree.each do |name|
n = Meta::create_class(father, name[0], name[1])
create_tree(n, name[2])
end
end
create_tree(Object,$as_tree)