Welcome to Flex, a flexible and beginner-friendly programming language that allows you to write code in multiple syntax styles, including Franko Arabic, English, and C-style syntax. Flex is designed for all levels of programmers, from children to professionals, providing an easy-to-learn syntax with powerful programming capabilities.
Flex is unique because it:
- Supports multiple programming styles, allowing developers to write code in a way they are most comfortable with.
- Bridges the gap between high-level scripting languages (like Python) and low-level languages (like C).
- Uses regular expressions (regex) for tokenization, making parsing and error handling efficient.
- Has intuitive and readable syntax, making it an excellent choice for beginners while still being powerful for advanced users.
- Is designed to be cross-platform, ensuring compatibility across different operating systems.
This guide will take you from the basics to advanced concepts, with clear explanations and code examples with outputs.
- Supports multiple syntaxes (Franko Arabic, English, C-style, etc.)
- Uses regular expressions (regex) for efficient tokenization
- Provides control flow structures (if-else, loops, functions)
- Allows variable declarations with intuitive keywords
- Implements built-in functions for input and output
- No need for semicolons (
;
) at the end of statements - Blocks are enclosed within
{}
- Seamless integration with Python and C-style and Flex syntax
- Automatic type detection when variables are assigned values
etb3("Hello, Flex!")
Output:
Hello, Flex!
rakm x = 10
int y = 5
rakm z=2, m=1, n=0
etb3("{x} and {y}")
etb3("count down {z} {m} {n}")
Output:
10 and 5
count down 2 1 0
kasr pi = 3.14
float radius = 3
etb3("Value of pi is {pi} and the radius value is {radius}")
Output:
Value of pi is 3.14 and the radius value is 3.0
isActive = true
bool isComplete = false
etb3("Active: {isActive}, Complete: {isComplete}")
Output:
Active: True, Complete: False
klma message = "Welcome to Flex!"
string letter = "Welcome to the world!"
etb3(message)
etb3(letter)
Output:
Welcome to Flex!
Welcome to the world!
dorg myList = [1, 2.3, "hello", true]
list alist = [15,3,26,1000]
etb3(myList)
etb3(alist)
Output:
[1, 2.3, 'hello', True]
[15, 3, 26, 1000]
x=5
y=2.43
z="hello"
l="m"
etb3(x)
etb3(y)
etb3(z)
etb3(l)
Output:
5
2.43
hello
m
x= "hello world to print in many ways"
etb3(x)
out("this is {x}")
print(x)
cout("this way for {x}")
output("{x}")
printf("toΒ printΒ {x}")
Output:
hello world to print in many ways
this is hello world to print in many ways
hello world to print in many ways
this way for hello world to print in many ways
hello world to print in many ways
to print hello world to print in many ways
etb3("Enter your name:")
klma name = da5l()
etb3("Hello, {name}!")
etb3("Enter your age:")
age = scan()
etb3("your age is {age}")
etb3("Enter your birthday:")
klma dateofbirth = read()
etb3("you were born on {dateofbirth}.")
etb3("Enter your phone number:")
number = input()
etb3("your phone number is {number}.")
etb3("Enter your favorite color:")
klma color = da5al()
etb3("your color is {color}!")
etb3("Enter your pet type:")
pet = d5l()
etb3("your pet is, {pet}!")
Output:
Enter your name:
Input:
lina
Hello, lina!
Enter your age:
Input:
23
your age is 23
Enter your birthday:
Input:
10-2-1999
you were born on 10-2-1999.
Enter your phone number:
Input: 01002325428
your phone number is 1002325428.
Enter your favorite color:
Input: red
your color is red!
Enter your pet type:
Input: cat
your pet is, cat!
rakm x = 5
lw x > 3 {
etb3("x is greater than 3")
}
gher {
etb3("x is not greater than 3")
}
Output:
x is greater than 3
rakm x = -2
lw x > 10 { etb3("x is greater than 10") }
aw x == 5 { etb3("x is equal to 5") }
aw x <= 0 { etb3("x is less than or equal 0") }
gher { etb3("x is less than 10") }
Output:
x is less than or equal 0
rakm x = 5
if (x > 3) { etb3("x is greater than 3") }
else { etb3("x is not greater than 3") }
Output:
x is greater than 3
rakm x = 5
lw x > 3 and x < 9 {
etb3("x is between 3 and 9")
}
gher {
etb3("x is not in the middle of 3 and 9")
}
Output:
x is between 3 and 9
kasr x = 5.45
cond (x > 10) {
etb3("{x} is bigger than 10")
}
gher {
etb3("{x} is less than 10")
}
Output:
5.45 is less than 10
rakm x = 2
lw x > 3 {
etb3("x is greater than 3")
}
otherwise {
etb3("x is not greater than 3")
}
Output:
x is not greater than 3
kasr x = 5.23
lw x > 3 {
etb3("x is greater than 3")
}
else {
etb3("x is not greater than 3")
}
Output:
x is greater than 3
rakm i = 0
talama i < 5 {
etb3(i)
i++
}
Output:
0
1
2
3
4
i = 1.0
tlma i < 5.0 {
etb3(i)
i++
}
Output:
1.0
2.0
3.0
4.0
i = 30
talma i >= 25 {
etb3(i)
i--
}
Output:
29
28
27
26
25
i = 4
while (i == 4) {
etb3(i)
i++
}
Output:
4
i = 0
loop (i < 6) {
etb3(i)
i++
}
Output:
0
1
2
3
4
5
karr x=4 l7d 10 {etb3(x)}
Output:
4
5
6
7
8
9
karr x l7d 10 {etb3("hello world 10 times")} //x will automatically be initiated by 0
Output:
4
5
6
7
8
9
karr l7d 10 {etb3("hello 10 times")} //automatically be initiated by 0
Output:
hello 10 times
hello 10 times
hello 10 times
hello 10 times
hello 10 times
hello 10 times
hello 10 times
hello 10 times
hello 10 times
hello 10 times
n=15
for (int i=5; i <= n; i++) {etb3("hello {i}")}
Output:
sndo2 add(rakm a, rakm b) {
rg3 a + b
}
rakm result = add(3, 7)
etb3("Result: {result}")
Output:
Result: 10
fun add(rakm a, rakm b) {
rg3 a + b
}
rakm result = add(3, 7)
etb3("Result: {result}")
Output:
Result: 10
sando2 add(rakm a, rakm b) {
rg3 a + b
}
rakm result = add(3, 7)
etb3("Result: {result}")
Output:
Result: 10
fn add(rakm a, rakm b) {
return a + b
}
rakm result = add(3, 7)
etb3("Result: {result}")
Output:
Result: 10
function add(rakm a, rakm b) {
rg3 (-1) * a + b
}
rakm result = add(3, 7)
etb3("Result: {result}")
Output:
Result: 4
dorg myList = [1, 2, 3]
myList.push(4)
etb3(myList)
myList.pop()
etb3(myList)
Output:
[1, 2, 3, 4]
[1, 2, 3]
list myList = [1, 2, 3]
myList.push(4)
etb3(myList)
myList.pop()
etb3(myList)
Output:
[1, 2, 3, 4]
[1, 2, 3]
sando2 absolute(rakm a){
lw a < 0 {
x = a * (-1)
rg3 x
}
gher{ rg3 a}
}
geeb "path to the .lx file "
x= -400
postive = absolute(x)
etb3("{x} after absolute is {postive}")
Output:
-400 after absolute is 400
sando2 absolute(rakm a){
lw a < 0 {
x = a * (-1)
rg3 x
}
gher{ rg3 a}
}
geep "path to the .lx file "
x= -400
postive = absolute(x)
etb3("{x} after absolute is {postive}")
Output:
-400 after absolute is 400
sando2 absolute(rakm a){
lw a < 0 {
x = a * (-1)
rg3 x
}
gher{ rg3 a}
}
import "path to the .lx file "
x= -400
postive = absolute(x)
etb3("{x} after absolute is {postive}")
Output:
-400 after absolute is 400
# Define a list
dorg arrr = [-1, 2, -3, 4, 99]
# Access elements by index and perform operations
rakm num = 4
etb3(arrr[num] + arrr[num]) # 99 + 99 = 198
# Finding the length of a list
rakm y = length(arrr)
lw length(arrr) < 3 {
etb3("List is too short!")
}
etb3(y)
# Creating and modifying lists
dorg xx = [6, 2, 3, 4]
etb3(xx) # Print the initial list
# Adding elements
xx.push(23) # Equivalent to push
xx.push("worddd")
etb3(xx) # Print list after additions
# Removing elements
xx.pop() # Removes the last element (pop)
etb3(xx)
xx.remove(3) # Removes the value 3 from the list
etb3(xx)
Output:
198
5
[6, 2, 3, 4]
[6, 2, 3, 4, 23, 'worddd']
[6, 2, 3, 4, 23]
[6, 2, 4, 23]
# Creating and modifying lists
dorg xx = [6, 2, 3, 4]
etb3(xx) # Print the initial list
# Merging lists & performing calculations
dorg qq = [12, 22, 34]
etb3("x0+q1={xx[0] + qq[1]}") # Print formatted string with calculation
etb3(xx[0] + qq[1]) # Sum of first element of xx and second of qq
# Arithmetic operations with list elements
rakm no = xx[0] * xx[1]
rakm ew = xx[0] * xx[1]
etb3(no - ew) # Should print 0
etb3("no is {no}")
# Conditional check with list values
lw xx[0] < xx[1] {
etb3("xo is smaller")
}
Output:
[6, 2, 3, 4]
x0+q1=28
28
0
no is 12
rakm i = 0
talama i < 10 {
etb3(i)
lw i == 4 {
w2f
}
i++
}
Output:
0
1
2
3
4
rakm i = 0
talama i < 10 {
etb3(i)
lw i == 4 {
break
}
i++
}
Output:
0
1
2
3
4
rakm i = 0
talama i < 10 {
etb3(i)
lw i == 4 {
stop
}
i++
}
Output:
0
1
2
3
4
sndo2 multiply(rakm a, rakm b) {
rg3 a * b
}
rakm x = 5
rakm y = 6
print("{x} x {y} = {multiply(x, y)}")
Output:
5 x 6 = 30
Congratulations! You have now learned the basics of Flex mixed with Python and C! π This guide covered:
- Variables and Data Types
- Input and Output
- Conditional Statements
- Loops and Iterations
- Functions and Error Handling
- Advanced Features (Lists, Nested Loops, Mixed Syntax, etc.)
Feel free to experiment with Flex and create your own programs!
To explore more about Flex, join the community and contribute to the development. Happy coding! π