Download presentation
Presentation is loading. Please wait.
Published byDonna Sims Modified over 8 years ago
1
Dr. Mohamed Ramadan Saady 314ALL CH1.1 Chapter 1: Introduction to Compiling
2
Dr. Mohamed Ramadan Saady 314ALL CH1.2 Introduction to Compilers As a Discipline, Involves Multiple CS&E Areas Programming Languages and Algorithms Theory of Computing & Software Engineering Computer Architecture & Operating Systems Has Deceivingly Simplistic Intent: Compiler Source program Target Program Error messages Diverse & Varied
3
Dr. Mohamed Ramadan Saady 314ALL CH1.3 Classifications of Compilers Compilers Viewed from Many Perspectives However, All utilize same basic tasks to accomplish their actions Single Pass Multiple Pass Load & Go Construction Debugging Optimizing Functional
4
Dr. Mohamed Ramadan Saady 314ALL CH1.4 The Model The TWO Fundamental Parts: We Will Discuss Both in This Class, and FOCUS on analysis. Analysis: Synthesis: Decompose Source into an intermediate representation Target program generation from representation
5
Dr. Mohamed Ramadan Saady 314ALL CH1.5 Important Notes Today: There are many Software Tools for helping with the Analysis Part. This Wasn’t the Case in Early Days. (some) analysis is also important in: Structure / Syntax directed editors: Force “syntactically” correct code to be entered Pretty Printers: Standardized version for program structure (i.e., blank space, indenting, etc.) Static Checkers: A “quick” compilation to detect rudimentary errors Interpreters: “real” time execution of code a “line-at-a- time”
6
Dr. Mohamed Ramadan Saady 314ALL CH1.6 Important Notes Compilation Is Not Limited to Programming Language Applications Text Formatters LATEX & TROFF Are Languages Whose Commands Format Text Silicon Compilers Textual / Graphical: Take Input and Generate Circuit Design Database Query Processors Database Query Languages Are Also a Programming Language Input is compiled Into a Set of Operations for Accessing the Database
7
Dr. Mohamed Ramadan Saady 314ALL CH1.7 The Many Phases of a Compiler Source Program Lexical Analyzer 1 Syntax Analyzer 2 Semantic Analyzer 3 Intermediate Code Generator 4 Code Optimizer 5 Code Generator 6 Target Program Symbol-table Manager Error Handler 1, 2, 3 : Analysis - Our Focus 4, 5, 6 : Synthesis
8
Dr. Mohamed Ramadan Saady 314ALL CH1.8 Language-Processing System Source Program Pre-Processor 1 Compiler 2 Assembler 3 Relocatable Machine Code 4 Loader Link/Editor 5 Executable Library, relocatable object files
9
Dr. Mohamed Ramadan Saady 314ALL CH1.9 Three Phases: Linear / Lexical Analysis: L-to-r Scan to Identify Tokens token: sequence of chars having a collective meaning Hierarchical Analysis: Grouping of Tokens Into Meaningful Collection Semantic Analysis: Checking to ensure Correctness of Components The Analysis Task For Compilation
10
Dr. Mohamed Ramadan Saady 314ALL CH1.10 Phase 1. Lexical Analysis Easiest Analysis - Identify tokens which are the basic building blocks For Example: All are tokens Blanks, Line breaks, etc. are scanned out Position := initial + rate * 60 ; _______ __ _____ _ ___ _ __ _
11
Dr. Mohamed Ramadan Saady 314ALL CH1.11 Phase 2. Hierarchical Analysis aka Parsing or Syntax Analysis For previous example, we would have Parse Tree: identifier expression identifier expression number expression assignment statement position := + * 60 initial rate Nodes of tree are constructed using a grammar for the language
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.