Skip to content

Keyword Reference

Keywords are reserved words that have a special meaning in XE. They cannot be used as variable names or function names.

All Reserved Keywords

KeywordCategoryPurpose
funDeclarationsDefine a new function
functionDeclarationsAlias for fun (legacy support)
ifControl FlowStart a conditional block
elifControl FlowAdd a conditional branch to an if statement
elseControl FlowFallback branch for an if statement
whileLoopsStart a conditional loop
forLoopsIterate over a list or text
inLoopsUsed in the for loop syntax
repeatLoopsStart a fixed-count loop
timesLoopsUsed in the repeat loop syntax
breakLoopsExit the current loop immediately
continueLoopsSkip to the next iteration of the loop
andLogicLogical AND operator
orLogicLogical OR operator
notLogicLogical NOT operator
trueLiteralsBoolean true value
falseLiteralsBoolean false value
returnFunctionsReturn a value from a function
importModulesImport an entire module
fromModulesImport specific names from a module

Details by Category

Declarations

  • fun: The primary keyword for defining functions. Example: fun add(a, b):.
  • function: A legacy alias for fun.

Control Flow

  • if, elif, else: Used to build decision logic. XE requires a colon : after the condition and an indented block for the body.

Loops

  • while: Repeats a block as long as a condition is true.
  • for ... in ...: Iterates through every element in a list or every character in a text value.
  • repeat ... times: A high-level loop for repeating an action a specific number of times.
  • break: Stops the execution of the innermost loop.
  • continue: Skips the current iteration and goes to the next check/value in the loop.

Logical Operators

  • and: Returns true if both operands are true.
  • or: Returns true if at least one operand is true.
  • not: Inverts a boolean value.

Module System

  • import: Used to load another .xe file as a module.
  • from: Used to pull specific functions out of a module into the current namespace.

Reserved Word Rule

If you try to use a keyword as a name, XE will report a syntax error during the parsing phase.

xe
# This will fail
if = 10

Error: expected expression at line 2, column 4

Pre-alpha language project built for learning and experimentation.