Skip to content

nivekithan/compiler

Repository files navigation

Typescript Compiler

This is a small Educational compiler which I created to apply my knowledge of compilers. I have also written a lot of comprenhsive test to make sure compiler works as it expected.

It converts a small subset of typescript language to Native code using LLVM backend.

As it is a eductioncal compiler I have not added any support for error reporting meaning that if your code has syntax error, instead of reporting it. It will die with an error message that you can't understand.

As of now these are the supported syntax

  1. Const variable declaration
const a = 1;
const b: number = 1;
  1. Let variable declaration
let a = 1;
let b: number = 1;
  1. Uniary expressions
!true + 1 - 1;
  1. Binary expressions
1 + 1;
1 - 1;
1 * 1;
1 / 1;
1 === 1;
1 !== 1;
1 <= 1;
1 >= 1;
1 < 1;
1 > 1;
  1. If block, else if block, else block
if (true) {
  doSomething();
} else if (true) {
  doSomethingElse();
} else {
  doSomethingDefault();
}
  1. While loop, do While loop.
while (true) {
  willRunAlways();
}

do {
  willRunOnce();
} while (false);
  1. Function declaration (only at top level)
function nameOfFunction(arg1 : boolean, arg2 : number) {
    return 1;
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published