mimimiC

mimimiC is a compiler that reads in the C programming language written source codes analyzes, compiles and executes. The goal of this project was it to develop and implement a compiler in programming language C. The compiler is written complete in C and accepts an input language, which is strongly ajar against C programming language. The input language of the compiler is a subset of C. With it the most important features of C are supported. mimimiC is a native multi-pass compiler, and generates RISC code for the virtual machine. The compiler is developed under Linux (Debian), and currently runs only on Linux with 32-bit operating systems.


The keywords are supported by the compiler mimimiC predefined as follows:

Num. Keyword Explanation Num. Keyword Explanation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define IDENTIFIER
#define INT
#define CHAR
#define STRUCT
#define STRUCTCHARACTER
#define ANDOPERATOR
#define CHARACTER
#define NUMERIC
#define STRING
#define IF
#define ELSE
#define WHILE
#define TYPEDEF
#define INCLUDE
#define RETURN
#define ERROR
#define ENDOFFILE
#define HASH
#define ADDITION
#define SUBTRACTION
#define DIVISION
// var and func. id.
// int
// char
// struct
// struct symbol
// &
// a|…z , A| …|Z
// 0|…|9
// string
// if
// else
// while
// typedef
// include
// return
// error
// The end of file
// #
// +
// -
// /
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#define MULTIPLICATION
#define GREATER
#define LESSER
#define LOGICALAND
#define LOGICALOR
#define MODULO
#define DOT
#define COMMA
#define SEMICOLON
#define LOGICALNOT
#define LEFTPARANTHESIS
#define RIGHTPARANTHESIS
#define LEFTBRACKET
#define RIGHTBRACKET
#define LEFTBRACE
#define RIGHTBRACE
#define SINGLEQUOTE
#define DOUBLEQUOTE
#define ASSIGNMENT
#define BACKSLASH
#define NULLCHARACTER
// *
// >
// <
//&&
// ||
// %
// .
// ,
// ;
// !
// (
// )
// [
// ]
// {
// }
// ‘
// „
// =
// \
// null

The output language which is accepted by mimimiC Virtual Machine:

Instruction  Explanation Instruction  Explanation
ADD Addition R[a]=R[b]+R[c]; PSH Push On Stack R[b]=R[b]-c;
int col=(R[b])%4;
memory[R[b]/4][col]=R[a];
SUB Subtraction R[a]=R[b]-R[c]; BEQ Branch If Equal
if(R[a]!=0){nxt=PC+c;}
MUL Multiplication R[a]=R[b]*R[c]; BNE Branch Not Equal
if(R[a]!=0){nxt=PC+c;}
DIV Division if(R[c]!=0){R[a]=R[b]/R[c];} BLT Branch If Less Than
if(R[a]<0){nxt=PC+c;}
MOD Modulo R[a]=R[b]%R[c]; BGE Branch If Greater Than Or Equal
if(R[a]<=0){nxt=PC+c;}
CMP Compare R[a]=R[b]-R[c]; BLE Branch If Less Than Or Equal
if(R[a]==0||R[a]<=0){nxt=PC+c}
OR Logical Or R[a]=(R[b]||R[c]); BGT Branch If Greater Than
if(R[a]>0){nxt=PC+c;}
AND Logical And R[a]=(R[b]&&R[c]); JSR Jump To Subroutine R[31]=PC+1; nxt= c;
ADDI Immediate Addition R[a]=R[b]+c; RET Returnnxt=R[c];
SUBI Immediate Subtraction R[a]=R[b]-c; FOP File Open
ANDI Immediate And R[a]=(R[b]&&c); FCL File Close
LDW Load Word int col=((R[b]+c))%4;
R[a= memory[(R[b]+c)/4][col];
FRD File Read
POP Pop On Stack int col=(R[b])%4;
R[a= memory[R[b]/4][col]; R[b=R[b]+c;
FWR File Write
STW Store Word int col=((R[b]+c))%4;
memory[(R[b]+c)/4][col]=R[a];

Features

  1. Primitive data types und complex data types (int, char, struct, array(int, char))
  2. Control structures (if, else, while) with arbitrary interleaving
  3. Type definitions/Structs (typedef typname aliasname; , typedef struct { int re, int im; } complx; )
  4. Arithmetical and logical operators (+, -, *, /, %, ==, !=, >, < , >=, <= ||, &&)
  5. Combining of brackets for arbitrary infix notation
  6. Error handling for the detection of syntax errors in the source-code
  7. Arrays (one Dimensional)
  8. Pointer(&)
  9. Functions (with Call-by-Value and Call-by-Reference)
  10. File I/O (Is realized by the VM, plus there is the FOP (open), FCL (close), FRD (read), FWR (write))
  11. Separate compilation
  12. Symbol table
  13. EBNF
  14. Heap – Linker
  15. Object-File generation
  16. Virtual Machine
  17. RISC code generation

Detailed information can be found in the Download page.

Y. Özbek, M. Kleber