Welcome to the Qweil programming language documentation! Qweil is designed to be a simple and intuitive language that compiles to Python, making it easy to learn and use. This document will guide you through the syntax and features of Qweil.
- Logging
- Conditional Statements
- Loops
- Functions
- Classes
- Exception Handling
- Variable Assignment
- Global Variables
- Decorators
- Deleting Variables
- Quitting the Program
- Throwing Exceptions
Logging in Qweil is done using the log
function. This is equivalent to the print
function in Python.
log("Hello, World!")
log("Hello, World!")
Conditional statements in Qweil use the if
keyword followed by the condition and the then
keyword.
if (condition) then # code to execute if condition is true end
x = 10 if x > 5 then log("x is greater than 5") end
Qweil supports both for
and while
loops.
for (variable in range) do # code to execute end
for i in range(5) do log(i) end
while (condition) do # code to execute end
x = 0 while x < 5 do log(x) x = x + 1 end
Functions in Qweil are defined using the func
keyword.
func function_name(parameters) do # function body end
func greet(name) do log("Hello, " + name) end
greet("Alice")
Classes in Qweil are defined using the class
keyword.
class ClassName do func __init__(self, parameters) do # constructor body end
func method_name(self, parameters) do # method body end
end
class Person do func __init__(self, name) do self.name = name end
func greet(self) do log("Hello, " + self.name) end
end
person = Person("Alice") person.greet()
Exception handling in Qweil is done using the try
, except
, and finally
keywords.
try # code that may raise an exception except (exception_type) do # code to handle the exception end finally do # code to execute regardless of an exception end
try risky_operation() except Exception as e do log("An error occurred: " + str(e)) end finally do log("This will always execute") end
Variable assignment in Qweil is straightforward.
variable_name = value
x = 10 log(x)
Global variables in Qweil are declared using the global
keyword.
global variable_name
global x x = 10 log(x)
Decorators in Qweil are defined using the @
symbol.
@decorator_name
@staticmethod func my_method() do log("This is a static method") end
Variables in Qweil can be deleted using the del
keyword.
del variable_name
x = 10 del x
The program can be terminated using the quit
function.
quit(exit_code)
quit(0)
Exceptions in Qweil can be thrown using the throw
keyword.
throw exception_type
throw ValueError("An error occurred")
Happy coding with Qweil!