Skip to content

Commit

Permalink
Working type enforcement in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
arnav-ag committed Apr 1, 2024
1 parent 00acb10 commit 431cf30
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 230 deletions.
44 changes: 34 additions & 10 deletions booga.bm
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
{"tag":"ENTER_SCOPE","num":1}
{"tag":"ENTER_SCOPE","num":3}
{"tag":"LDCI","val":5}
{"tag":"ASSIGN","pos":[1,0]}
{"tag":"LD","sym":"i","pos":[1,0]}
{"tag":"LDCI","val":10}
{"tag":"LOG","operator":"<"}
{"tag":"JOF","addr":16}
{"tag":"POP"}
{"tag":"LD","sym":"x","pos":[1,0]}
{"tag":"POP"}
{"tag":"LDF","arity":2,"addr":8}
{"tag":"GOTO","addr":12}
{"tag":"LD","sym":"b","pos":[2,1]}
{"tag":"RESET"}
{"tag":"LDU"}
{"tag":"RESET"}
{"tag":"ASSIGN","pos":[1,1]}
{"tag":"POP"}
{"tag":"LD","sym":"y","pos":[1,1]}
{"tag":"LDCI","val":1}
{"tag":"LDCI","val":2}
{"tag":"CALL","arity":2}
{"tag":"POP"}
{"tag":"LDF","arity":2,"addr":21}
{"tag":"GOTO","addr":36}
{"tag":"ENTER_SCOPE","num":1}
{"tag":"LDCI","val":5}
{"tag":"ASSIGN","pos":[3,0]}
{"tag":"POP"}
{"tag":"LD","sym":"print","pos":[0,0]}
{"tag":"LD","sym":"i","pos":[1,0]}
{"tag":"LD","sym":"z","pos":[3,0]}
{"tag":"CALL","arity":1}
{"tag":"POP"}
{"tag":"LD","sym":"i","pos":[1,0]}
{"tag":"LDCI","val":1}
{"tag":"LD","sym":"x","pos":[2,0]}
{"tag":"LD","sym":"y","pos":[2,1]}
{"tag":"BINOP","operator":"+"}
{"tag":"ASSIGN","pos":[1,0]}
{"tag":"GOTO","addr":3}
{"tag":"RESET"}
{"tag":"EXIT_SCOPE"}
{"tag":"LDU"}
{"tag":"RESET"}
{"tag":"LDCI","val":1}
{"tag":"LDCI","val":3}
{"tag":"CALL","arity":2}
{"tag":"ASSIGN","pos":[1,2]}
{"tag":"EXIT_SCOPE"}
{"tag":"DONE"}
17 changes: 14 additions & 3 deletions booga.ooga
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
for i := 5; i < 10; i = i + 1 {
print (i);
}
var x int = 5;
x;

func y(a int, b int) int, int {
return b;
}

y(1,2);

var add = func(x int, y int) (int) {
z := 5;
print(z);
return x + y;
}(1,3);
Loading

0 comments on commit 431cf30

Please sign in to comment.