Documentation

This documentation provides an in-depth guide to the Ulto programming language. Use the navigation links below to explore detailed sections on Variables and Data, Control Structures, and Reversibility in Ulto. Each section includes grammar rules, code examples, and comprehensive descriptions to help you understand the key features of the language.

For detailed docstring for the codebase you can visit on the link below

Control Structures

Control structures in Ulto allow developers to direct the flow of program execution. These structures include conditionals, loops, and other branching mechanisms that enable dynamic decision-making within the code.

1. Conditionals

Ulto supports conditional statements using if, elif, and else. These statements allow the program to execute certain blocks of code based on the evaluation of expressions.

Example: If-Else Statement

if x > 10:
    y = 20
elif x == 10:
    y = 15
else:
    y = 5

This code evaluates the value of x and assigns a value to y based on the condition. If x is greater than 10, y becomes 20; if x equals 10, y becomes 15; otherwise, y is set to 5.

Grammar Rule: If Statement

ifStatement
    : IF expression block (ELIF expression block)* (ELSE block)?
    ;

This rule defines the structure of an if statement in Ulto. It shows that an if statement can include multiple elif branches and an optional else branch, each associated with a block of code.

2. Loops

Loops in Ulto allow the execution of a block of code multiple times. The language provides both for and while loops to handle repetitive tasks.

Example: For Loop

for i in range(0, 5):
    print(i)

This loop iterates from 0 to 4, printing each number. The range function generates the sequence of numbers.

Grammar Rule: For Loop

forLoop
    : FOR ID IN iterable block
    ;

This rule defines the structure of a for loop in Ulto. The loop iterates over an iterable object, executing a block of code for each item in the sequence.

Example: While Loop

x = 5
while x > 0:
    print(x)
    x -= 1

This loop continues to execute as long as x is greater than 0. It prints the value of x and then decrements it by 1 in each iteration.

Grammar Rule: While Loop

whileLoop
    : WHILE expression block
    ;

This rule defines the structure of a while loop in Ulto. The loop repeatedly executes a block of code as long as the specified expression evaluates to true.

3. Combining Conditionals and Loops

Ulto allows conditionals and loops to be combined for more complex control flow. This can be useful in scenarios where the loop's execution depends on a condition.

Example: Nested Conditionals and Loops

for i in range(1, 11):
    if i % 2 == 0:
        print(f"{i} is even")
    else:
        print(f"{i} is odd")

This code iterates through numbers 1 to 10. It checks if each number is even or odd and prints the appropriate message.