← Back
x0rma-404

x0rma-404/XR-Extention

View on GitHub ↗
Stars
4
Forks
0
Watchers
4
Open issues
0
Contributors
1
Language
C++
License
MIT License
Default branch
main
Created Oct 1, 2026Updated Oct 1, 2026

Star growth

Today—
This week—
This month—

Star history will appear here once this repo has been tracked for a couple of days.

README

XR Programming Language

A small experimental programming language written in C++
with dedicated Visual Studio Code support.


About

XR is a small experimental programming language built from scratch in C++.

Instead of directly following the syntax of languages such as Python, Java, or C++, XR uses its own syntax and concepts.

The project consists of two main parts:

  • XR Interpreter — executes .xr source files.
  • XR VS Code Extension — provides a complete development environment for XR.

The goal of XR is to experiment with language design, interpreters, syntax, developer tooling, and programming-language concepts while keeping the language simple and distinctive.


Features

Language

  • C++17 interpreter
  • .xr source files
  • Variables
  • Conditional statements
  • Loops
  • Lists
  • Ranges
  • Indexing
  • Slicing
  • Arithmetic operators
  • Comparison operators
  • Logical operators
  • String operations
  • Built-in functions
  • Comments

Visual Studio Code

  • XR language recognition
  • Syntax highlighting
  • Autocomplete / IntelliSense
  • Variable suggestions
  • Built-in function suggestions
  • Code snippets
  • Error diagnostics
  • Problems panel integration
  • XR: Run File command
  • Integrated interpreter execution

XR Syntax

Variables

Variables are declared using the deyer keyword.

deyer -> ad;
deyer -> yas;

Values are assigned using the -> operator.

'Xorma' -> ad;
20 -> yas;

Variables can then be used directly:

> ad;
> yas;

Output:

Xorma
20

Printing

The > operator is used to print a value.

> 'Salam XR!';

Variables can also be printed:

deyer -> ad;

'Xorma' -> ad;

> ad;

Output:

Xorma

Expressions can be printed as well:

> 'Salam ' ~ ad;

Conditions

XR uses ? to define a conditional statement.

? ad = 'Xorma' {
    > 'Dogru';
} : {
    > 'Yanlis';
}

The : block represents the alternative branch.

Example

deyer -> yas;

20 -> yas;

? yas >= 18 {
    > 'Yetkin';
} : {
    > 'Yetkin deyil';
}

Loops

XR uses @ for loops.

A condition can be used directly:

@ x < 5 {
    > x;
}

XR can also iterate over a list:

@ x : #[1, 2, 3] {
    > x;
}

Output:

1
2
3

Lists

Lists use the #[ ] syntax.

#[1, 2, 3, 4, 5]

A list can be assigned to a variable:

deyer -> nums;

#[1, 2, 3, 4, 5] -> nums;

Lists can contain different values depending on the interpreter's supported types.


Indexing

List elements are accessed using ..

deyer -> nums;

#[10, 20, 30] -> nums;

> nums.0;
> nums.1;
> nums.2;

Output:

10
20
30

Variable Index

Indexes can also be stored in variables:

nums.i

Expression Index

Expressions can be used as indexes:

nums.(i + 1)

Slicing

XR supports selecting a section of a list using ranges.

nums.(1..3)

The general syntax is:

start..end

For example:

deyer -> nums;

#[10, 20, 30, 40, 50] -> nums;

> nums.(1..3);

Ranges

Ranges are represented using ...

1..5

Ranges can be used with loops:

@ x : 1..5 {
    > x;
}

Output:

1
2
3
4
5

Operators

XR provides operators for arithmetic, comparison, logical operations, concatenation, power, and assignment.

Arithmetic

Operator Operation
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo

Example:

5 + 3
10 - 2
4 * 5
20 / 4
10 % 3

Power

The ^ operator is used for power / repetition.

2 ^ 3

Comparison

Operator Meaning
= Equal
<> Not equal
< Less than
> Greater than
<= Less than or equal
>= Greater than or equal

Example:

10 > 5
10 = 10
5 <> 3

Logical Operators

Operator Meaning
& AND
| OR
! NOT

Example:

x > 5 & x < 10

Concatenation

The ~ operator combines values.

'Salam ' ~ 'XR'

Output:

Salam XR

Variables can also be combined:

deyer -> ad;

'Xorma' -> ad;

> 'Salam ' ~ ad;

Assignment

The -> operator assigns a value to a variable.

5 -> x;

For example:

deyer -> x;

10 -> x;

Built-in Functions

XR currently provides the following built-in functions:

Function Purpose
uz() Returns the length of a value
qat() Combines two values
cixar() Performs subtraction
metn() Converts a value to text
eded() Converts a value to a number
sirala() Sorts a list
boyuk() Returns the larger value
kicik() Returns the smaller value
bol() Performs division
yig() Returns the sum of list values
var() Checks whether a value exists

uz()

Returns the length of a value.

> uz('XR');

qat()

Combines two values.

> qat('Hello', 'XR');

cixar()

Performs subtraction.

> cixar(10, 3);

metn()

Converts a value to text.

> metn(123);

eded()

Converts a value to a number.

> eded('123');

sirala()

Sorts a list.

> sirala(#[5, 2, 8, 1]);

boyuk()

Returns the larger value.

> boyuk(10, 20);

kicik()

Returns the smaller value.

> kicik(10, 20);

bol()

Performs division.

> bol(20, 4);

yig()

Returns the sum of values in a list.

> yig(#[1, 2, 3, 4]);

var()

Checks whether a value exists.

> var(x);

Comments

Comments begin with //.

// This is an XR comment

deyer -> ad;

Comments are ignored by the interpreter.


Strings

XR uses single quotes for strings.

'Salam XR!'

Strings can be combined using ~.

'Hello' ~ ' XR'

Output:

Hello XR

Complete Example

// XR example

deyer -> ad;
deyer -> nums;

'Xorma' -> ad;
#[1, 2, 3, 4, 5] -> nums;

> 'Salam ' ~ ad;

? ad = 'Xorma' {
    > 'Dogru ad';
} : {
    > 'Yanlis ad';
}

@ x : nums {
    > x;
}

Output:

Salam Xorma
Dogru ad
1
2
3
4
5

Visual Studio Code Extension

XR comes with a dedicated Visual Studio Code extension designed to make .xr development easier.

The extension provides:

  • .xr language recognition
  • Syntax highlighting
  • Autocomplete
  • Variable suggestions
  • Built-in function documentation
  • Code snippets
  • Error diagnostics
  • Problems panel integration
  • XR interpreter execution

Syntax Highlighting

XR source files are automatically recognized as .xr files.

The syntax definition is located at:

vscode-extension/syntaxes/xr.tmLanguage.json

It provides highlighting for:

  • Keywords
  • Variables
  • Strings
  • Numbers
  • Operators
  • Comments
  • Built-in functions
  • Control structures

Autocomplete

The extension provides autocomplete for:

  • XR keywords
  • Built-in functions
  • Operators
  • Snippets
  • Declared variables

For example:

deyer -> ad;
deyer -> yas;

'Xorma' -> ad;
20 -> yas;

After declaring a variable, it can appear in autocomplete suggestions.

Built-in functions can also display documentation:

uz(value)

Dəyərin uzunluğunu qaytarır

Snippets

XR provides snippets for frequently used structures.

Conditional

Typing:

if

can generate:

? sert {
    
} : {
    
}

Loop

Typing:

loop

can generate:

@ sert {
    
}

Foreach

Typing:

foreach

can generate:

@ x : siyahi {
    
}

Error Diagnostics

Interpreter errors can be displayed directly inside Visual Studio Code.

For example:

> ad2;

If ad2 has not been declared, the interpreter can report:

Xeta: teyin olunmamis deyisen: ad2

The extension can forward interpreter errors to the Problems panel, making errors easier to locate while developing.


Running the Interpreter

The XR interpreter is written in C++17.

Compile

g++ -std=c++17 xr.cpp -o xr.exe

Run

xr.exe hello.xr

For example:

xr.exe examples/hello.xr

Running XR in Visual Studio Code

Open the VS Code extension project.

Press:

F5

This launches the Extension Development Host.

Create or open an .xr file.

Then open the Command Palette:

Ctrl + Shift + P

Search for:

XR: Run File

Press Enter.

The extension will execute the current XR file using the XR interpreter.


Project Structure

XR/
│
├── interpreter/
│   ├── xr.cpp
│   └── xr.exe
│
├── vscode-extension/
│   ├── package.json
│   ├── extension.js
│   ├── language-configuration.json
│   ├── xr.exe
│   │
│   ├── snippets/
│   │   └── xr.json
│   │
│   └── syntaxes/
│       └── xr.tmLanguage.json
│
├── examples/
│   ├── hello.xr
│   ├── variables.xr
│   ├── conditions.xr
│   └── loops.xr
│
└── README.md

Examples

Example programs can be found in:

examples/

Current examples include:

hello.xr
variables.xr
conditions.xr
loops.xr

These examples demonstrate the basic features of the language.


Development

Interpreter

The XR interpreter is implemented in:

interpreter/xr.cpp

VS Code Extension

The extension logic is implemented in:

vscode-extension/extension.js

Language Definition

Syntax highlighting is defined in:

vscode-extension/syntaxes/xr.tmLanguage.json

Snippets

Code snippets are located at:

vscode-extension/snippets/xr.json

Project Status

XR is currently an experimental programming language project.

The current version includes:

  • A working C++ interpreter
  • A custom programming-language syntax
  • .xr source files
  • Lists and ranges
  • Conditions and loops
  • Built-in functions
  • VS Code syntax highlighting
  • Autocomplete
  • Snippets
  • Diagnostics
  • File execution through VS Code

The language and development tools are still evolving, and syntax or features may change in future versions.


Roadmap

Potential future improvements include:

  • User-defined functions
  • More data types
  • Better type handling
  • Improved error messages
  • More advanced IntelliSense
  • Debugging support
  • Package / module system
  • Standard library
  • Better runtime error locations
  • XR language server
  • Cross-platform interpreter builds
  • VS Code Marketplace release

Why XR?

XR is not intended to replace established programming languages.

It is a project for exploring how a programming language works from the inside:

Source Code
     │
     ▼
   Lexer
     │
     ▼
   Parser
     │
     ▼
 Interpreter
     │
     ▼
   Output

At the same time, the VS Code extension demonstrates how a custom language can be integrated into a modern development environment.


Author

Xorma

GitHub:

x0rma-404


License

This project is licensed under the MIT License.