The commit rewrites the environment to use a stack of hash maps for managing variable scopes. This replaces the old parent-reference approach with a simpler and more efficient stack-based model. Key changes: - Rename Environment to EnvironmentStack - Store scopes in a Vec of HashMaps - Add push/pop scope operations for block handling - Update interpreter to properly manage scope lifetimes - Clean up error handling with helper functions
25 lines
416 B
Lox
25 lines
416 B
Lox
// var Person :: struct {
|
|
// name: String,
|
|
// age: Int,
|
|
// address: String,
|
|
// }
|
|
// var func_name :: fn(param, param2) {param is Int} do
|
|
do
|
|
print "ciao";
|
|
1 + 2;
|
|
var cavallo = 1 + 2;
|
|
cavallo = cavallo + 1;
|
|
print cavallo;
|
|
cavallo
|
|
end
|
|
do
|
|
var cavallo = 0;
|
|
print "cavallo";
|
|
while cavallo < 10 do
|
|
cavallo = cavallo + 1;
|
|
print cavallo;
|
|
end
|
|
89
|
|
end
|
|
99
|