compiler design

Description

solve each part and question in this assignment please – using Java

Don't use plagiarized sources. Get Your Custom Assignment on
compiler design
From as Little as $13/Page

Unformatted Attachment Preview

ASSIGNMENT BRIEF
HTU Course No:
30201460
HTU Course Name:
Compiler Design
BTEC Unit No:
BTEC UNIT Name:
Version: 3
Student Name/ID Number/Section
HTU Course Number and Title
30201460 Compiler Design
BTEC Unit Number and Title
Academic Year
2023-2024 Fall
Assignment Author
Samer Suleiman
Course Tutor
Samer Suleiman
Assignment Title
Compiler Design Assignment
Assignment Ref No
1
Issue Date
01/12/2023
Formative Assessment dates
From 02/12/2023 to 11/01/2024
Submission Date
30/01/2024
IV Name & Date
Mustafa Al-Smady 30/11/2023
Submission Format
The submission of this assignment consists of the following parts:
1. An individual written report that has a solution for tasks that ends with the word
(Report).
2. A full working source code for tasks that require code implementation.
3. a 10-15 slide presentation that summarize the work.
4. Any supported diagrams for handwritten solutions for a prat of the tasks
Guidelines

You are required to submit a well-formatted .docx report that provides a complete
answer for all required tasks.

Full and clear answers for all required tasks, mention the task number and the subtask
number before each answer.

You should sign the student declaration form attached to this assignment brief (use
electronic signature to sign it use the word-format).

You must submit a compressed file (ZIP file) that includes all Source codes for the
tasks that require code implementation, each source code should be named by the task
number and the extension should be .java (TaskN.java). The source file should be fully
documented.

Soft-copy submissions are only allowed, you are required to upload your submission
files to the university’s eLearning platform through (https://elearning.htu.edu.jo/)
within the submission date and time stated above. NO SUBMISSION by EMAIL and
NO LATE SUBMISSIONS WILL BE ACCEPTED.

If you commit any kind of plagiarism, HTU policies and regulations will be applied.

The Discussion will be one to one oral discussion between you and your instructor,
which includes debugging, analyzing, and evaluating the code and algorithm developed
in this code.

Attendance of the oral discussion is mandatory on the date and time determined by
your instructor; the exact discussion schedule will be announced after your submission.

You must sign the witness form that your instructor will fill in after the discussion to
complete the discussion process.

If you referred to any external resource for your answers, you need to mention this
resource as a reference in the References section in your report.
Unit Learning Outcomes
LO1 Obtain a well understanding about the compiler role and phases and a description of its inputs and outputs
for each phase
LO2 Ability to illustrate the lexical analyser concepts, techniques, implement scanner/Lexical Analyzer.
LO3 Ability to identify compiler parser strategies, techniques, algorithms, and methods (top-down or bottomup, etc.).
LO4 Describe techniques for intermediate code generation and optimization.
Assignment Brief and Guidance
You have been hired in a Software company that are going to design and implement a
compiler that will be used in a system to compile different programming languages.
You have been asked to illustrate and demonstrate the compiler design building process
to the development team to build such a system, remember that the team experiences
are mixed, and their professorial backgrounds are different, you must use the needed
techniques and methods to give them the basic concepts about the compiler.
Part 1 Report
Your report should
1. Identify the compiler to your development team in terms of its definition, role, features to understand
how it works you can give an example.
2. Through the introductory process you must mention the language processors (compiler) types and
how they are different, what the advantages and disadvantages for each of them and hence when each
of them could be used, in addition to the report its better to provide or write a simple code as well as
give an example to keep all the team members on the line.
3. The development team have a basic idea now about the Compiler, but they still confused about where
and how it could be employed in the program execution process, so you must describe using an
example, the program execution cycle and the role of the compiler in building the program.
4. You may be asked about what the internal phases of the compilation process are, the input and output
for each phase, you must trace them using an example.
5. Describe the lexical analyser role in detail in terms of its inputs and outputs, the used data structures,
and techniques to build it, what is its advantages and disadvantages, why should be separated from the
other parts of the phases, and show it works using an example.
6. Discuss by solving an example the relationships between the lexical analyzer, the source language
and both the finite state automata and the Regular expression.
7. Show the conversion between
a) Regular Expression à Nondeterministic finite state automata NFA à deterministic finite state
automata (DFA) and from
b) Regular expression à deterministic finite state automata (DFA) by solving an example.
c) Generate and test and input strings for your example using both (a) and (c).
8. Describe the Parser role in detail, in terms of its inputs and outputs, the used data structures, and
techniques to build it, what is its advantages and disadvantages, why should be separated from the
other parts of the phases, show it works using an example.
9. Discuss by solving an example the relationships between the parser and the grammar for the source
language with examples for the source code and/or language.
10. Describes the grammar and techniques adapted to build the parser (Top down, Bottom Up and their
variations) and compare between all types by solving an example(s) taking into consideration how to
eliminate the left recursive and left factoring.
11. Describe the code generation process and techniques, -give some examples- as well as the code
optimization techniques used to increase the efficiency of the compiler.
Part2: Code
2.1 Lexical Units and Symbol table
a) Your program should read the source program from a file.
b) It should have a function to print the symbol table at run time.
c) The lexical units of a program are identifiers, reserved words, numbers, strings, and delimiters.
d) A delimiter is any one of the following special characters: () [ ] ; : . , * – + / < = > or one of the
following compound symbols = != =
e) Spaces may be inserted freely with no effect on meaning between lexical units. At least one space
must separate adjacent identifiers or numbers. The end of a line is equivalent to a space except (1) it
terminates comments and (2) is illegal in quoted character strings (see below). Thus, each lexical unit
must fit on one line.
f)
Identifiers: Identifiers (names) consist of a letter followed by a sequence of letters or digits, it is case
sensitive, its length between 1 and 32
g) Numbers: the kinds of numbers are the integer and float. An integer is a sequence of digits, Real is a
sequence of integers separated by decimal point.
h)
Strings: A character string is a sequence of characters prefixed and terminated by the apostrophe
character. The backslash character () acts as an escape.
o When followed by an n or a t, the backslash denotes a new line (CR) or tab.
o When followed by another character it denotes that character. Thus ‘ denotes the single quote. For
example, the string WOULDN’T be represented as ‘DON’T’.
i)
Comments
·
A single line comment starts with (//) and multi-line comment starts with (/*) and ends with (*/)
//This is a single line comment
/* this is a
multi-line comments*/
j)
Reserved word
·
The reserved words in C language and may not be declared by the programmer:
2.2 SYNTAX and Parser
a) Your parser should read the tokens from your lexical.
b) Check the grammar (syntax and semantics) of Arithmetic expressions (+, -, ++, –, /, *, %) only in
the reference file for C language.
c) Run the Parser in two modes (interpreter and compilers)
d) Do some correction strategies for some kind of errors regarding the athematic operations.
e) generate a proper syntax error message, with line number indicator.
Learning Outcomes and Assessment Criteria
Learning Outcome
Pass
P1 Define the Compiler
and its importance with
examples, show and the
role of the compiler in
building the program.
LO1 Obtain a well
understanding about the
compiler role and phases
and a description of its
inputs and outputs for
each phase
P2 Make a comparison
between the different
types of language
processors, show some
examples with sample
code or description.
Mention the advantages
and disadvantages for
each of them.
Merit
M1 Describe using an
example, the compilation
D1 Implement a lexical
phases and relationships
analyser without the aid of
between each of them and
automatic generators.
what is the input and
output for each of which.
M2 Discuss by solving an
example the relationships
between the lexical
LO2 Ability to illustrate
analyser, regular
the lexical analyser
expression, and finite state
concepts, techniques,
P4 Identify the techniques automata for the source
implement
that build the lexical
language, provide a
scanner/Lexical Analyzer.
analyser and specify how segment of code to realize
it works using an example. this relation.
P3 Identify the role of the
lexical analyser, its
features (advantages and
disadvantages)
Distinction
M3 Show the
transformation of Regular
Expression to NFA and
between NFA to DFA, by
solving an example.
P5 Identify the role of the
Parser its features
(advantages and
LO3 Ability to identify
compiler parser strategies, disadvantages).
techniques, algorithms,
P6 Identify the techniques
and methods (top-down or
that build the parser and
bottom-up, etc.).
specify how it works
using an example.
LO4 Describe techniques
for intermediate code
generation and
optimization.
P7 Identify the code
generation and
optimization processes,
show the importance and
differences between them.
M4 Discuss by solving an
example the relationship
between the parser and the
CFG (Context free
D2 Implement parser to
Grammar) for the source handle a set of chosen
language. provide segment grammar form the source
of code to realize this
language.
relation.
M5 Describes the
grammar and techniques
adapted to build the parser
(Top down, Bottom Up
and their variations) and
compare between all types
by solving an example(s).
M6 Describe code
generation and
optimization approaches
by a sample code and
examples.
STUDENT ASSESSMENT SUBMISSION AND DECLARATION
When submitting evidence for assessment, each student must sign a declaration confirming that the work is
their own
Student name:
Assessor name:
Issue date:
01/12/2023
Submission date:
30/01/2024
Submitted on:
Programme: Computing
HTU Course Name: Compiler Design
BTEC Course Title:
HTU Course Code: 30201460
BTEC Course Code:
Assignment number and title: 1, Compiler Design Assignment
Plagiarism:
Plagiarism is a particular form of cheating. Plagiarism must be avoided at all costs and students who break the
rules, however innocently, may be penalised. It is your responsibility to ensure that you understand correct
referencing practices. As a university level student, you are expected to use appropriate references
throughout and keep carefully detailed notes of all your sources of materials for material you have used in
your work, including any material downloaded from the Internet. Please consult the relevant unit lecturer or
your course tutor if you need any further advice.
I certify that the assignment submission is entirely my own work and I fully understand the
consequences of plagiarism. I understand that making a false declaration is a form of malpractice.
Student Name:
Student Signature:
Date:

Purchase answer to see full
attachment