CASE STUDYSystems · compiler

ShiftC Compiler

A metamorphic compiler written in C with Flex and Bison.

CCompilerFlexBisonLexerParserASTIR
01

Screenshots

02

The problem

A compiler that does more than translate: ShiftC reads programs written in its own language, ShiftLang (.sc), and transforms the code through lexical analysis, parsing, IR generation and code mutation before emitting C.
03

What it does

  • 01Lexical analysis with Flex and parsing with Bison, building an AST
  • 02Intermediate representation with semantic checks and a symbol table
  • 03Code mutation: variable renaming and junk-code insertion
  • 04C code generation from the AST
  • 05Full documentation for every stage in a Z_DOCS folder
04

How it works

  1. 1

    Lexer — tokenises the .sc source.

  2. 2

    Parser — applies the grammar and builds the AST.

  3. 3

    IR — semantic checks and symbol table.

  4. 4

    Mutate — renames variables and inserts junk code.

  5. 5

    CodeGen — turns the tree back into C code that can be compiled and run.

05

ShiftLang

set x = 10
set y = x + 5
if (x > y) {
    print (x)
}
06

Tech stack

Language
C
Lexer / parser
Flex 2.6+, Bison 3.8+
Build
GCC 15+, Make
Platform
Linux