implement chapter 11 in rust
This commit is contained in:
parent
8860a1c639
commit
a25b6d1e92
16 changed files with 470 additions and 32 deletions
9
lox/fibonacci.lox
Normal file
9
lox/fibonacci.lox
Normal file
|
@ -0,0 +1,9 @@
|
|||
var a = 0;
|
||||
var temp;
|
||||
|
||||
var b = 1;
|
||||
for(var b = 1; a < 1000; b = temp + b) {
|
||||
print a;
|
||||
temp = a;
|
||||
a = b;
|
||||
}
|
4
lox/name_redefinition.lox
Normal file
4
lox/name_redefinition.lox
Normal file
|
@ -0,0 +1,4 @@
|
|||
fun bad() {
|
||||
var a = "first";
|
||||
var a = "second";
|
||||
}
|
10
lox/scoping.lox
Normal file
10
lox/scoping.lox
Normal file
|
@ -0,0 +1,10 @@
|
|||
var a = "global";
|
||||
{
|
||||
fun showA() {
|
||||
print a;
|
||||
}
|
||||
|
||||
showA();
|
||||
var a = "block";
|
||||
showA();
|
||||
}
|
1
lox/top_level_return.lox
Normal file
1
lox/top_level_return.lox
Normal file
|
@ -0,0 +1 @@
|
|||
return "at top level";
|
Loading…
Add table
Add a link
Reference in a new issue