This is the official repository for RLox.
RLox is a programming language written in Rust, solely designed to make memes.
rlox
in the terminal to start repl mode which looks like :
You can run your file simply by typing rlox [file name]
replace file name with your file name example:
.tokenfile | Code |
---|---|
![]() |
![]() |
Output -> | ![]() |
You can change keywords if you want
.tokenfile | Code |
---|---|
![]() |
![]() |
Output -> | ![]() |
yes this is similar to bhialang you can find the preset for this in presets folder you can also add your presets to this repository for others to use refer contribution guidelines to raise pr.
my personal favourite:
.tokenfile | Code |
---|---|
print : hello_world |
hello_world "print" |
Output -> | print |
Windows: Check the releases section.
Linux: You will figure out how to build this project dont worry.
Mac: We recommend using an emulator. Just ignore the overheating and random crashes.
start of the file is the entrypoint for the program.
// your code
// anything after '//' is comment
/* This is for multiline comment */
Variables can be declared using var
.
var a = 5 ;
var b = 6.9 ;
var c = "Hello World";
var d = true ;
var e = false ;
var f ;// nil is assigned by default
Numbers strings and boolean are like other languages. Null values can be denoted using nil
.
var a = 5 ; //integer
var b = 6.9 ; //float
var c = "Hello World"; //string
var d = true ; // boolean
var e = false ; // boolean
var f ; // nil is assigned by default
Use print
to print anything to console.
var a = 5;
print a ; //prints a to the terminal adds a \n by default so you don't have to manually
RLox supports if else blocks if
block execute only if condition given is true
. else block is optional and only executes if condition given is false
.RLox also supports and
and or
logical operator.
var a = 5 ;
if (a == 5){
print a ;
}
else {
print b ;
}
Statements inside while
blocks are executed as long as a specified condition evaluates to true
. If the condition becomes false
, statement within the loop stops executing and control passes to the statement following the loop.
var a = 0;
while (a<10){
a = a + 1;
if (a==5){
print a ;
}
}
.tokenfile
file in your directory. If the file exists, it replaces reserved keywords with the tokens defined in the file.
Make sure the tokens you replace are listed below:
- Pattern to replace tokens is as follows:
- Native_Token_Name : Your_Desired_Token_Name
- Note: Token names should be alphanumeric and can contain underscores between them.
- var
- true
- false
- nil
- if
- else
- or
- and
- while
- for
- class
- fun
- super
- this