EURECOM IT BASICS
1st year Project
Project
Deadline : 13th of October 2024 at 23h59 (local time)
This project aims to familiarize yourself with the C programming lan-
guage, GIT, and UNIX. You will implement a complete project in C from
scratch, implement Bash scripts to test if everything works properly, and
make it available through git using EURECOM’s Gitlab server.
This project will be evaluated on several key aspects :
— Code quality (validity, error management, explicit variable names,
comments, indentation, etc.)
— Tests design and implementation (use of asserts in the code, tests
should cover various aspects of the functionalities, etc.)
— Documentation (how to compile and run your code)
— Git repository management (regular commits split by features, explicit
and informative messages)
1 GIT : management of a git repository
During the project, you will work in groups of 2 students and must
manage a Git repository to share your project properly.
We expect that this repository contains regular commits with infor-
mative messages, that both users regularly contribute to the commit
during the project (uploading everything at once the day before the deadline
is the best way to fail this part), and that your project will be well documen-
ted, with useful comments, a README text file providing a brief description
of the project and a AUTHORS text file providing the members of the group
1
EURECOM Project
(one student per line, with the format first name last name git username
eurecom email address)
Using branches and releases will be appreciated but is not mandatory.
Some files should never be committed on your repository : binary exe-
cutables and log files. They take up a lot of space and can be regenerated
using scripts, as we will see in the next section.
2 Bash scripts : implementing build scripts
and unit tests
Being able to quickly rebuild and test a project is a great way to save a
lot of time during the development process since you will most likely change
(and so recompile) your program a lot.
You will write a single C file per question. Since there are 4 ques-
tions (with a bonus question), there should be at least 4 C files called
rpn{question number}.c. Of course, you can reuse the code of the pre-
vious questions for the next ones by copying/pasting the previous code. This
is not good practice most of the time, but will be considered acceptable here
to make the project management simpler.
In addition, you must write three bash scripts, allowing to easily test if
your program works properly and facilitate the compilation of your project :
1. [Link] : this script must check if the source files are present in the
working directory and compile them to generate an executable file
per source file. Each C file should be compiled into a binary named
rpn{question number}, with question number being the code of the
question being compiled.
2. [Link] : This script will be used to test the behavior of your program
for question 4 only. It must read line by line a text file named
unit [Link] formatted using the following format :
input0 input1 input2 ... inputn:output
and repeatedly execute the compiled program for question 4 with
the provided input to check if the expected output is generated. Before
any operation, the test script will check if the program exists and
if it is executable. At the end of execution, the script must generate
a report containing for each test if it ran successfully or not, display
this report on the screen, and save it in a text file (called [Link]).
2
EURECOM Project
3. [Link] : this script must remove the executable files.
You have to provide the three scripts and a set of relevant tests in the file
unit [Link] (one test per line), checking if your program works properly
when a valid input is provided or when an error occurs.
To summarize, your root directory should have the following files after
running [Link] and [Link] :
— README
— AUTHORS
— rpn1.c
— rpn2.c
— rpn3.c
— rpn4.c
— rpn5.c (optional)
— rpn1
— rpn2
— rpn3
— rpn4
— rpn5 (optional)
— [Link]
— [Link]
— [Link]
— unit [Link]
— [Link]
— Makefile (optional)
Of course, rpn{question number} executable binaries and [Link] should
never be committed to your git repository directly.
Since we are running automated tests to check the correctness of your
project, we expect this project repository structure to be strictly
enforced. Not following this structure will result in a penalty.
Optional : Write a Makefile allowing to run the clean, build and tests
commands for your project. You can learn how Makefiles work with this
step-by-step Makefile guide for example.
3
EURECOM Project
3 C Programming : implementation of a Re-
verse Polish Notation calculator
The objective of this project is to develop a simple calculator that im-
plements the four common arithmetic operators on integers numbers (”+”,
”-”, ”*”, ”/”). The calculator will understand formulas described using the
Reverse Polish Notation (RPN). An example of an expression written using
the RPN is shown below. The expression :
(3 + 5) × (4 − 1)
would be written as such in the RPN :
35 + 41 − ∗
In a formula described in RPN, each element is separated by a space
character (0x20 ). An element can either be an integer number or an opera-
tor. An operator element performs the computation on the two left previous
elements (relative to the operator) that are either available straight from
the formula or from a previous operator result. When processing an RPN
formula, an operator effectively replaces itself and the two previous integer
elements with its result. To be considered valid, an RPN formula must result
in only one integer element after performing all the operators. Here is an
example of the successive computation of a valid RPN formula :
35 + 41 − ∗
841 − ∗
83∗
24
Our calculator will retrieve RPN formulas from its program parameters
(arguments). We will call the provided elements to the program (’3’, ’5’,
the ’+’ operator, etc) tokens. To design the RPN calculator, you will have
to implement a specific kind of linked list, called a stack, in which the last
element to be inserted is the first one to be removed (Last In, First Out).
Our stack will implement at least two operations, push (insert an element in
the stack) and pop (get and remove an element from the stack). In fact, you
will realize that the RPN representation is perfectly adapted to stack-based
implementations due to its particular token (number/operator) ordering.
The expected behavior of your program is summarized below :
4
EURECOM Project
For each token:
- if the token is an integer :
push the number on the stack
- if the token is an arithmetic operator:
pop the two last elements of the stack
implement the arithmetic operation
push the result on the stack
Figure 1 – Example of execution of the main algorithm for 3 5 + 4 2 - *
We strongly suggest that you follow the steps described below to imple-
ment your program. For each step, you will provide a file named rpnquestion
number.c containing the associated source code (of course, you will have to
reuse code from previous steps).
1. Implement a stack (First In Last Out) able to store integers. Write
several functions allowing to :
— create the stack
— insert an element on the stack (push)
— extract an element (pop)
— display the content of the stack
The stack implementation must be based on pointers and structures.
An array-based implementation is not allowed.
5
EURECOM Project
2. Write three functions allowing respectively :
— to check if a string is an integer or not (only contains digits)
— to check is a string is an arithmetic operator (”+”, ”-”, ”*”, ”/”)
— to check if a string is a valid token (either an integer or an arith-
metic operator)
3. Implement in your main function a basic algorithm iterating over all
command line arguments (using argc and argv), generating an output
similar to :
$ ./calculator 3 5 + hello 24 pouet
INTEGER : 3
INTEGER : 5
OPERATOR : +
UNKNOWN : hello
INTEGER: 24
UNKNOWN : pouet
4. By combining the stack implementation and the argument processing,
you must implement the main algorithm to perform the computation
based on the provided expression. A result is considered valid when
at the end of computation, there is only one element in the stack
containing the result, otherwise an error must be displayed. Some
examples of inputs your program should be able to handle are listed
below :
$ ./calculator 3 5 +
RESULT : 8
$ ./calculator 3 5 + 4 2 -
RESULT : 2
$ ./calculator 3 5 + 4 2 - *
RESULT : 16
$ ./calculator 1 +
ERROR
$ ./calculator hello
ERROR
If no argument is provided or if the only argument is the string -h
or --help, the program must display a usage message indicating how
to use it.
6
EURECOM Project
5. Optional : add support for the following tokens, allowing to manipu-
late the state of the stack from the program inputs :
— DROP : remove the latest element inserted in the stack
— DUP : duplicate the latest element inserted in the stack
— SWAP : swap the two latest elements inserted in the stack
— ROT : change the order of the three latest elements inserted in the
stack
Figure 2 – Example of execution of keywords DROP, DUP, SWAP, ROT