implement scoping 🎉
This commit is contained in:
99
IBAF-Tests/IBAF-1/scopes.fct
Normal file
99
IBAF-Tests/IBAF-1/scopes.fct
Normal file
@@ -0,0 +1,99 @@
|
||||
initialise-binding scope
|
||||
(collateral
|
||||
(bind
|
||||
("z",
|
||||
allocate-initialised-variable
|
||||
(integers,
|
||||
0)),
|
||||
bind
|
||||
("x",
|
||||
allocate-initialised-variable
|
||||
(integers,
|
||||
0)),
|
||||
map
|
||||
( ),
|
||||
map
|
||||
( ),
|
||||
map
|
||||
( ),
|
||||
map
|
||||
( ),
|
||||
map
|
||||
( ),
|
||||
map
|
||||
( ),
|
||||
map
|
||||
( )),
|
||||
sequential
|
||||
(assign
|
||||
(bound
|
||||
("z"),
|
||||
decimal-natural
|
||||
("5")),
|
||||
assign
|
||||
(bound
|
||||
("x"),
|
||||
int-mul
|
||||
(decimal-natural
|
||||
("5"),
|
||||
decimal-natural
|
||||
("3"))),
|
||||
print
|
||||
(assigned
|
||||
(bound
|
||||
("x"))),
|
||||
assign
|
||||
(bound
|
||||
("x"),
|
||||
decimal-natural
|
||||
("2")),
|
||||
print
|
||||
(int-mul
|
||||
(assigned
|
||||
(bound
|
||||
("x")),
|
||||
decimal-natural
|
||||
("3"))),
|
||||
scope
|
||||
(collateral
|
||||
(bind
|
||||
("y",
|
||||
allocate-initialised-variable
|
||||
(integers,
|
||||
0)),
|
||||
map
|
||||
( ),
|
||||
map
|
||||
( )),
|
||||
sequential
|
||||
(assign
|
||||
(bound
|
||||
("y"),
|
||||
decimal-natural
|
||||
("4")),
|
||||
print
|
||||
(assigned
|
||||
(bound
|
||||
("y"))))),
|
||||
assign
|
||||
(bound
|
||||
("z"),
|
||||
int-mul
|
||||
(assigned
|
||||
(bound
|
||||
("z")),
|
||||
assigned
|
||||
(bound
|
||||
("x")))),
|
||||
print
|
||||
(assigned
|
||||
(bound
|
||||
("z"))),
|
||||
print
|
||||
(int-add
|
||||
(assigned
|
||||
(bound
|
||||
("z")),
|
||||
assigned
|
||||
(bound
|
||||
("x"))))))
|
||||
16
IBAF-Tests/IBAF-1/scopes.ibaf
Normal file
16
IBAF-Tests/IBAF-1/scopes.ibaf
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
int z =5;
|
||||
int x =5*3;
|
||||
print(x);
|
||||
|
||||
x = 2;
|
||||
print(x*3);
|
||||
|
||||
{
|
||||
int y =4;
|
||||
print (y);
|
||||
}
|
||||
|
||||
z = z * x;
|
||||
print(z);
|
||||
print(z+x);
|
||||
@@ -1,64 +0,0 @@
|
||||
initialise-binding finalise-failing scope
|
||||
(collateral
|
||||
(bind
|
||||
("x",
|
||||
allocate-initialised-variable
|
||||
(integers,
|
||||
0)),
|
||||
bind
|
||||
("y",
|
||||
allocate-initialised-variable
|
||||
(integers,
|
||||
0))),
|
||||
sequential
|
||||
(assign
|
||||
(bound
|
||||
("x"),
|
||||
decimal-natural
|
||||
("10")),
|
||||
assign
|
||||
(bound
|
||||
("y"),
|
||||
checked int-mod
|
||||
(assigned
|
||||
(bound
|
||||
("x")),
|
||||
int-val [: 0 :])),
|
||||
print
|
||||
(assigned
|
||||
(bound
|
||||
("x"))),
|
||||
print
|
||||
(assigned
|
||||
(bound
|
||||
("y"))),
|
||||
print
|
||||
(is-equal
|
||||
(assigned
|
||||
(bound
|
||||
("x")),
|
||||
decimal-natural
|
||||
("1"))),
|
||||
print
|
||||
(is-equal
|
||||
(assigned
|
||||
(bound
|
||||
("x")),
|
||||
assigned
|
||||
(bound
|
||||
("y")))),
|
||||
print
|
||||
(is-less
|
||||
(assigned
|
||||
(bound
|
||||
("x")),
|
||||
assigned
|
||||
(bound
|
||||
("y")))),
|
||||
print
|
||||
(int-add
|
||||
(assigned
|
||||
(bound
|
||||
("x")),
|
||||
decimal-natural
|
||||
("2")))))
|
||||
@@ -1,4 +1,4 @@
|
||||
int x, y;
|
||||
int x,y;
|
||||
|
||||
int x = 10;
|
||||
int y = x % 3;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
int x , y ; x = 10 % 3 ; y = x + 10 ; print ( x ) ; print ( y ) ;
|
||||
Reference in New Issue
Block a user