aboutsummaryrefslogtreecommitdiff
path: root/lang.felan
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2024-09-18 19:46:38 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2024-09-18 19:57:20 +0330
commitd6ba30b94a24607bce5db5e706eb20cc051a98f0 (patch)
tree146e74b0bc2e1636451257015210e3c7d1a0ecab /lang.felan
initial commit
Diffstat (limited to 'lang.felan')
-rw-r--r--lang.felan159
1 files changed, 159 insertions, 0 deletions
diff --git a/lang.felan b/lang.felan
new file mode 100644
index 0000000..b18785e
--- /dev/null
+++ b/lang.felan
@@ -0,0 +1,159 @@
+// variable
+// variable definition (full version)
+variableName : Type = value;
+constantName : Type : value;
+
+// i.e.
+myInt : Int = 23;
+myConstInt : Int : 23;
+myFloat : Float = 23.0;
+
+// multiple variable definition (full version)
+variableName0, ... : TypeForAllOfThem = value0, ...;
+
+// i.e.
+myInt, yourInt : Int = 23 , 54;
+
+// variable definition (compiler knows types)
+variableName := value;
+constantName :: value;
+
+// i.e.
+myInt := 23;
+myConstInt :: 23;
+myFloat := 23.0;
+
+// multiple variable definition (compiler knows types)
+variableName0, ... := value0, ...;
+
+// i.e.
+myInt, yourInt := 23, 54; // all values must have the same type
+
+// variable definition (without initialization) constants can't be defined this way
+variableName : Type;
+
+// i.e.
+myInt : Int;
+myFloat : Float;
+
+// multiple variable definition (without initialization)
+variableName0, ... : TypeForAllOfThem;
+
+// i.e.
+myInt, yourInt : Int;
+
+// pointers
+// pointers will be initialized to undefined
+
+// definition of a pointer which can't be null
+pointerName : *Type = value;
+
+// i.e.
+myPointer : *Int = new Int;
+
+// definition of a pointer which can be null
+myPointer : nullable*Type = value;
+
+// i.e.
+myPointer : nullable*Int = null;
+
+// arrays
+arrayName : [size]Type = [size]Type{value,...};
+
+// i.e.
+myArray : [4]Int = [4]Int{11,2,23,4};
+myArray2 := [4]Int{11,2,23,4}; // identical to the last one
+myArray3 : [4]Int;
+
+// function
+// function definition
+functionName :: (paramName:ParamType, ...) -> ReturnType {
+ // body
+}
+
+// i.e.
+foo :: () {
+ // no param no returning (void)
+}
+bar :: (myInt: Int,myFloat:Float) -> Int {
+ // 2 param Int , Float and Int return Type
+}
+boo :: (myInt: Int) -> Int, Int {
+ // this is the way to return multiple values
+ return myInt, myInt;
+}
+
+// function calling
+functionName(paramters, ...);
+
+// i.e
+foo();
+retValue := bar(myInt,myFloat);
+retValue0,retValue2 := boo(myInt);
+
+// lambdas
+// lambdas are just functions that have been assigned to variables
+
+// structs (classes)
+// definition
+StructName :: struct {
+ // field
+ fieldName : Type;
+
+ // constant field
+ constantFiledName : Type : value;
+
+ // method (has this pointer)
+ methodName :: (paramName:ParamType, ...) -> ReturnType {
+ // body
+ }
+
+ #static
+ staticFieldName : Type = value;
+
+ // static method (has no this pointer)
+ #static
+ staticMethodName :: (paramName:ParamType, ...) -> ReturnType {
+ // body
+ }
+}
+
+// instancing
+instanceName : StructName = StructName {
+ .fieldName = value,
+ ...
+};
+
+// instancing as a pointer
+pointerInstance := new StructName{
+ .fieldName = value,
+ ...
+}
+
+// with undefined value
+pointerInstance := new StructName;
+
+// if
+if (condition) {
+ // body
+}
+
+// while
+while (condition) {
+ // body
+}
+
+// for
+for ( definition ; condition ; step ) {
+ // body
+}
+
+// i.e.
+for (i := 0;i < 10;++i){
+ // body
+}
+
+// for each
+for ( variableName in iteratorName ){
+ // body
+}