Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Latest commit

 

History

History
169 lines (142 loc) · 3.28 KB

File metadata and controls

169 lines (142 loc) · 3.28 KB

GRUA

  • A New Programming Language that is Simple to learn

NOTICE

THIS PROJECT IS SUCCEEDED BY THIS PROJECT

  • Reason because i genuinely lost my interest to code again actually ever since the AI ERA has started
  • so i wish whoever is interested is they can fork it and do what they like with it
  • If they wish to credit me you may do so but i dont mind if no credit is given actually to whoever is interested i wish the best

Syntax

Variables

-- Variables Have Type Inference by default

-- Global Variables
-- immutable
x = 10

-- mutable
mut y = 10

-- Local Variables
-- immutable
local z = 10

-- mutable
local mut zx = 23

Data Types

  • These are data types that will be built into the language
-- Built in the Language
string

-- unsigned integers
int (size of 64 bit by default)
    - i64
    - i32
    - i16
    - i8

-- signed integers
sint (size of 64 bit by default)
    - s64
    - s32
    - s16
    - s8

float (size of 64 bit by default)
    - f64
    - f32

bool
char
array
map
quaternion
vector
    - vector2
    - vector3
any

Custom Data types

-- Basic Data Type
function ArrayList[T: any](data: T, length: int, capacity: int, allocator = .DEFAULT) -> type
    -- This tells the langauge to do the following code when it is trying to allocate memory for this type
    [new] do
        allocator.region = get_default_procces_allocator(#region(100, T), #sizeof(capacity));
    end

    -- This tells the langauge to do the following code when it is trying to deallocate memory for this type
    [delete] do
        allocator.free = free_all_allocator(.{}); 
    end

    -- This tells the langauge to do the following code to occur when this type is having side_efffects
    [side_effects] do
        allocator.free = free_all_allocator(.{}); 
    end

    -- This tells the langauge that we are extending the custom data type to contain such a method to be allowed the below code
    -- x = ArrayList(bool, 100, 1000);
    -- x.get_length();
    #extend do
        function get_length() -> int
            return this.length;
        end
    end
end

Functions

-- function with no parameters
function no_parameters()
    -- Source Code Goes Here
end

-- function with parameters
function parameters(x : string)
    -- Source Code Goes Here
end 

-- function with return type
function return_type() -> int
    return 69420;
end

-- function with multiple return types 
function mutli_return_values() -> (int, string)
    return 0, "success";
end

Condition Statements

-- if..else statement (one_line)
is_bool = if x > 10 {return false}  else {return true} end
assign_number = if x > 10 {return 12345} else {return 69420} end

-- if..elif..else
if x > 10 {
    return 69;
} elif x > 69 {
    return 45;
} else {
    return 0;
}

-- unless..else
-- the opposite of an if statement
unless x < 49 {
    return 69;
} else {
    return 10;
}

-- unless..else (one_line)
is_bool2 = unless x > 10 {return false}  else {return true} end
assign_number2 = unless x > 10 {return 12345} else {return 69420} end

Loops

-- for loop
for i:= 0; i<10; i+=1
    print(i);
end

-- range loop
for i in range(69420)
    print(i);
end

-- while
while x < 10
    print(x)
    x+=1
end

-- do while
do {
    print(x)
    x+=1
} while x < 10 end