Skip to content

ober-man/Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Compiler project

This project consist of 3 level:

  • 1 level - very simple Turing-complete language and its interpretator.
  • 2 level - add variable declarations, code division by functions and functions call support.
  • 3 level - add code generation with using LLVM IR.

How it works

  • parse input file with using regular expressions (Flex) and grammatics (Bison)
  • make an AST (Abstract Syntax Tree)
  • code generation from the AST to LLVM IR
  • link libraries and make an executable file with using clang++ compiler

Language reference

To see examples, go to the tests folder.

Variables and arithmetic
var x = 1;
var y;
y = 5 + 6*x;
Input-output
x = scan();
print(x*x);
If-construction
var x = scan();
if x < 10
{
  print(x);
}
While-construction
while (x < 10)
{
  x = x + 1;
  print(x);
}
Functions
func sqr(x)
{
  return x*x;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published