Skip to content

samueldsr99/rotom-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Rotom Programming language

rotom pet

Yes, the pokemon

This is an in progress implementation of a js transpiled programming language, it aims to have a simply yet powerful syntax.

Usage

python3 rotomc.py path/to/file

Help

python3 rotomc.py --help

Example:

fn fact(x) -> 1 if x == 0 else x * fact(x - 1)

fn main() {
    let mut i = 0;
    let n = 5;
    while i < n {
        print "fact(" + i + "): " + fact(i);
        i = i + 1;
    }
}

JS transpilation:

function fact(x) {
  return x === 0 ? 1 : x * fact(x - 1);
}

function main() {
  let i = 0;
  const n = 5;
  while (i < n) {
    console.log("fact(" + i + "): " + fact(i));
    i = i + 1;
  }
}

main();

Output:

1/2 Transpiling...
1/2 Transpilation succeded
2/2 Writing js file...
2/2 🥳 Finished!!!

fact(0): 1
fact(1): 1
fact(2): 2
fact(3): 6
fact(4): 24

Examples

Check out /examples/code for more examples

Releases

No releases published

Packages

No packages published

Languages