Jumping Back and Forth 23
This commit is contained in:
parent
98e7f950cf
commit
8717d37445
13 changed files with 299 additions and 30 deletions
9
test/for.lox
Normal file
9
test/for.lox
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
for(var x = 1; x < 3; x = x + 1){
|
||||
print x;
|
||||
}
|
||||
|
||||
for(var x = 1; x <= 3; x = x + 1){
|
||||
print x;
|
||||
}
|
||||
|
||||
23
test/ifelse.lox
Normal file
23
test/ifelse.lox
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
if(true){
|
||||
print "a1";
|
||||
} else {
|
||||
print "b1";
|
||||
}
|
||||
|
||||
if(false){
|
||||
print "a2";
|
||||
} else {
|
||||
print "b2";
|
||||
}
|
||||
|
||||
if(false){
|
||||
print "a3";
|
||||
} else if(false){
|
||||
print "b3";
|
||||
} else if(true){
|
||||
print "c3";
|
||||
} else {
|
||||
print "d3";
|
||||
}
|
||||
|
||||
42
test/while.lox
Normal file
42
test/while.lox
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
var x = 1;
|
||||
|
||||
while(x <= 2){
|
||||
print x;
|
||||
x = x + 1;
|
||||
}
|
||||
print "";
|
||||
|
||||
while(x > 0){
|
||||
print x;
|
||||
x = x - 1;
|
||||
}
|
||||
print "";
|
||||
|
||||
while(x < 2){
|
||||
print x;
|
||||
x = x + 1;
|
||||
}
|
||||
print "";
|
||||
|
||||
{
|
||||
var x = 1;
|
||||
|
||||
while(x <= 2){
|
||||
print x;
|
||||
x = x + 1;
|
||||
}
|
||||
print "";
|
||||
|
||||
while(x > 0){
|
||||
print x;
|
||||
x = x - 1;
|
||||
}
|
||||
print "";
|
||||
|
||||
while(x < 2){
|
||||
print x;
|
||||
x = x + 1;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue