voor de initialise-variable verandering

This commit is contained in:
Peter
2024-03-10 09:53:47 +01:00
parent 613fa9ab1a
commit cb7f6f8e5d
18 changed files with 163 additions and 183 deletions

View File

@@ -1,7 +1,9 @@
if (true) {
print(true);
}else{print(false);}
}else{
print(false);
}

View File

@@ -70,7 +70,7 @@ initialise-binding scope
(bound
("n")),
decimal-natural
("8")),
("5")),
sequential
(scope
(collateral

View File

@@ -5,6 +5,6 @@ fun fib(n) {
return fib(n-1) + fib(n-2);
}
for (int n = 0; n < 8) {
for (int n = 0; n < 5) {
print(fib(n));
}

View File

@@ -69,7 +69,7 @@ initialise-binding scope
(bound
("n")),
decimal-natural
("8")),
("5")),
scope
(collateral
(map

View File

@@ -5,9 +5,10 @@ fun fib(n) {
return fib(n-1) + fib(n-2);
}
int n = 0;
while (n < 8) {
while (n < 5) {
print(fib(n));
n = n + 1;
}

View File

@@ -0,0 +1,64 @@
initialise-binding scope
(collateral
(bind
("x",
allocate-variable
(integers)),
map
( ),
map
( ),
map
( ),
map
( )),
sequential
(assign
(bound "x",
int-mul
(decimal-natural
("10"),
decimal-natural
("10"))),
print assigned
(bound
("x")),
scope
(collateral
(bind
("x",
allocate-variable
(integers)),
bind
("y",
allocate-variable
(integers)),
map
( ),
map
( ),
map
( )),
sequential
(assign
(bound "x",
decimal-natural
("10")),
assign
(bound "y",
int-mul
(assigned
(bound
("x")),
assigned
(bound
("x")))),
print assigned
(bound
("x")),
print assigned
(bound
("y")))),
print assigned
(bound
("y"))))

View File

@@ -0,0 +1,13 @@
int x =10*10;
print(x);
{
int x = 10;
int y = x*x;
print(x);
print(y);
}
print(y);
//int x = 1;

View File

@@ -1,21 +1,9 @@
initialise-binding scope
(collateral
(bind
("z",
allocate-initialised-variable
(integers,
0)),
bind
("x",
allocate-initialised-variable
(integers,
0)),
map
( ),
map
( ),
map
( ),
allocate-variable
(integers)),
map
( ),
map
@@ -26,74 +14,51 @@ initialise-binding scope
( )),
sequential
(assign
(bound
("z"),
decimal-natural
("5")),
assign
(bound
("x"),
(bound "x",
int-mul
(decimal-natural
("5"),
("10"),
decimal-natural
("3"))),
print
(assigned
(bound
("x"))),
assign
("10"))),
print assigned
(bound
("x"),
decimal-natural
("2")),
print
(int-mul
(assigned
(bound
("x")),
decimal-natural
("3"))),
("x")),
scope
(collateral
(bind
("x",
allocate-variable
(integers)),
bind
("y",
allocate-initialised-variable
(integers,
0)),
allocate-variable
(integers)),
map
( ),
map
( ),
map
( )),
sequential
(assign
(bound
("y"),
(bound "x",
decimal-natural
("4")),
print
(assigned
(bound
("y"))))),
assign
("10")),
assign
(bound "y",
int-mul
(assigned
(bound
("x")),
assigned
(bound
("x")))),
print assigned
(bound
("x")),
print assigned
(bound
("y")))),
print assigned
(bound
("z"),
int-mul
(assigned
(bound
("z")),
assigned
(bound
("x")))),
print
(assigned
(bound
("z"))),
print
(int-add
(assigned
(bound
("z")),
assigned
(bound
("x"))))))
("x"))))

View File

@@ -1,16 +1,11 @@
z =5;
x =5*3;
int x =10*10;
print(x);
x = 2;
print(x*3);
{
y =4;
print (y);
int x = 10;
int y = x*x;
print(x);
print(y);
}
z = z * x;
print(z);
print(z+x);
print(x);

View File

@@ -1,50 +0,0 @@
L-start--L-pgm(
L-pgm--R-int-L-idlist-SEMI-L-stmt(
L-idlist--L-id-C-COMMA-L-idlist-D-Q(
LEX-id("x")
, Some(L-COMMA-L-idlist--COMMA-L-idlist(L-idlist--L-id-C-COMMA-L-idlist-D-Q(LEX-id("y"), None())))
)
, L-stmt--L-stmt-L-stmt(
L-stmt--L-id-EQUALS-L-exp-SEMI(
LEX-id("x")
, L-exp--L-aexp(
L-aexp--L-aexp-PERCENT-L-aexp(
L-aexp--L-int(L-int--C-DASH-Q-L-decimal-D(L-DASH-Q-L-decimal--DASH-Q-L-decimal(None(), LEX-decimal("10"))))
, L-aexp--L-int(L-int--C-DASH-Q-L-decimal-D(L-DASH-Q-L-decimal--DASH-Q-L-decimal(None(), LEX-decimal("3"))))
)
)
)
, L-stmt--L-stmt-L-stmt(
L-stmt--L-id-EQUALS-L-exp-SEMI(
LEX-id("y")
, L-exp--L-aexp(
L-aexp--L-aexp-PLUS-L-aexp(
L-aexp--L-id(LEX-id("x"))
, L-aexp--L-int(L-int--C-DASH-Q-L-decimal-D(L-DASH-Q-L-decimal--DASH-Q-L-decimal(None(), LEX-decimal("10"))))
)
)
)
, L-stmt--L-stmt-L-stmt(
L-stmt--R-print-LPAREN-L-exp-RPAREN-SEMI(
amb(
[ amb(
[L-exp--L-id(LEX-id("x")), L-exp--L-bexp(L-bexp--L-id(LEX-id("x")))]
)
, L-exp--L-aexp(L-aexp--L-id(LEX-id("x")))
]
)
)
, L-stmt--R-print-LPAREN-L-exp-RPAREN-SEMI(
amb(
[ amb(
[L-exp--L-id(LEX-id("y")), L-exp--L-bexp(L-bexp--L-id(LEX-id("y")))]
)
, L-exp--L-aexp(L-aexp--L-id(LEX-id("y")))
]
)
)
)
)
)
)
)

View File

@@ -1,13 +0,0 @@
int x,y;
int x = 10;
int y = x % 3;
print(x);
print(y);
print(x == 1);
print(x == y);
print(x < y);
print(x + 2);