Syntax

A comprehensive guide to XXML syntax, including keywords, operators, and code structure.

Keywords

XXML uses the following reserved keywords:

importNamespaceClassEnumerationValueFinalExtendsNonePublicPrivateProtectedPropertyTypesConstructordefaultMethodReturnsParametersParameterEntrypointInstantiateAsRunForWhileIfElseExitReturnBreakContinueLambdatruefalseCompiletimeTemplatesConstrainsSetDo

Comments

XXML supports single-line comments:

xxml
// This is a single-line comment

Identifiers

Identifiers in XXML follow these patterns:

TypePatternExample
Regular[a-zA-Z_][a-zA-Z0-9_]*MyClass, counter
Angle-bracketed<identifier><name>, <age>
QualifiedNamespace::Class::MemberLanguage::Core::String

Note

Angle-bracketed identifiers like <name> are used for variable declarations, method names, and parameters. This syntax makes declarations visually distinct from usage.

Literals

Integer Literals

xxml
42i      // With suffix
123      // Without suffix

String Literals

xxml
"hello"
"hello\nworld"  // Escape sequences supported

Boolean Literals

xxml
true
false

Operators

CategoryOperatorsDescription
Arithmetic+ - * / %Math operations
Comparison== != < > <= >=Value comparison
Logical&& || !Boolean logic
Assignment=Value assignment
Member Access. ::Instance/static access
Range..Range creation (exclusive end)
Arrow->Block introduction
Ownership^ & %Owned, reference, copy

Program Structure

Imports

Import modules using the #import directive:

xxml
#import Language::Core;
#import Language::Collections;
#import Language::IO;

Namespaces

Organize code into namespaces:

xxml
[ Namespace <MyApp>
    // Declarations go here
]

[ Namespace <Outer::Inner>
    // Nested namespace
]

Entrypoint

Every XXML program requires an entrypoint:

main.xxml
[ Entrypoint
    {
        // Program starts here
        Run Console::printLine(String::Constructor("Hello!"));
        Exit(0);
    }
]

Tip

The Exit(0) call is required to terminate the program with an exit code. Use 0 for success and non-zero for errors.

Statements

Variable Declaration

Declare variables using the Instantiate keyword:

xxml
// Syntax: Instantiate Type As <variableName> = initializer;

Instantiate Integer^ As <x> = Integer::Constructor(42);
Instantiate String^ As <name> = String::Constructor("Alice");
Instantiate Bool^ As <active> = Bool::Constructor(true);

Assignment

Reassign variables using the Set keyword:

xxml
Set variableName = expression;
Set counter = counter.add(Integer::Constructor(1));

Function Calls

Execute functions using the Run keyword:

xxml
Run Console::printLine(message);
Run object.method(args);
Run list.add(item);

Control Flow

For Loop

xxml
// Range-based for loop (exclusive end)
For (Integer^ <i> = 0 .. 10) ->
{
    Run Console::printLine(i.toString());
}

While Loop

xxml
While (condition) ->
{
    // Loop body
}

If/Else

xxml
If (condition) -> {
    // Then branch
} Else -> {
    // Else branch
}

Warning

Note that XXML uses -> arrows after conditions and loop declarations. This is different from C-style syntax.

Return and Exit

xxml
Return value;    // Return from method
Return;          // Return None
Exit(0);         // Exit program with code

Next Steps

Now that you understand the basic syntax, learn about XXML's type system and ownership semantics.