MercuryLang

Welcome to MercuryLang

Welcome to MercuryLang — a free and open-source lightweight interpreter written in C++, inspired by the simplicity of Python. MercuryLang is designed to offer clean, readable, and expressive syntax, making it an ideal choice for developers of all experience levels.

Why MercuryLang?

Getting started

Before you download MercuryLang, make sure you have:

Once you have these prerequisites, you can download MercuryLang from the link above. After downloading, follow the installation instructions in the README file.

Syntax

MercuryLang has a simple and easy-to-read syntax. Here are some examples:


# Hello World program in MercuryLang
print("Hello, World!")
            

The code above prints "Hello, World!" to the console.

This is for variable name of variable dont start with number and only support alpha or "_"


# Variable declaration
LET x = 10
LET y = 20
            

This is for function and function call


# Function declaration
FUNC foo() DO
    print("Hello from foo!")
END

foo() 
            

This is for math operator


# Math operations
LET a = 10
LET b = 20

a + b # Addition
a - b # Subtraction
a * b # Multiplication
a / b # Division
            

Comparison operator


# Comparison operations
LET a = 10
LET b = 20

a == b # Equality
a != b # Inequality
a > b  # Greater than
a < b  # Less than
a >= b # Greater than or equal to
a <= b # Less than or equal to
            

This is for if statement


# If statement
LET a = 10
LET b = 20
IF a > b THEN
    print("a is greater than b")
END
            

Assignment expression


# Assignment expression
LET a = 10
a = a + 5
            

This is for while statement


# While loop
LET i = 0
WHILE i < 10 DO
    print(i)
    i = i + 1
END
            

Example for what MercuryLang can do


# TODO: print the number from 1 to 100 that divisible by 2

LET max = 100
LET number = 0

WHILE number <= max DO
    IF number % 2 == 0 THEN
        print(number)
    END
    number = number + 1
END
            

Contribute

If you want to contribute to MercuryLang, please check out our GitHub repository. We welcome contributions from anyone!

To contribute, follow these steps:

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Commit your changes
  5. Push to the branch
  6. Create a pull request

Contact

If you have any questions or feedback, please feel free to contact us at My Github