Skip to content

Commit 0dec89f

Browse files
authored
feat: generate TASM (#37)
**Description** Generates TASM code from the AST
1 parent 03a79e2 commit 0dec89f

File tree

13 files changed

+1081
-131
lines changed

13 files changed

+1081
-131
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.parser
44
*.symbol_table
55
*.dot
6+
*.asm

examples/init.lm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ main(){
22
init {
33
a1 : float
44
}
5+
a1:=1.0
56
}

inputs/test.txt

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
init {
2-
a1, b2 : int
3-
c33, d4, e5 : float
4-
f6f, g : string
2+
xFib, yFib, tempFib, countFib: int
3+
num : float
4+
cuentaRegresiva: int
5+
fecha: int
6+
nombre : string
57

68
#+ Ejemplo de una variable mal declarada +#
79
#+ fecha : date +#
@@ -11,39 +13,54 @@ init {
1113
#+ a1: int +#
1214
}
1315

14-
a1 := -125
15-
b2 := -125
16-
b2 := a1
16+
write("Hola! Antes de empezar cual es tu nombre?")
17+
read(nombre)
1718

18-
c33 := 5.34
19-
d4 := c33-2.1
20-
e5 := -5.1 #+ numero "negativo" +#
19+
write("Hola!")
20+
write(nombre)
21+
countFib := 0
22+
xFib := 0
23+
yFib := 1
2124

22-
f6f := "hola \n como estas"
23-
g := "que onda"
25+
write("Estos son los primeros 10 numeros de la secuencia fibonacci")
2426

25-
#+ comentario +#
26-
27-
if(a1 > b2) {
28-
a1 := 10
27+
while (countFib < 10) {
28+
write(xFib)
29+
tempFib := yFib
30+
yFib := xFib + yFib
31+
xFib :=tempFib
32+
countFib := countFib + 1
2933
}
30-
else {
31-
b2 := 20
34+
35+
write("adivina el numero: ")
36+
read(num)
37+
if(num == 4.0) {
38+
write("Adivinaste!")
39+
} else {
40+
write("Numero incorrecto ")
3241
}
3342

34-
while(c33 == 5.34 and d4 <= 2 and not c33 or e5 >= 1) {
35-
a1 := a1+1
36-
while(d4 >= 1) {
37-
if(not isZero(a1)) {
38-
a1 := -125
39-
}
43+
cuentaRegresiva := 10
44+
45+
while (not isZero(cuentaRegresiva)) {
46+
write(cuentaRegresiva)
47+
48+
if (cuentaRegresiva == 5) {
49+
write("Vamos por la mitad, la fecha de hoy es 11-11-2025 o:")
50+
fecha := convDate(11-11-2025)
51+
write(fecha)
4052
}
53+
54+
cuentaRegresiva := cuentaRegresiva - 1
55+
4156
}
4257

43-
write("hola")
44-
write(g)
4558

46-
read(f6f)
59+
write("Todo salio bien!")
60+
write("Saludos:")
61+
62+
write(nombre)
63+
4764

4865
#+ Ejemplo de error por asignacion incorrecta +#
4966
#+ x = 10 +#
@@ -62,5 +79,3 @@ read(f6f)
6279

6380
#+ Ejemplo de error por asignacion de con tipos incorrectos +#
6481
#+ a1 := 33 + 1.33 +#
65-
66-
a1 := convDate(01-02-1900)

src/compiler/asm/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mod tasm;
2+
pub use tasm::TasmGenerator;

0 commit comments

Comments
 (0)