Skip to content

onkarverma975/FlatB-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlatB Compiler

FlatB is a very basic language built to explore the concepts of compiler design and implementation.

The following are the various features.

  1. Data Types

Inegers and Array of Integers.

int data, array[100]; int sum;

All the variables have to be declared in the declblock{....} before being used in the codeblock{...}. Multiple variables can be declared in the statement and each declaration statement ends with a semi-colon.

array can be accesseed using an arithmetic expression between square brackets

  1. Expressions

    There are two kinds of expressions 1. Arithmetic (Ouput is a number) 2. Boolean (Output is of bool type)

  2. for loop

for i = 1, 100 { ..... }

for i = 1, 100, 2 { ..... }

for var_name = Arith_Expr , Arith_Expr, Arith_Expr {//code block

}

  1. if-else statement

    if bool_expression { .... } ....

    if bool_expression { ... } else { .... }

  2. while statment

    while bool_expression {

    }

  3. conditional and unconditional goto

    got label

    goto label if bool_expression

  4. print/read

    print "blah...blah", val println "new line at the end" read sum read data[i]