Updated docs

This commit is contained in:
acano 2026-03-06 11:38:06 +01:00
parent 6692990a38
commit a434d34676
19 changed files with 292 additions and 193 deletions

View File

@ -81,12 +81,12 @@ startLoop() try: print(1 / 0) except: raise RuntimeError("Something went wrong")
Break Statement Break Statement
In AVAP, the break statement is used to terminate the closest enclosing loop. The syntax for the break statement is as follows: In AVAP, the break statement is used to terminate the closest enclosing loop. The syntax for the break statement is as follows:
break break()
When a break statement is encountered, it causes the loop to exit immediately, regardless of the loop's condition or any remaining iterations. This effectively transfers control to the statement following the loop. When a break statement is encountered, it causes the loop to exit immediately, regardless of the loop's condition or any remaining iterations. This effectively transfers control to the statement following the loop.
The break statement is typically used within for or while loops to provide a way to exit the loop prematurely based on a certain condition. The break statement is typically used within for or while loops to provide a way to exit the loop prematurely based on a certain condition.
for i in range(10): if i == 5: break print(i) print("Loop ended") addVar(_status, "OK") startLoop(idx, 0, 9) if(idx, 4, "==") idx = -1 break() end() endLoop() addResult(idx) addStatus("OK")
In this example, the loop will terminate when i equals 5, and "Loop ended" will be printed. The numbers 0 through 4 will be printed before the loop is exited. In this example, the loop will terminate when i equals 5, and "Loop ended" will be printed. The numbers 0 through 4 will be printed before the loop is exited.
Break Statement Break Statement
@ -109,16 +109,16 @@ When continue is used within a loop that is also handling exceptions with a try
for i in range(10): try: if i % 2 == 0: continue print(i) finally: print("In finally clause") print("Loop ended") for i in range(10): try: if i % 2 == 0: continue print(i) finally: print("In finally clause") print("Loop ended")
In this example, the continue statement will skip the current iteration when i is even, but before moving to the next iteration, the finally clause will print "In finally clause." For odd numbers, the loop will print the number and then "In finally clause." After the loop finishes, "Loop ended" will be printed. In this example, the continue statement will skip the current iteration when i is even, but before moving to the next iteration, the finally clause will print "In finally clause." For odd numbers, the loop will print the number and then "In finally clause." After the loop finishes, "Loop ended" will be printed.
Import Statement Include Statement
In AVAP, the import statement is used to import an entire code file and define names in the local namespace. The syntax for the import statement is as follows: In AVAP, the include statement is used to include an entire code file and define names in the local namespace. The syntax for the include statement is as follows:
import file.avap include file.avap
The import statement in AVAP imports an entire code file and makes it available in the local namespace. No alias is assigned to the imported file; the file is simply referred to by its name. The include statement in AVAP includes an entire code file and makes it available in the local namespace. No alias is assigned to the included file; the file is simply referred to by its name.
For example: For example:
# In the 'module.avap' file example_variable = 10 # In the main file import module.avap print(module.avap.example_variable) # Will print 10 # In the 'module.avap' file example_variable = 10 # In the main file include module.avap addResult(example_variable) # Will print 10
In this example, the main file imports the module.avap file and can access the example_variable defined in that file using the module.avap syntax. In this example, the main file includess the module.avap file and can access the example_variable defined in that file using the module.avap syntax.
Compound Statements Compound Statements
In AVAP, compound statements contain (groups of) other statements; these affect or control the execution of those other statements in some way. In general, compound statements span multiple lines, though in simpler representations a complete compound statement might be contained within a single line. In AVAP, compound statements contain (groups of) other statements; these affect or control the execution of those other statements in some way. In general, compound statements span multiple lines, though in simpler representations a complete compound statement might be contained within a single line.
@ -133,7 +133,7 @@ In AVAP, control flow structures include conditional statements and loops, which
If Statements If Statements
The syntax for an if statement in AVAP is: The syntax for an if statement in AVAP is:
if (variable, variableValue, comparator, expression): code to execute if (variable, variableValue, comparator, expression) code to execute else() code to execute end()
This structure checks if the condition (variable compared to variableValue with the given comparator) is true, and if so, executes the block of code. This structure checks if the condition (variable compared to variableValue with the given comparator) is true, and if so, executes the block of code.
Loops Loops
@ -145,13 +145,13 @@ This structure initiates a loop where the variable iterates from the 'from' valu
The if Statement The if Statement
The if statement in AVAP is used for conditional execution. The syntax is as follows: The if statement in AVAP is used for conditional execution. The syntax is as follows:
if (variable, variableValue, comparator, expression): code to execute if (variable, variableValue, comparator, expression) code to execute else() code to execute end()
This statement evaluates the condition specified by the variable, variableValue, comparator, and expression. It selects exactly one of the suites (blocks of code) by evaluating the expressions one by one until a true condition is found. The corresponding suite is then executed. If all conditions are false, no suites are executed. This statement evaluates the condition specified by the variable, variableValue, comparator, and expression. It selects exactly one of the suites (blocks of code) by evaluating the expressions one by one until a true condition is found. The corresponding suite is then executed. If all conditions are false, no suites are executed.
The try Statement The try Statement
The try statement in AVAP specifies exception handlers and/or cleanup code for a block of statements. The syntax is as follows: The try statement in AVAP specifies exception handlers and/or cleanup code for a block of statements. The syntax is as follows:
try(): code to execute except(): code to execute try() code to execute exception() code to execute end()
The try block contains code that might raise an exception. The except block contains code to handle exceptions raised by the try block. If an exception occurs, control is transferred to the except block. If no exception occurs, the except block is skipped. The try block contains code that might raise an exception. The exception block contains code to handle exceptions raised by the try block. If an exception occurs, control is transferred to the except block. If no exception occurs, the except block is skipped.
Additional information about exceptions can be found in the section Exceptions, and information about using the raise statement to throw exceptions can be found in the section The raise Statement. Additional information about exceptions can be found in the section Exceptions, and information about using the raise statement to throw exceptions can be found in the section The raise Statement.

View File

@ -35,14 +35,15 @@ Example of import usage:
avap avap
// Content of the file main.avap // Content of the file main.avap
addVar(10, x) addVar(x, 10)
import functions.avap include functions.avap
myFunction(x) myFunction(x)
// Content of the file functions.avap // Content of the file functions.avap
def myFunction(y): function myFunction(y){
addVar(y + 5, result) addVar(result, y + 5)
print(result) addResult(result)
}
4.4. Exceptions 4.4. Exceptions
Exceptions in AVAP allow for the handling of errors or exceptional conditions. An exception is raised when an error is detected; it can be handled by the surrounding code block or by any code block that directly or indirectly invoked the block where the error occurred. Exceptions in AVAP allow for the handling of errors or exceptional conditions. An exception is raised when an error is detected; it can be handled by the surrounding code block or by any code block that directly or indirectly invoked the block where the error occurred.
@ -50,10 +51,11 @@ The AVAP interpreter raises an exception when it detects a runtime error. An AVA
Example of exception handling: Example of exception handling:
try: try()
addVar(10 / 0, result) addVar(10 / 0, result)
except ZeroDivisionError: except()
print("Cannot divide by zero.") addResult("Cannot divide by zero.")
end()
In this example, if a division by zero occurs, a ZeroDivisionError exception is raised and handled by the except block. In this example, if a division by zero occurs, a ZeroDivisionError exception is raised and handled by the except block.
This structure ensures that AVAP programs execute in a sequential and predictable manner, without advanced dynamic or deferred execution features, maintaining simplicity and clarity in name binding and import handling. This structure ensures that AVAP programs execute in a sequential and predictable manner, without advanced dynamic or deferred execution features, maintaining simplicity and clarity in name binding and import handling.
@ -61,26 +63,27 @@ This structure ensures that AVAP programs execute in a sequential and predictabl
5. The Import System in AVAP 5. The Import System in AVAP
AVAP code in one file gains access to code in another file through the import process. The import statement is the only way to invoke the import machinery in AVAP. AVAP code in one file gains access to code in another file through the import process. The import statement is the only way to invoke the import machinery in AVAP.
The import statement inserts the contents of the specified file at the exact point where the import statement appears in the original file. There are no other ways to invoke the import system in AVAP. The include statement inserts the contents of the specified file at the exact point where the import statement appears in the original file. There are no other ways to invoke the import system in AVAP.
When an import statement is executed, the contents of the imported file are processed as if they were part of the original file, ensuring that all functions and variables from the imported file are available in the context of the original file. If the specified file is not found, a FileNotFoundError is raised. When an include statement is executed, the contents of the imported file are processed as if they were part of the original file, ensuring that all functions and variables from the imported file are available in the context of the original file. If the specified file is not found, a FileNotFoundError is raised.
Example of using the import statement in AVAP: Example of using the include statement in AVAP:
Content of file main.avap Content of file main.avap
addVar(10, x) addVar(x,10)
import functions.avap include functions.avap
myFunction(x) myFunction(x)
Content of file functions.avap Content of file functions.avap
def myFunction(y): function myFunction(y){
addVar(y + 5, result) addVar(result, y + 5)
print(result) addResult(result)
}
In this example, the content of functions.avap is inserted into main.avap at the point of the import statement, ensuring that myFunction is defined before being called. In this example, the content of functions.avap is inserted into main.avap at the point of the import statement, ensuring that myFunction is defined before being called.
5.1. Import Rules 5.1. Import Rules
Position of Import: The import statement must be placed at the exact location where the content of the imported file is to be included. The content of the imported file is executed linearly along with the original file. Position of Import: The include statement must be placed at the exact location where the content of the imported file is to be included. The content of the imported file is executed linearly along with the original file.
Import Error: If the file specified in the import statement is not found, a FileNotFoundError is raised. Import Error: If the file specified in the include statement is not found, a FileNotFoundError is raised.
Scope of Imports: The functions and variables from the imported file are added to the local scope of the original file at the point of import. This means they can be accessed as if they were defined in the same file. Scope of Imports: The functions and variables from the imported file are added to the local scope of the original file at the point of import. This means they can be accessed as if they were defined in the same file.
5.2. Limitations and Considerations 5.2. Limitations and Considerations
No Packages: Unlike other languages, AVAP does not have a hierarchical package system. Each file is imported independently and treated as an autonomous unit. No Packages: Unlike other languages, AVAP does not have a hierarchical package system. Each file is imported independently and treated as an autonomous unit.
@ -91,18 +94,19 @@ Consider the following example where multiple files are imported:
Content of the file main.avap Content of the file main.avap
addVar(5, a) addVar(5, a)
import utilities.avap include utilities.avap
import operations.avap include operations.avap
addVar(utilities.increment(a), b) addVar(b, increment(a))
addVar(operations.multiply(b, 2), c) addVar( c, multiply(b, 2))
print(c) addResult(c)
Content of the file utilities.avap Content of the file utilities.avap
def increment(x): function increment(x){
return x + 1 return(x + 1)
}
Content of the file operations.avap Content of the file operations.avap
def multiply(x, y): function multiply(x, y){
return x * y return(x * y)
}
In this example, utilities.avap and operations.avap are imported into main.avap at the specified points, allowing the increment and multiply functions to be used in main.avap. In this example, utilities.avap and operations.avap are imported into main.avap at the specified points, allowing the increment and multiply functions to be used in main.avap.

View File

@ -4,9 +4,9 @@ The IF-THEN-ELSE statement in AVAP™ allows for decision-making based on specif
6.1 Syntax of the IF-THEN-ELSE Statement 6.1 Syntax of the IF-THEN-ELSE Statement
The basic syntax of the IF-THEN-ELSE statement in AVAP™ is as follows: The basic syntax of the IF-THEN-ELSE statement in AVAP™ is as follows:
IF(condition, true_value, operator) if(condition, true_value, operator)
// Block of code if the condition is true ELSE // Block of code if the condition is true else()
// Block of code if the condition is false END() // Block of code if the condition is false end()
condition: This is an expression that evaluates to either true or false. condition: This is an expression that evaluates to either true or false.
true_value: This is the value assigned if the condition is true. true_value: This is the value assigned if the condition is true.
operator: This is the operator used to compare the condition with the true value. operator: This is the operator used to compare the condition with the true value.
@ -17,9 +17,11 @@ Below is the description of each part of the IF-THEN-ELSE statement using the pr
// IF, ELSE and END Sample Use // IF, ELSE and END Sample Use
addVar(selector,'yes') addVar(selector,'yes')
IF(selector,'yes','=') if(selector,'yes','=')
addVar(result,1) ELSE() addVar(result,1)
addVar(result,0) END() else()
addVar(result,0)
end()
addResult(result) addResult(result)
The variable selector is initialized with the value 'yes'. The variable selector is initialized with the value 'yes'.
The statement IF(selector,'yes','=') evaluates whether the value of selector is equal to 'yes'. In this case, the condition is true. The statement IF(selector,'yes','=') evaluates whether the value of selector is equal to 'yes'. In this case, the condition is true.

View File

@ -12,9 +12,9 @@ Example Usage
Below is a practical example illustrating how to use the addParam() function in an API call: Below is a practical example illustrating how to use the addParam() function in an API call:
# API call with addParam() # API call with addParam()
addParam(user, "john_doe") addParam(user, user_var)
addParam(password, "password123") addParam(password, password_var)
In this example, two parameters, user and password, are being added to an API call. The value of user is set to "john_doe" and the value of password is set to "password123". In this example, two parameters, user and password, are being added to an API call. The value of user is set to user_var and the value of password is set to password_var.
Internal Operation Internal Operation
Internally, the addParam() function constructs the querystring for the API call by adding the specified parameters along with their corresponding values. This querystring is passed to the API, which uses it to process the request and return the appropriate response. Internally, the addParam() function constructs the querystring for the API call by adding the specified parameters along with their corresponding values. This querystring is passed to the API, which uses it to process the request and return the appropriate response.

View File

@ -3,14 +3,16 @@ Introduction
Functions in AVAP™ are reusable blocks of code that perform a specific task. Just like in Python, functions in AVAP™ allow for code modularization, improved readability, easier maintenance, and code reuse. Functions in AVAP™ are reusable blocks of code that perform a specific task. Just like in Python, functions in AVAP™ allow for code modularization, improved readability, easier maintenance, and code reuse.
Function Construction Function Construction
In AVAP™, similar to Python, functions are defined using the keyword def, followed by the function name and its parameters in parentheses. The function definition ends with a colon (:), followed by the block of code that forms the function body, indented with four spaces. In AVAP™, similar to Python, functions are defined using the keyword function , followed by the function name and its parameters in parentheses. The function definition ends with a {, followed by the block of code that forms the function body, and closed by }.
Defining a function in AVAP™ Defining a function in AVAP™
def greet(name): function greet(name){
return "Hello, " + name + "!" return("Hello, " + name + "!")
}
Calling the function Calling the function
message = greet("World") message = greet("World")
print(message) addResult(message)
Output Output
Hello, World! Hello, World!
Technical Features Technical Features
@ -22,12 +24,15 @@ Practical Example
Below is a practical example illustrating the definition and invocation of a function in AVAP™: Below is a practical example illustrating the definition and invocation of a function in AVAP™:
Definition of a Function to Calculate the Area of a Circle Definition of a Function to Calculate the Area of a Circle
def calculate_circle_area(radius): function calculate_circle_area(radius){
return 3.14 * radius ** 2 return(3.14 * radius ** 2)
}
Calling the Function Calling the Function
circle_radius = 5 circle_radius = 5
area = calculate_circle_area(circle_radius) area = calculate_circle_area(circle_radius)
print("The area of the circle is:", area) result = "The area of the circle is: %s" % area
addResult(result)
Output: Output:
The area of the circle is: 78.5 The area of the circle is: 78.5
Conclusions Conclusions

View File

@ -1,4 +1,3 @@
Appendix
Function Glossary Function Glossary
randomString() randomString()
The randomString() command generates a random string based on a specified pattern and stores it in a target variable. It is especially useful when random strings are needed to conform to a specific format, such as passwords or identifiers. The randomString() command generates a random string based on a specified pattern and stores it in a target variable. It is especially useful when random strings are needed to conform to a specific format, such as passwords or identifiers.

View File

@ -30,10 +30,12 @@ AVAP™ offers a wide range of features that promote flexibility in programming.
# Example of a higher-order function # Example of a higher-order function
def operation(func, a, b): function operation(func, a, b){
return func(a, b) return(func(a, b))
def add(x, y): }
return x + y function add(x, y){
return(x + y)
}
result = operation(add, 3, 5) result = operation(add, 3, 5)
# The add function is passed as an argument # The add function is passed as an argument

View File

@ -63,10 +63,11 @@ Practical Example
example_variable = 10 example_variable = 10
// Definition of a function // Definition of a function
example_function(parameter): function example_function(parameter){
// Function body // Function body
result = parameter * 2 result = parameter * 2
return result return(result)
}
// Function call // Function call
result = example_function(example_variable) result = example_function(example_variable)

View File

@ -54,9 +54,10 @@ Below is a practical example that illustrates lexical analysis in AVAP™:
// Function definition // Function definition
function_example(parameter): function function_example(parameter){
result = parameter * 2 result = parameter * 2
return result return(result)
}
// Function call // Function call
value = function_example(10) value = function_example(10)

View File

@ -34,15 +34,15 @@ Below is a practical example that illustrates the use of the data model in AVAP
example_list = [1, 2, 3, 4, 5] example_list = [1, 2, 3, 4, 5]
# Accessing individual elements # Accessing individual elements
print(example_list[0]) # Output: 1 addResult(example_list[0]) # Output: 1
# Slicing to get a sublist # Slicing to get a sublist
sublist = example_list[2:4] sublist = example_list[2:4]
print(sublist) # Output: [3, 4] addResult(sublist) # Output: [3, 4]
# List methods # List methods
example_list.append(6) example_list.append(6)
print(example_list) # Output: [1, 2, 3, 4, 5, 6] addResult(example_list) # Output: [1, 2, 3, 4, 5, 6]
Conclusions Conclusions
The data model in AVAP™ provides a flexible and dynamic structure for working with data in the language. By understanding the available data types, data structures, operations, and methods, developers can write efficient and effective code that manipulates and processes data effectively. The data model in AVAP™ provides a flexible and dynamic structure for working with data in the language. By understanding the available data types, data structures, operations, and methods, developers can write efficient and effective code that manipulates and processes data effectively.

View File

@ -35,7 +35,7 @@ value is the initial value to be assigned to the variable.
2.3.3 Direct Initialization 2.3.3 Direct Initialization
It is also possible to declare and initialize a global variable at the same time using the following syntax: It is also possible to declare and initialize a global variable at the same time using the following syntax:
global variable_name=value addVar(variable_name,value)
Where: Where:
variable_name is the name of the variable to be declared. variable_name is the name of the variable to be declared.

View File

@ -33,10 +33,7 @@
"OLLAMA_URL = os.getenv(\"OLLAMA_URL\")\n", "OLLAMA_URL = os.getenv(\"OLLAMA_URL\")\n",
"OLLAMA_LOCAL_URL = os.getenv(\"OLLAMA_LOCAL_URL\")\n", "OLLAMA_LOCAL_URL = os.getenv(\"OLLAMA_LOCAL_URL\")\n",
"OLLAMA_MODEL_NAME = os.getenv(\"OLLAMA_MODEL_NAME\")\n", "OLLAMA_MODEL_NAME = os.getenv(\"OLLAMA_MODEL_NAME\")\n",
"OLLAMA_EMB_MODEL_NAME = os.getenv(\"OLLAMA_EMB_MODEL_NAME\")\n", "OLLAMA_EMB_MODEL_NAME = os.getenv(\"OLLAMA_EMB_MODEL_NAME\")"
"\n",
"config = AutoConfig.from_pretrained(HF_EMB_MODEL_NAME)\n",
"embedding_dim = config.hidden_size"
] ]
}, },
{ {
@ -222,7 +219,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": null,
"id": "8e214f79", "id": "8e214f79",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -263,7 +260,7 @@
"\n", "\n",
"\n", "\n",
"chunks = build_chunks_from_folder(\n", "chunks = build_chunks_from_folder(\n",
" folder_path=\"/home/acano/PycharmProjects/assistance-engine/data/raw/docs\"\n", " folder_path=\"/home/acano/PycharmProjects/assistance-engine/ingestion/docs\"\n",
")" ")"
] ]
}, },

File diff suppressed because one or more lines are too long