1.1.1 • Published 1 year ago

@rinkadev/rang v1.1.1

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

RANG

RANG is a JavaScript transpiled programming language, the goal of this project is convert JavaScript to a more friendly-language.

The file extension of Rang codes is .rang.

If there is a thing that you don't like with Rang, you can just use that like JavaScript (ex: "i dont like then/end system", so use normal javascript braces lol)

Docs: https://rinkagi.github.io/Rang/

Install NPM rang package: npm i -g rang Use NPX Rang command: npx rang --help

TO-DO:

  • More source organization (separate systems)
  • Add a time system
  • Add support to non-main class.
  • Code explanation in README.md
  • Documentation
  • Logo
  • NPM Package
  • FIRST OFFICIAL RELEASE 🎉🎉🎉

  • Operators and conditionals

  • Change the name of output.js generated file to the original rang file.

Do you have a suggest? Add it to issues

EXAMPLES:

Hello world!

class Main then
    Main() then
        Console.Print("Hello world");
    end
end

For VS While

// Example program: Which is faster, for or while.

class Main then
    Main() then
        Time.StartConsoleTimer("for")

        for (let i = 0; i > 10; i++) then

        end

        Time.EndConsoleTimer("for")


        Time.StartConsoleTimer("while")

        let i = 0

        while (i > 10) then
            i++
        end

        Time.EndConsoleTimer("while")
    end
end

No Main Entry Point

Console.Print("This is a program written in Rang without use the Main class")

Rang code explanation

  • rang/index.js:

    • Interpreter class It uses the child_process func: spawn for execute JavaScript files.
    • getCode function It uses fs for read the .rang script, if it the script is not found, throw an error.
    • handleArgs function It reads the args received from terminal call. It verify what func is calling (run, transpile or help) and returns something. If its run, it will parse it and execute it (with Interpreter class)
  • rang/parser.js

    • Parser class It has the methods: constructor, parseEverything, checkString and parsing methods. The parsing methods follows 2 types of ways to parse it. The first type is making a for that go with every line checking if a word is in the script, if it is, replace it to JavaScript. Second type is to include systems (rang/systems/). Just call the systems and get the code.
    • parseEverything method it calls every parse method.
    • addEntryPoint method Is a combination of 2 ways mentioned. If it detects "class Main " in a line. It will add the Entry Point support.
    • parseCatchKeyword method It uses the first type mentioned. It changes catch -> except.
    • parseOpenBrace and parseCloseBrace methods First type mentioned.
    • addConsoleClass and addTimeClass methods Second type mentioned.
  • rang/systems/classes/Console.js

    • Almost every static method It calls a console function depending on what method. In some methods it uses ...args, if there is a function that needs an unkown arg, i use ...args.
    • getString method It returns the code of the system.
  • rang/systems/classes/Time.js

    • Almost every static method It calls a Date function or console depending on what method. In some methods it uses ...args, if there is a function that needs an unkown arg, i use ...args.
    • getString method It returns the code of the system.

Differences from JS

RangJavaScriptWhy?
Main entry point (Main class with Main method class and not compulsory)No main entry pointMore organized code
then / end{ }More readable code for new programmers
Console classconsole classConsole class is console class adapted for NodeJS and new programmers
except keywordcatch keywordMore understable for new programmers
Time classDate class and console functionsWe can use most used JavaScript time tools in just one class.
equal to operator== OperatorLess symbols
greater than operator> OperatorLess symbols
greater equal than operator>= OperatorLess symbols
less than operator< operatorLess symbols
less equal than operator<= operatorLess symbols
and operator== operatorLess symbols
or operator|| operatorLess symbols
not operator! operatorLess symbols
type oftypeofidk
1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago