Compiler and Translator
Subject Code: ECP3096
Aim of Subject: To provide the basic understanding of computer compilers, translators and related issues.
Learning Outcome of Subject: At the completion of the subject, students should be able to:
  • Design a FSA given a description of the lexical tokens of a language.
  • Write a syntax analyzer based on a FSA.
  • Design the BNF for a language.
  • Eliminate left recursion on a BNF.
  • Use a non-left-recursive BNF to produce a predictive top-down parser.
  • Show how bottom-up parsers solve the problem differently from top-down parsers.
  • Work in a team to produce a compiler or translator.
Programme Outcomes:
  • Ability to acquire and apply fundamental principles of science and engineering(10%)
  • Capability to communicate effectively(5%)
  • Acquisition of technical competence in specialised areas of engineering discipline(40%)
  • Ability to identify, formulate and model problems and find engineering solutions based on a systems approach(10%)
  • Ability to conduct investigation and research on engineering problems in a chosen field of study(10%)
  • Understanding of the importance of sustainability and cost-effectiveness in design and development of engineering solutions(10%)
  • Understanding and commitment to professional and ethical responsibilities(5%)
  • Ability to work effectively as an individual, and as a member/leader in a teams(10%)
  • Ability to be a multi-skilled engineer with good technical knowledge, management, leadership and entrepreneurship skills(5%)
  • Awareness of the social, cultural, global and environmental responsibilities as an engineer(5%)
Assessment Scheme:
  • Assignment / Project - Work in groups of 4, Write a compiler or interpreter(10%)
  • Tutorials - computer as well as paper-based tutorials(10%)
  • Midterm - written exam(20%)
  • Final Exam - written exam(60%)
Discussion on the fundamentals of compilers and translators, their role in relation to other programs, design issues, internal processes, implementation and related issues.
Teaching and Learning Activities: 45 hours (lectures and tutorials)
Credit Hours: 3
Pre-Requisite: ECP1016: Computer and Program Design 
  • J.P. Bennett, “Introduction to Compiling Techniques”, 2nd Edition, McGraw-Hill, 1996.
  • Alfred Aho, Ravi Sethi, Jeffrey Ullman, “Compilers: Principles, Techniques and Tools”, Addison-Wesley, 1986.

Subject Contents

  • General Concepts

  • Introduction. Principles, techniques and tools. Properties and requirements of programming languages, design requirements. Representation. Syntactic specification of natural and programming languages.
  • Structure and Design

  • Compiler structure and design issues. Error analysis. Compile-time and run-time diagnostics. Symbol tables and their data structures. Translator structure and design issues. Implementation of translator.
  • Implementation and Interpretation

  • Lexical analysis. Finite state automata, token types, table-driven and hand-coded scanners. Syntax analysis. Top-down methods, LL parsers, LR parsers, precedence parsers. Intermediate languages. Syntax trees. Quadruplets and postfix notations.
  • Process Design

  • Organization of data storage in computer languages. Object code generation. Accessing of the operands.


The programming tutorials will be conducted using the GCC compiler in the LINUX operating system.