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.
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
If you want to contribute to MercuryLang, please check out our GitHub repository. We welcome contributions from anyone!
To contribute, follow these steps:
If you have any questions or feedback, please feel free to contact us at My Github