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

Variables and Data

In Ulto, variables and data handling are designed to support both traditional and reversible programming paradigms. The language's approach to memory management ensures that variables can be assigned new values without losing their previous states, making it easier to revert operations if needed.

1. Variables

Variables in Ulto are declared and assigned values using typical syntax. However, unlike conventional languages where variable assignment is a destructive process, Ulto preserves the history of each variable's state using a log stack.

Example: Variable Assignment

x = 10
x += 5
print(x)  # Outputs: 15

In this example, x is first assigned the value 10 and then incremented by 5. The current value of x is 15.

Grammar Rule: Assignment

assignment
    : ID ASSIGN expression
    | ID PLUS_ASSIGN expression
    | ID MINUS_ASSIGN expression
    | ID TIMES_ASSIGN expression
    | ID OVER_ASSIGN expression
    ;

This grammar rule defines how variable assignments are structured in Ulto. It shows that an assignment consists of an identifier (ID), followed by an assignment operator (=, +=, etc.), and an expression.

2. Data Types

Ulto supports various data types, including numbers and strings. The language's syntax for working with these data types is straightforward, making it easy to perform operations on variables.

Example: Data Types

num = 42
text = "Hello, World!"
print(num)  # Outputs: 42
print(text)  # Outputs: Hello, World!

Here, num is an integer, and text is a string. Both variables are printed, showing their respective values.

Grammar Rule: Primary Expressions

primaryExpression
    : NUMBER
    | STRING
    | TRUE
    | FALSE
    | ID
    ;

This grammar rule specifies how primary expressions are formed, including numbers, strings, booleans, and identifiers. These are the basic building blocks for more complex expressions.

3. Memory Management

Memory management in Ulto is enhanced by the use of a log stack, which records every change made to a variable. This ensures that no information is destroyed during the execution of a program, allowing for easy reversal of operations.

Example: Non-destructive Assignment

y = 50
y /= 2
print(y)  # Outputs: 25

Even though y is divided by 2, the original value is preserved in the log stack, allowing for potential reversal if needed.