Skip to content

gaurav-foroll/RLox

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

26 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

RLox

This is the official repository for RLox.

RLox is a programming language written in Rust, solely designed to make memes.

Usage

REPL: Type rlox in the terminal to start repl mode which looks like :

Repl Preview

You can run your file simply by typing rlox [file name] replace file name with your file name example:

.tokenfile Code
Empty tokenfile code
Output -> Output

You can change keywords if you want

.tokenfile Code
Empty tokenfile code
Output -> 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

Installation

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.

Documentation

General

start of the file is the entrypoint for the program.

// your code
// anything after '//' is comment
/* This is for multiline comment */ 

Variables

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

Types

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

Built-ins

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

Conditionals

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 ;
}

Loops

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 ;
    }
}

Dynamic Scanner

When scanning the code, RLox's scanner looks for 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.

Tokens

  • var
  • print
  • true
  • false
  • nil
  • if
  • else
  • or
  • and
  • while
  • for
  • class
  • fun
  • super
  • this

About

Fun Interpreter ๐Ÿ˜…

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%