Implementing a complete Compiler for a simple C-like language using the C-tools Flex and Bison
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
Abstract Syntax Tree Management
Abstract Syntax Tree Structure
Action Rules for Declarations and Initializations
Action Rules for Expressions
Action Rules for Function Calls
Action Rules for Function Declarations
Action Rules for If-Else Statements
Action Rules for Loop Statements and some Fixes
Action Rules for Simple Statements and Assignments
Bison example
Combining Flex and Bison
Datatype attribute for Expressions
Finishing Off The Grammar-Parser-part1
Finishing Off The Grammar-Parser-part2
Function Semantics part 1
Function Semantics part 2
Lexical Analysis using Flex
Passing information from Lexer to Parser
Revisit Queue and Assignment Checking
Revisit Queue and Parameter Checking
Scope Resolution
Simple C Language
Symbol Table and Lexer
Type Checking for Assignments
Type Declaration and Checking


A short Description of this repository:
It contains all the Code from my "Writing a simple Compiler on my own" series on Steemit (step by step / article by article), where we are implementing a complete Compiler for a simple C-like Language using the C-tools Flex and Bison.

It's worth noting that not all articles contain actual Code.
Compiler design in general is mostly about understanding how everything needs to work.
After understanding the basic principle, the implementation is much easier, which is why some articles are 90% theory!

Until now we covered:
-Compiler design in general (introduction) ->
-The simple C-like Language ->
-Lexical Analysis and the implementation of a simple Lexer using Flex ->
-The basic implementation/structure of a Symbol Table ->
-Using the Symbol Table in the Lexer ->
-Syntax Analysis Theory needed->
-Bison tool basics / tutorial ->
-Creating a Grammar for the Language by also implementing a first Parser ->
-Combining Flex and Bison ->
-Passing information from the Lexer to the Parser ->
-Finishing Off the Grammar/Parser (part 1) ->
-Finishing Off the Grammar/Parser (part 2) ->
-Semantic Analysis Theory ->
-Semantics Examples ->
-Scope Resolution using Symbol Table ->
-Type Declaration and Checking ->
-Function Semantics (part 1) ->
-Function Semantics (part 2) ->
-Abstract Syntax Tree Principle ->
-Abstract Syntax Tree Structure ->
-Abstract Syntax Tree Management ->
-Action Rules for Declarations and Initializations ->
-Action Rules for Expressions ->
-Action Rules for Assignments and Simple Statements ->
-Action Rules for If-Else Statemenets ->
-Action Rules for Loop Statements and some Fixes ->
-Action Rules for Function Declarations (part 1) ->
-Action Rules for Function Declarations (part 2) ->
-Action Rules for Function Calls ->
-Datatype attribute for Expressions ->
-Type Checking for Assignments ->
-Revisit Queue and Parameter Checking (part 1) ->
-Revisit Queue and Parameter Checking (part 2) ->
-Revisit Queue and Parameter Checking (part 3) ->
-Revisit Queue and Parameter Checking (part 4) ->
-Revisit Queue and Assignment Checking (part 1) ->

What remains now is:
-Semantic analysis which includes creating and using even more semantic and so action rules in Bison
-Final machine code generation in MIPS Assembly

After doing all that we could also get into Optimizations, Extensions and even more if you like :)