Home

Awesome

CsGo

Introduction

The CsGo compiler compiles a self-designed language with features in both C and Golang, using flex, bison and LLVM.

Features

Install

To install, first download the project by

git clone https://github.com/xinyu-evolutruster/CsGo-Compiler.git

Then run

cd ./src

to the main directory. Compile the project by running

make
# the compiler program is named 'mini'

To compile your program, run

./mini {filename}.gc
clang {filename}.o -o filename.out

Grammar Rules

variable declaration:

int num;
int arr[100];

variable assignment:

num = 1;
i, j, k = 1, 2, 3;
i, j, k = begin, end, arr[begin];

function declaration:

// func {func_name}({var_name}{var_type}, ...)(ret {var_type})

func main(void)(ret int);
func qsort(arr[] int, begin int, end int)(void);

I/O operations:

scanf("%d", len);
printf("%d\n", arr[i]);

conditional statements:

if(i<j){
  arr[i]=arr[j];
}

loop statements:

while(i<j){
  arr[i]=key;
  i=i+1;
}

macros:

#define ZERO 0
#define index(i,j,N) (i*N+j)

To learn more about the CsGo language, check ebnf.md to see all definitions.

File Description