catarinacps / ccompiler

Repository dedicated to the final assignment of INF01147.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ccompiler

Hi! In this repository you’ll find the final assignment of INF01147: a compiler implemented in the C language using flex, bison and other friends.

Table of contents

Planning

The project will span through the following stages:

StageDescription
E1Lexical Analysis
E2Syntax Analysis
E3Abstract Syntax Tree
E4Semantic Analysis
E5Code Generation
E6Execution Support
E7Optimization

At the end of each stage, we will update the repository with a tag containing the stage code. This way you can track the release schedule through this semester.

Project structure

We’ve structured the template according to the following directories:

src/
The sources directory. Here lies all .c files, organized inside this folder in sub-folders if the source-code belongs to a module or namespace. If the file rests in the root of this directory its considered a main file, which will be compiled as one of the target executables.
include/
The headers directory, analogue to the sources directory.
bin/
The .o directory. Here will be dumped all compiled objects.
build/
The executables directory. Here is the final resting place of the project targets.
scripts/
The .sh directory. Any script that needs to be used during the compiling or dependency handling or whatever should stay here.

Build

To build, just run this single line in the root of this repository:

make

This is the case as the default target for my Makefile is the all rule.

To use all cores in your machine, just add the following flag:

make -j<NUMBER_OF_CORES>

# like
make -j4

In order to find out how many cores you have, run any of the following command in your shell:

# either
nproc
# or
lscpu
# or
cat /proc/cpuinfo

Also, here’s an example of all the rules you can target (and, therefore, call this Makefile with):

ccompiler's project Makefile.

Utilization example:
 make <TARGET> ['DEBUG=true']

@param TARGET
 Can be any of the following:
 all - builds the project (DEFAULT TARGET)
 clean - cleans up all binaries generated during compilation
 redo - cleans up and then builds
 help - shows the utilization example
 test - builds and run tests
 tool - generates compile_commands.json
 release - cleans and compresses the work directory for release

@param 'DEBUG=true'
 When present, the build will happen in debug mode.

Contact

You can contact me through the following e-mail address:

hcpsilva@inf.ufrgs.br

About

Repository dedicated to the final assignment of INF01147.

License:MIT License


Languages

Language:C 68.1%Language:Yacc 13.2%Language:Lex 10.5%Language:Makefile 5.0%Language:Shell 3.2%