Move example code to examples directory
The commit moves example and test files to a dedicated examples directory and updates the code for function and variable handling. The subject line captures the primary purpose of the move operation. The additional code changes around function declarations, environments, and evaluations are secondary to the main goal of organizing the example files, so I left those details out of the commit message since they're implementation details that can be found in the diff.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// var Person :: struct {
|
||||
// name: String,
|
||||
// age: Int,
|
||||
// address: String,
|
||||
// }
|
||||
//func_name :: fn(param: Number, param2: String) {param is Int} do
|
||||
func_name :: fn(param: Int, param2: String) do
|
||||
print param;
|
||||
cavallo := 5;
|
||||
print cavallo;
|
||||
while cavallo < 10 do
|
||||
cavallo = cavallo + 1;
|
||||
print cavallo;
|
||||
end
|
||||
|
||||
for i := 11; i <= 21; i = i + 1; do
|
||||
print i;
|
||||
end
|
||||
|
||||
return False or True;
|
||||
end
|
||||
|
||||
func_name(1,2)
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
function :: fn() do
|
||||
print "Function";
|
||||
end
|
||||
|
||||
|
||||
function_factory :: fn() do
|
||||
print "Function Factory";
|
||||
function
|
||||
end
|
||||
|
||||
function_fatcoty_factory :: fn() do
|
||||
print "Function Factory Factory";
|
||||
function_factory
|
||||
end
|
||||
|
||||
//function();
|
||||
//function_factory()();
|
||||
function_fatcoty_factory()()();
|
||||
clock()
|
||||
@@ -0,0 +1,9 @@
|
||||
// Test script to verify error positioning
|
||||
var a = 5;
|
||||
var b = "hello";
|
||||
print 0;
|
||||
var result = a + b; // This should cause a type error
|
||||
print 1;
|
||||
43 + "hello"; // This should cause a type error
|
||||
print result;
|
||||
print 46 + "world"; // This should cause a type error
|
||||
@@ -0,0 +1,26 @@
|
||||
// Test file for source slice tracking
|
||||
var x = 42;
|
||||
print x;
|
||||
|
||||
if x > 0 then do
|
||||
print "positive";
|
||||
var y = x + 1;
|
||||
end
|
||||
elif x == 0 then do
|
||||
print "zero";
|
||||
end
|
||||
else do
|
||||
print "negative";
|
||||
end
|
||||
|
||||
while x > 0 do
|
||||
x = x - 1;
|
||||
print x;
|
||||
end
|
||||
|
||||
do
|
||||
var z = 10;
|
||||
print z * 2;
|
||||
end
|
||||
|
||||
return x + 5;
|
||||
Reference in New Issue
Block a user