# PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Objective PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS Explain what is meant by compiler. Explain how the compiler works. Describe various analysis of the source program. Describe the phases of compiler. Explain about Loaders, Linkers & Assemblers. Differentiate Lexical and Syntax Analysis. Describe various compiler construction tools. 1.1 Compiler A compiler is a program that can read a program in one language - the source language - and translate it into an equivalent program in another language - the target language. An interpreter is another common kind of language processor. Instead of producing a target program as a translation, an interpreter appears to directly execute the operations specified in the source program on inputs supplied by the user. 1.2 Analysis of the source program Linear Analysis, in which the stream of characters making up the source program is read from left to right and grouped into tokens that are sequences of characters having a collective meaning. Hierarchical Analysis, in which characters or tokens are grouped hierarchically into nested collections with collective meaning. Semantic Analysis, in which certain checks are performed to ensure that the components of a program fit together meaningfully. Principles of Compiler Design - Unit1 1

2 1. Lexical analysis Linear analysis is also called as Lexical analysis or scanning. The lexical analyzer reads the stream of characters making up the source program and groups the characters into meaningful sequences called lexemes. For each lexeme, the lexical analyzer produces as output a token of the form (token-name, attribute-value) that it passes on to the subsequent phase, syntax analysis. For example, suppose a source program contains the assignment statement position = i n i t i a l + r a t e * 60. Then in lexical analysis the charcetrs are grouped into to the following tokens: 1. The identifier position 2. The assignment symbol = 3. The identifier initial 4. The plus sign 5. The identifier rate 6. The * sign 7. The number Syntax Analysis Hierarchical analysis is also called as syntax analysis or parsing. The parser uses the first components of the tokens produced by the lexical analyzer to create a tree-like intermediate representation that depicts the grammatical structure of the token stream. A typical representation is a syntax tree in which each interior node represents an operation and the children of the node represent the arguments of the operation. The hierarchical structure of a program is usually expressed by recursive rules. For example, we might have the following rules as part of the definition of expressions: Principles of Compiler Design - Unit1 2

3 1. Any identifier is an expression. 2. Any number is an expression. 3. If expression1 and expression2 are expressions, then so are expression1 + expression2 expression1 * expression2 (expression1) 3. Semantic Analysis The semantic analyzer uses the syntax tree and the information in the symbol table to check the source program for semantic consistency with the language definition. It also gathers type information and saves it in either the syntax tree or the symbol table, for subsequent use during intermediate-code generation. An important part of semantic analysis is type checking, where the compiler checks that each operator has matching operands. The language specification may permit some type conversions called coercions. For example, a binary arithmetic operator may be applied to either a pair of integers or to a pair of floating-point numbers. If the operator is applied to a floating-point number and an integer, the compiler may convert or coerce the integer into a floating-point number. 1.3 Phases of a compiler A compiler is a program that reads a program in one language, the source language and translates into an equivalent program in another language, the target language. The translation process should also report the presence of errors in the source program. There are two parts of compilation. Principles of Compiler Design - Unit1 3

4 -> The analysis part breaks up the source program into constant piece and creates an intermediate representation of the source program. -> The synthesis part constructs the desired target program from the intermediate representation. The compiler has a number of phases plus symbol table manager and an error handler. The phases of a compiler are collected into front end and back end. The front end includes all analysis phases end the intermediate code generator. The back end includes the code optimization phase and final code generation phase. The front end analyzes the source program and produces intermediate code while the back end synthesizes the target program from the intermediate code. A correct approach to that front end might run the phases serially. 1. Lexical Analysis The first phase of a compiler is called lexical analysis or scanning. The lexical analyzer reads the stream of characters making up the source program and groups the characters into meaningful sequences called lexemes. For each lexeme, the lexical analyzer produces as output a token of the form (token-name, attribute-value) that it passes on to the subsequent phase, syntax analysis. In the token, the first component token-name is an abstract symbol that is used during syntax analysis, and the second component attribute- value points to an entry in the symbol table for this token. Information from the symbol-table entry 'is needed for semantic analysis and code generation. For example, suppose a source program contains the assignment statement position = i n i t i a l + r a t e * 60 The characters in this assignment could be grouped into the following lexemes and mapped into the following tokens passed on to the syntax analyzer: position is a lexeme that would be mapped into a token (id, I), where id is an abstract symbol standing for identifier and 1 points to the symbol table entry for position. The symbol-table entry for an identifier holds information about the identifier, such as its name and type. The assignment symbol = is a lexeme that is mapped into the token (=). Since this token needs no attribute-value, we have omitted the second component. i n i t i a l is a lexeme that is mapped into the token (id, 2), where 2 points to the symbol-table entry for i n i t i a l is a lexeme that is mapped into the token (+). r a t e is a lexeme that is mapped into the token (id, 3), where 3 points to the symbol-table entry for r a t e. * is a lexeme that is mapped into the token (*). 60 is a lexeme that is mapped into the token (60).' Blanks separating the lexemes would be discarded by the lexical analyzer. Principles of Compiler Design - Unit1 4

5 Principles of Compiler Design - Unit1 5

6 2. Syntax Analysis The second phase of the compiler is syntax analysis or parsing. The parser uses the first components of the tokens produced by the lexical analyzer to create a tree-like intermediate representation that depicts the grammatical structure of the token stream. A typical representation is a syntax tree in which each interior node represents an operation and the children of the node represent the arguments of the operation. A syntax tree for the token stream (1.2) is shown as the output of the syntactic analyzer. This tree shows the order in which the operations in the assignment position = i n i t i a l + r a t e * 60 are to be performed. The tree has an interior node labeled * with (id, 3) as its left child and the integer 60 as its right child. The node (id, 3) represents the identifier rate. The node labeled * makes it explicit that we must first multiply the value of r a t e by 60. The node labeled + indicates that we must add the result of this multiplication to the value of i n i t i a l. The root of the tree, labeled =, indicates that we must store the result of this addition into the location for the identifier posit ion. This ordering of operations is consistent with the usual conventions of arithmetic which tell us that multiplication has higher precedence than addition, and hence that the multiplication is to be performed before the addition. 3. Semantic Analysis The semantic analyzer uses the syntax tree and the information in the symbol table to check the source program for semantic consistency with the language definition. It also gathers type information and saves it in either the syntax tree or the symbol table, for subsequent use during intermediate-code generation. An important part of semantic analysis is type checking, where the compiler checks that each operator has matching operands. For example, many programming language definitions require an Principles of Compiler Design - Unit1 6

7 array index to be an integer; the compiler must report an error if a floating-point number is used to index an array. The language specification may permit some type conversions called coercions. For example, a binary arithmetic operator may be applied to either a pair of integers or to a pair of floating-point numbers. If the operator is applied to a floating-point number and an integer, the compiler may convert or coerce the integer into a floating-point number. 4. Intermediate Code Generation In the process of translating a source program into target code, a compiler may construct one or more intermediate representations, which can have a variety of forms. Syntax trees are a form of intermediate representation; they are commonly used during syntax and semantic analysis. After syntax and semantic analysis of the source program, many compilers generate an explicit low-level or machine-like intermediate representation, which we can think of as a program for an abstract machine. This intermediate representation should have two important properties: it should be easy to produce and it should be easy to translate into the target machine. The output of the intermediate code generator consists of the three-address code sequence tl = i n t t o f l o a t (60) t 2 = id3 * tl t 3 = id2 + t 2 id1 = t 3 There are several points worth noting about three-address instructions. First, each three-address assignment instruction has at most one operator on the right side. Thus, these instructions fix the order in which operations are to be done; the multiplication precedes the addition in the source program. Second, the compiler must generate a temporary name to hold the value computed by a three-address instruction. Third, some "three-address instructions" like the first and last in the sequence above, have fewer than three operands. 5. Code Optimization The machine-independent code-optimization phase attempts to improve the intermediate code so that better target code will result. Usually better means faster, but other objectives may be desired, such as shorter code, or target code that consumes less power. For example, a straightforward algorithm generates the intermediate code using an instruction for each operator in the tree representation that comes from the semantic analyzer. A simple intermediate code generation algorithm followed by code optimization is a reasonable way to generate good target code. The optimizer can deduce that the conversion of 60 from integer to floating point can be done once and for all at compile time, so the inttofloat operation can be eliminated by replacing the integer 60 by the floating-point number Principles of Compiler Design - Unit1 7

8 Moreover, t3 is used only once to transmit its value to id1 so the optimizer can transform into the shorter sequence, There is a great variation in the amount of code optimization different compilers perform. In those that do the most, the so-called "optimizing compilers," a significant amount of time is spent on this phase. 6. Code Generation The code generator takes as input an intermediate representation of the source program and maps it into the target language. If the target language is machine code, registers or memory locations are selected for each of the variables used by the program. Then, the intermediate instructions are translated into sequences of machine instructions that perform the same task. A crucial aspect of code generation is the judicious assignment of registers to hold variables. For example, using registers R1 and R2, the intermediate code in might get translated into the machine code LDF R2, id3 MULF R 2, R 2, #60.0 LDF R l, id2 ADDF R l, R l, R2 STF i d l, R l The first operand of each instruction specifies a destination. The F in each instruction tells us that it deals with floating-point numbers. The code loads the contents of address id3 into register R2, then multiplies it with floating-point constant The # signifies that 60.0 is to be treated as an immediate constant. The third instruction moves id2 into register R1 and the fourth adds to it the value previously computed in register R2. Finally, the value in register R1 is stored into the address of i d l, so the code correctly implements the assignment statement. 7. Symbol-Table Management An essential function of a compiler is to record the variable names used in the source program and collect information about various attributes of each name. These attributes may provide information about the storage allocated for a name, its type, its scope (where in the program its value may be used), and in the ca,se of procedure names, such things as the number and types of its arguments, the method of passing each argument (for example, by value or by reference), and the type returned. The symbol table is a data structure containing a record for each variable name, with fields for the attributes of the name. The data structure should be designed to allow the compiler to find the record for each name quickly and to store or retrieve data from that record quickly. Principles of Compiler Design - Unit1 8

9 Limitations Requires enormous amount of space to store tokens and trees. Very slow since each phase would have to input and output to and from temporary disk Summary Language Processors. An integrated software development environment includes many different kinds of language processors such as compilers, interpreters, assemblers, linkers, loaders, debuggers, profilers. Compiler Phases. A compiler operates as a sequence of phases, each of which transforms the source program from one intermediate representation to another. Machine and Assembly Languages. Machine languages were the first generation programming languages, followed by assembly languages. Programming in these languages was time consuming and error prone. Modeling in Compiler Design. Compiler design is one of the places where theory has had the most impact on practice. Models that have been found useful include automata, grammars, regular expressions, trees, and many others. Code Optimization. Although code cannot truly be "optimized," the science of improving the efficiency of code is both complex and very important. It is a major portion of the study of compilation. Higher-Level Languages. As time goes on, programming languages take on progressively more of the tasks that formerly were left to the programmer, such as memory management, typeconsistency checking, or parallel execution of code. Key Terms >> compiler >> intermediate code generation >> tokens >> lexical analysis >> code optimization >> error handler >> syntax analysis >> code generation >> linear analysis >> semantic analysis >> symbol table >> hierarchical analysis Key Term Quiz 1. A is a program that can read the source language and translate it into an equivalent program in to the target language. 2. An appears to directly execute the operations specified in the source program on inputs supplied by the user. Principles of Compiler Design - Unit1 9

10 analysis is also called as Lexical analysis or scanning Analysis, in which the stream of characters making up the source program is read from left to right and grouped into tokens that are sequences of characters having a collective meaning Analysis, in which characters or tokens are grouped hierarchically into nested collections with collective meaning Analysis, in which certain checks are performed to ensure that the components of a program fit together meaningfully phase attempts to improve the intermediate code so that better target code will result. 8. The groups the characters into meaningful sequences called takes as input an intermediate representation of the source program and maps it into the target language. Multiple Choice Questions is a program that can read the source language and translate it into an equivalent program in to the target language. a. compiler b. interpreter c. assembler d. loader 2. Which one of the following that executes the operations specified in the source program on inputs supplied by the user? a. compiler b. interpreter c. assembler d. loader 3. Linear analysis is also called as a. lexical analysis b. syntax analysis c. hierarchical analysis d. semantic analysis 4. The stream of characters making up the source program is read from left to right and grouped into tokens called a. lexical analysis b. syntax analysis c. hierarchical analysis d. semantic analysis 5. Which one of the following phase is the front end of the compiler? a. lexical analysis b. code generation c. code optimization d. None of the above 6. Which one of the following phase is the back end of the compiler? a. lexical analysis b. linear analysis c. code optimization d. syntax analysis 7. Which phase attempts to improve the intermediate code so that better target code will result? a. lexical analysis b. code generation c. code optimization d. syntax analysis 8. Which phase takes as input an intermediate representation of the source program and maps it into the target language? a. lexical analysis b. code generation c. code optimization d. syntax analysis Principles of Compiler Design - Unit1 10

11 9. Which phase is used to separate the tokens from the expression? a. lexical analysis b. code generation c. code optimization d. syntax analysis 10. Which phase is used to construct the parse tree for the given expression? a. lexical analysis b. code generation c. code optimization d. syntax analysis 11. A language translator is a program a. which converts the program from machine to high level b. which converts the program from C to C++ c. which converts the program from high level to machine d. which converts the program from assembly to machine 12. Which of the following translator converts the assembly language to object language? a. assembler b. compiler c. macro processor d. linker 13. A compiler is a program that a. places program into memory and prepares them for execution b. automates the translation of assembly language into machine language c. accepts the program written in high level language and produces an object program d. appears to execute a source program as if it were machine language 14. An interpreter is a program that a. places program into memory and prepares them for execution b. automates the translation of assembly language into machine language c. accepts the program written in high level language and produces an object program d. appears to execute a source program as if it were machine language 15. A load is a program that a. places program into memory and prepares them for execution b. automates the translation of assembly language into machine language c. accepts the program written in high level language and produces an object program d. appears to execute a source program as if it were machine language 16. A program written in high level language is known as a. source program b. object program c. OS d. none 17. Compiler can diagnose a. grammatical errors only b. logical errors only c. grammatical as well as logical errors d. neither grammatical nor logical errors 18. Object program is a a. program written in machine language Principles of Compiler Design - Unit1 11

12 b. program translated into machine language c. the translation of high level language into machine language d. none 19. A programmer by mistake written an instruction to divide, instead if multiply, such errors can be detected by an a. compiler b. interpreter c. compiler or interpreter d. none 20. Semantic errors can be detected a. at compile time only b. at run time only c. both d. none 21. The task lexical analysis program is a. to parse the source program to basic or tokens of the language b. to build a literal table and an identifier table c. to build a uniform symbol table d. all of the above 22. The function of syntax analyzer is a. to recognize the major constructs of the language and calls the appropriate the action routines that will generate the intermediate form for these constructs b. to build a literal table and an identifier table c. to build a uniform symbol table d. to parse the source program to basic or tokens of the language 23. The errors that can pointed by the compiler is a. syntax error b. semantic error c. logical error d. internal error Review Questions Two mark Questions 1. Define a symbol table. 2. Differentiate compiler and interpreter. 3. What is a language processing system? 4. What are error recovery actions in lexical analyzer? 5. How to analyze the source program? 6. What does translator mean? 7. What are the phases of a compiler? 8. Mention the role of semantic analysis? 9. What are the different data structures used for symbol table? Principles of Compiler Design - Unit1 12

13 10. What is front-end and back-end of the compiler? 11. What is linear analysis? 12. What is the main difference between phase and pass of a compiler? Big Questions 1. Write about the phases of compiler and by assuming an input and show the output of various phases. 2. Explian in detail the role of lexical analyzer with the possible error recovery actions. Lesson Labs Exercise 1 : What is the difference between a compiler and an interpreter? Exercise 2 : What are the advantages of (a) a compiler over an interpreter (b) an interpreter over a compiler? 1.4 Cousins of the Compiler The cousins of the compiler are 1. Preprocessor. 2. Assembler. 3. Loader and Link-editor. 1. Preprocessors Preprocessors produce input to compilers. They may perform the following functions. Macro processing -> A preprocessor may allow a user to define macros that are shorthand s for longer constructs. File Inclusion -> A preprocessor may include hearder files into program text. Rational preprocessors -> These preprocessors augment older languages with more tokens flow of control and data structuring faculties. Language extensions -> These preprocessors attempt to add capabilities to the language by what amounts to built in macros. 2. Assembler A program that translates a symbolic version of an instruction into the binary version. Assemblers provide a friendlier representation than a computer s 0s and 1s that simplifies writing and reading programs. Symbolic names for operations and locations are one facet of this representation. An assembler reads a single assembly language source file and produces an object file containing machine instructions and bookkeeping information that Principles of Compiler Design - Unit1 13

15 languages for specifying and implementing specific components, and many use quite sophisticated algorithms. The most successful tools are those that hide the details of the generation algorithm and produce components that can be easily integrated into the remainder of the compiler. Some commonly used compiler-construction tools include 1. Parser generators that automatically produce syntax analyzers from a grammatical description of a programming language. 2. Scanner generators that produce lexical analyzers from a regular-expression description of the tokens of a language. 3. Syntax-directed translation engines that produce collections of routines for walking a parse tree and generating intermediate code. 4. Code-generator generators that produce a code generator from a collection of rules for translating each operation of the intermediate language into the machine language for a target machine. 5. Data-flow analysis engines that facilitate the gathering of information about how values are transmitted from one part of a program to each other part. Data-flow analysis is a key part of code optimization. 6. Compiler-construction toolk2ts that provide an integrated set of routines for constructing various phases of a compiler. 1.7 Translators Language translators convert programming source code into language that the computer processor understands. Programming source code has various structures and commands, but computer processors only understand machine language. Different types of translations must occur to turn programming source code into machine language, which is made up of bits of binary data. The three major types of language translators are compilers, assemblers, and interpreters. (i) Compilers Most 3GL and higher-level programming languages use a compiler for language translation. A compiler is a special program that takes written source code and turns it into machine language. When a compiler executes, it analyzes all of the language statements in the source code and builds the machine language object code. After a program is compiled, it is then a form that the processor can execute one instruction at a time. Principles of Compiler Design - Unit1 15

16 In some operating systems, an additional step called linking is required after compilation. Linking resolves the relative location of instructions and data when more than one object module needs to be run at the same time and both modules cross-reference each others instruction sequences or data. Most high-level programming languages come with a compiler. However, object code is unique for each type of computer. Many different compilers exist for each language in order to translate for each type of computer. In addition, the compiler industry is quite competitive, so there are actually many compilers for each language on each type of computer. Although they require an extra step before execution, compiled programs often run faster than programs executed using an interpreter. (ii) Assembler An assembler translates assembly language into machine language. Assembly language is one step removed from machine language. It uses computer-specific commands and structure similar to machine language, but assembly language uses names instead of numbers. An assembler is similar to a compiler, but it is specific to translating programs written in assembly language into machine language. To do this, the assembler takes basic computer instructions from assembly language and converts them into a pattern of bits for the computer processor to use to perform its operations. (iii) Interpreters Many high-level programming languages have the option of using an interpreter instead of a compiler. Some of these languages exclusively use an interpreter. An interpreter behaves very differently from compilers and assemblers. It converts programs into machine-executable form each time they are executed. It analyzes and executes each line of source code, in order, without looking at the entire program. Instead of requiring a step before program execution, an interpreter processes the program as it is being executed. 1.8 One Pass Compilers A one-pass compiler is a compiler that passes through the source code of each compilation unit only once. In other words, a one-pass compiler does not "look back" at code it previously processed. Another term sometimes used is narrow compiler, which emphasizes the limited scope a one-pass compiler is Principles of Compiler Design - Unit1 16

17 obliged to use. This is in contrast to a multi-pass compiler which traverses the source code and/or the abstract syntax tree several times, building one or more intermediate representations that can be arbitrarily refined. While one-pass compilers may be faster than multi-pass compilers, they are unable to generate as efficient programs, due to the limited scope available. (Many optimizations require multiple passes over a program, subroutine, or basic block.) In addition, some programming languages simply cannot be compiled in a single pass, as a result of their design. In contrast, some programming languages have been designed specifically to be compiled with one-pass compilers, and include special constructs to allow one-pass compilation. One-pass compilers are faster, but may not generate an as efficient program. In addition, one-pass compilers cannot compile all types of source codes. One-pass versus multi-pass compilers Classifying compilers by number of passes has its background in the hardware resource limitations of computers. Compiling involves performing lots of work and early computers did not have enough memory to contain one program that did all of this work. So compilers were split up into smaller programs which each made a pass over the source (or some representation of it) performing some of the required analysis and translations. The ability to compile in a single pass is often seen as a benefit because it simplifies the job of writing a compiler and one pass compilers generally compile faster than multi-pass compilers. Many languages were designed so that they could be compiled in a single pass (e.g., Pascal). In some cases the design of a language feature may require a compiler to perform more than one pass over the source. For instance, consider a declaration appearing on line 20 of the source which affects the Principles of Compiler Design - Unit1 17

18 translation of a statement appearing on line 10. In this case, the first pass needs to gather information about declarations appearing after statements that they affect, with the actual translation happening during a subsequent pass. The disadvantage of compiling in a single pass is that it is not possible to perform many of the sophisticated optimizations needed to generate high quality code. It can be difficult to count exactly how many passes an optimizing compiler makes. For instance, different phases of optimization may analyse one expression many times but only analyse another expression once. Splitting a compiler up into small programs is a technique used by researchers interested in producing provably correct compilers. Proving the correctness of a set of small programs often requires less effort than proving the correctness of a larger, single, equivalent program. While the typical multi-pass compiler outputs machine code from its final pass, there are several other types: A "source-to-source compiler" is a type of compiler that takes a high level language as its input and outputs a high level language. For example, an automatic parallelizing compiler will frequently take in a high level language program as an input and then transform the code and annotate it with parallel code annotations (e.g. OpenMP) or language constructs (e.g. Fortran's DOALL statements). Stage compiler that compiles to assembly language of a theoretical machine, like some Prologimplementations Just-in-time compiler, used by Smalltalk and Java systems, and also by Microsoft.Net's Common Intermediate Language (CIL) Difference between single pass compiler and multi pass compiler A one-pass compiler is a compiler that passes through the source code of each compilation unit only once. A multi-pass compiler is a type of compiler that processes the source code or abstract syntax tree of a program several times. A one-pass compilers is faster than multi-pass compilers A one-pass compiler has limited scope of passes but multi-pass compiler has wide scope of passes. Multi-pass compilers are sometimes called wide compilers where as one-pass compiler are sometimes called narrow compiler. Many programming languages cannot be represented with a single pass compilers, for example Pascal can be implemented with a single pass compiler where as languages like Java require a multi-pass compiler. Principles of Compiler Design - Unit1 18

19 Summary Assemblers provide a friendlier representation than a computer s 0s and 1s that simplifies writing and reading programs. A two pass assembler does two passes over the source file ( the second pass can be over a file generated in the first pass ). Loader is a utility program that sets up an executable program in main memory ready for execution. This is the final stage of the compiling/assembly process. Link editor (linkage editor, linker) is the utility program that combines several separately compiled modules into one, resolving internal references between them. Translators convert programming source code into language that the computer processor understands. An assembler translates assembly language into machine language. Assembly language is one step removed from machine language. An interpreter behaves very differently from compilers and assemblers. It converts programs into machine-executable form each time they are executed. A one-pass compiler is a compiler that passes through the source code of each compilation unit only once. Key Terms >> preprocessors >> linkers >> loaders >> translators >> assemblers >> interpreter >> one pass compiler Key Term Quiz 1) provide a friendlier representation than a computer s 0s and 1s that simplifies writing and reading programs. 2) is a utility program that sets up an executable program in main memory ready for execution. This is the final stage of the compiling/assembly process. 3) is the utility program that combines several separately compiled modules into one, resolving internal references between them. 4) convert programming source code into language that the computer processor understands. 5) An assembler translates language into language. Assembly language is one step removed from machine language. Principles of Compiler Design - Unit1 19

21 7. Define one pass compiler. 8. Compare one pass and two pass compiler. Big Questions 1. Explain briefly about complier construction tools. 2. Discuss briefly about one pass compiler END OF FIRST UNIT Principles of Compiler Design - Unit1 21

### COMP455: COMPILER AND LANGUAGE DESIGN. Dr. Alaa Aljanaby University of Nizwa Spring 2013

COMP455: COMPILER AND LANGUAGE DESIGN Dr. Alaa Aljanaby University of Nizwa Spring 2013 Chapter 1: Introduction Compilers draw together all of the theory and techniques that you ve learned about in most

UNIT I INTRODUCTION TO COMPILER 1. What is a Complier? A Complier is a program that reads a program written in one language-the source language-and translates it in to an equivalent program in another

UNIT -1 1.1 OVERVIEW OF LANGUAGE PROCESSING SYSTEM 1.2 Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing: A preprocessor may allow a

### Compiler Design. Subject Code: 6CS63/06IS662. Part A UNIT 1. Chapter Introduction. 1.1 Language Processors

Compiler Design Subject Code: 6CS63/06IS662 Part A UNIT 1 Chapter 1 1. Introduction 1.1 Language Processors A compiler is a program that can read a program in one language (source language) and translate

### LECTURE NOTES ON COMPILER DESIGN P a g e 2

LECTURE NOTES ON COMPILER DESIGN P a g e 1 (PCCS4305) COMPILER DESIGN KISHORE KUMAR SAHU SR. LECTURER, DEPARTMENT OF INFORMATION TECHNOLOGY ROLAND INSTITUTE OF TECHNOLOGY, BERHAMPUR LECTURE NOTES ON COMPILER

### PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Computer Science and Engineering

TEST 1 Date : 24 02 2015 Marks : 50 Subject & Code : Compiler Design ( 10CS63) Class : VI CSE A & B Name of faculty : Mrs. Shanthala P.T/ Mrs. Swati Gambhire Time : 8:30 10:00 AM SOLUTION MANUAL 1. a.

### Introduction to Compiler Construction

Introduction to Compiler Construction ASU Textbook Chapter 1 Tsan-sheng Hsu tshsu@iis.sinica.edu.tw http://www.iis.sinica.edu.tw/~tshsu 1 What is a compiler? Definitions: A recognizer. A translator. source

Compiler, Assembler, and Linker Minsoo Ryu Department of Computer Science and Engineering Hanyang University msryu@hanyang.ac.kr What is a Compilation? Preprocessor Compiler Assembler Linker Loader Contents

i About the Tutorial A compiler translates the codes written in one language to some other language without changing the meaning of the program. It is also expected that a compiler should make the target

### Earlier edition Dragon book has been revised. Course Outline Contact Room 124, tel , rvvliet(at)liacs(dot)nl

Compilerconstructie najaar 2013 http://www.liacs.nl/home/rvvliet/coco/ Rudy van Vliet kamer 124 Snellius, tel. 071-527 5777 rvvliet(at)liacs(dot)nl college 1, dinsdag 3 september 2013 Overview 1 Why this

### COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

COP4020 ming Languages Compilers and Interpreters Robert van Engelen & Chris Lacher Overview Common compiler and interpreter configurations Virtual machines Integrated development environments Compiler

### COP4020 Programming Languages. Compilers and Interpreters Prof. Robert van Engelen

COP4020 ming Languages Compilers and Interpreters Prof. Robert van Engelen Overview Common compiler and interpreter configurations Virtual machines Integrated development environments Compiler phases Lexical

### CD Assignment I. 1. Explain the various phases of the compiler with a simple example.

CD Assignment I 1. Explain the various phases of the compiler with a simple example. The compilation process is a sequence of various phases. Each phase takes input from the previous, and passes the output

### About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1

Table of Contents About the Authors... iii Introduction... xvii Chapter 1: System Software... 1 1.1 Concept of System Software... 2 Types of Software Programs... 2 Software Programs and the Computing Machine...

### COMPILER CONSTRUCTION LAB 2 THE SYMBOL TABLE. Tutorial 2 LABS. PHASES OF A COMPILER Source Program. Lab 2 Symbol table

COMPILER CONSTRUCTION Lab 2 Symbol table LABS Lab 3 LR parsing and abstract syntax tree construction using ''bison' Lab 4 Semantic analysis (type checking) PHASES OF A COMPILER Source Program Lab 2 Symtab

### UNIT I- LEXICAL ANALYSIS. 1.Interpreter: It is one of the translators that translate high level language to low level language.

INRODUCTION TO COMPILING UNIT I- LEXICAL ANALYSIS Translator: It is a program that translates one language to another. Types of Translator: 1.Interpreter 2.Compiler 3.Assembler source code Translator target

### Compiler Structure. Lexical. Scanning/ Screening. Analysis. Syntax. Parsing. Analysis. Semantic. Context Analysis. Analysis.

Compiler Structure Source Program Text Phases of Compilation Compilation process is partitioned into a series of four distinct subproblems called phases, each with a separate well-defined translation task

### Crafting a Compiler with C (II) Compiler V. S. Interpreter

Crafting a Compiler with C (II) 資科系 林偉川 Compiler V S Interpreter Compilation - Translate high-level program to machine code Lexical Analyzer, Syntax Analyzer, Intermediate code generator(semantics Analyzer),

### Early computers (1940s) cost millions of dollars and were programmed in machine language. less error-prone method needed

Chapter 1 :: Programming Language Pragmatics Michael L. Scott Early computers (1940s) cost millions of dollars and were programmed in machine language machine s time more valuable than programmer s machine

### Compiler Code Generation COMP360

Compiler Code Generation COMP360 Students who acquire large debts putting themselves through school are unlikely to think about changing society. When you trap people in a system of debt, they can t afford

### SLIDE 2. At the beginning of the lecture, we answer question: On what platform the system will work when discussing this subject?

SLIDE 2 At the beginning of the lecture, we answer question: On what platform the system will work when discussing this subject? We have two systems: Widnows and Linux. The easiest solution is to use the

### Compiler Theory Introduction and Course Outline Sandro Spina Department of Computer Science

Compiler Theory 001 - Introduction and Course Outline Sandro Spina Department of Computer Science ( course Books (needed during this My slides are based on the three books: Compilers: Principles, techniques

### Principles of Compiler Design

Principles of Compiler Design Intermediate Representation Compiler Lexical Analysis Syntax Analysis Semantic Analysis Source Program Token stream Abstract Syntax tree Unambiguous Program representation

### DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Subject Name: CS2352 Principles of Compiler Design Year/Sem : III/VI

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Subject Name: CS2352 Principles of Compiler Design Year/Sem : III/VI UNIT I - LEXICAL ANALYSIS 1. What is the role of Lexical Analyzer? [NOV 2014] 2. Write

### Time : 1 Hour Max Marks : 30

Total No. of Questions : 6 P4890 B.E/ Insem.- 74 B.E ( Computer Engg) PRINCIPLES OF MODERN COMPILER DESIGN (2012 Pattern) (Semester I) Time : 1 Hour Max Marks : 30 Q.1 a) Explain need of symbol table with

### Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Module No. # 01 Lecture No. # 01 An Overview of a Compiler This is a lecture about

### CS606- compiler instruction Solved MCQS From Midterm Papers

CS606- compiler instruction Solved MCQS From Midterm Papers March 06,2014 MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01 Final Term MCQ s and Quizzes CS606- compiler instruction If X is a

### KINGS COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING ACADEMIC YEAR / EVEN SEMESTER

KINGS COLLEGE OF ENGINEERING PUNALKULAM DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING ACADEMIC YEAR 2010-2011 / EVEN SEMESTER SUBJECT CODE\SUBJECT NAME: CS1352 \ PRINCIPLES OF COMPILER DESIGN QUESTION BANK

### 4. An interpreter is a program that

1. In an aboslute loading scheme, which loader function is accomplished by programmer? A. Allocation B. LInking C. Reallocation D. both (A) and (B) 2. A compiler program written in a high level language

### Theory and Compiling COMP360

Theory and Compiling COMP360 It has been said that man is a rational animal. All my life I have been searching for evidence which could support this. Bertrand Russell Reading Read sections 2.1 3.2 in the

### Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Language Translation Compilation vs. interpretation Compilation diagram Step 1: compile program compiler Compiled program Step 2: run input Compiled program output Language Translation compilation is translation

### Languages and Compilers

Principles of Software Engineering and Operational Systems Languages and Compilers SDAGE: Level I 2012-13 4. Lexical Analysis (Scanning) Dr Valery Adzhiev vadzhiev@bournemouth.ac.uk Office: TA-121 For

### Advanced Programming & C++ Language

Advanced Programming & C++ Language ~1~ Introduction. Compilation Process Ariel University 2018 Dr. Miri (Kopel) Ben-Nissan 2 Administration Stuff Final Exam: 70% Exercises: 30% Both lectures and exercises

### COMPILERS BASIC COMPILER FUNCTIONS

COMPILERS BASIC COMPILER FUNCTIONS A compiler accepts a program written in a high level language as input and produces its machine language equivalent as output. For the purpose of compiler construction,

### Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

### 11. a b c d e. 12. a b c d e. 13. a b c d e. 14. a b c d e. 15. a b c d e

CS-3160 Concepts of Programming Languages Spring 2015 EXAM #1 (Chapters 1-6) Name: SCORES MC: /75 PROB #1: /15 PROB #2: /10 TOTAL: /100 Multiple Choice Responses Each multiple choice question in the separate

### 3.5 Practical Issues PRACTICAL ISSUES Error Recovery

3.5 Practical Issues 141 3.5 PRACTICAL ISSUES Even with automatic parser generators, the compiler writer must manage several issues to produce a robust, efficient parser for a real programming language.

### CS /534 Compiler Construction University of Massachusetts Lowell

CS 91.406/534 Compiler Construction University of Massachusetts Lowell Professor Li Xu Fall 2004 Lab Project 2: Parser and Type Checker for NOTHING Due: Sunday, November 14, 2004, 11:59 PM 1 Introduction

### Semantic actions for expressions

Semantic actions for expressions Semantic actions Semantic actions are routines called as productions (or parts of productions) are recognized Actions work together to build up intermediate representations

### Chapter 3:: Names, Scopes, and Bindings (cont.)

Chapter 3:: Names, Scopes, and Bindings (cont.) Programming Language Pragmatics Michael L. Scott Review What is a regular expression? What is a context-free grammar? What is BNF? What is a derivation?

### Chapter 4 :: Semantic Analysis

Chapter 4 :: Semantic Analysis Programming Language Pragmatics, Fourth Edition Michael L. Scott Copyright 2016 Elsevier 1 Chapter04_Semantic_Analysis_4e - Tue November 21, 2017 Role of Semantic Analysis

### LECTURE 3. Compiler Phases

LECTURE 3 Compiler Phases COMPILER PHASES Compilation of a program proceeds through a fixed series of phases. Each phase uses an (intermediate) form of the program produced by an earlier phase. Subsequent

### CS 415 Midterm Exam Spring 2002

CS 415 Midterm Exam Spring 2002 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Good Luck! Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming

### Defining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1

Defining Program Syntax Chapter Two Modern Programming Languages, 2nd ed. 1 Syntax And Semantics Programming language syntax: how programs look, their form and structure Syntax is defined using a kind

### UNIT V SYSTEM SOFTWARE TOOLS

5.1 Text editors UNIT V SYSTEM SOFTWARE TOOLS A text editor is a type of program used for editing plain text files. Text editors are often provided with operating systems or software development packages,

### Intermediate Representations

COMP 506 Rice University Spring 2018 Intermediate Representations source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students

### Group A Assignment 3(2)

Group A Assignment 3(2) Att (2) Perm(3) Oral(5) Total(10) Sign Title of Assignment: Lexical analyzer using LEX. 3.1.1 Problem Definition: Lexical analyzer for sample language using LEX. 3.1.2 Perquisite:

### QUESTION BANK CHAPTER 1 : OVERVIEW OF SYSTEM SOFTWARE. CHAPTER 2: Overview of Language Processors. CHAPTER 3: Assemblers

QUESTION BANK CHAPTER 1 : OVERVIEW OF SYSTEM SOFTWARE 1) Explain Analysis-synthesis model/fron end backend model of compiler 2) Explain various phases of compiler and symbol table. Consider the statement

### 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

### GBIL: Generic Binary Instrumentation Language. Language Reference Manual. By: Andrew Calvano. COMS W4115 Fall 2015 CVN

GBIL: Generic Binary Instrumentation Language Language Reference Manual By: Andrew Calvano COMS W4115 Fall 2015 CVN Table of Contents 1) Introduction 2) Lexical Conventions 1. Tokens 2. Whitespace 3. Comments

### Chapter 3:: Names, Scopes, and Bindings (cont.)

Chapter 3:: Names, Scopes, and Bindings (cont.) Programming Language Pragmatics Michael L. Scott Review What is a regular expression? What is a context-free grammar? What is BNF? What is a derivation?

### History of Compilers The term

History of Compilers The term compiler was coined in the early 1950s by Grace Murray Hopper. Translation was viewed as the compilation of a sequence of machine-language subprograms selected from a library.

### Context-Free Grammar. Concepts Introduced in Chapter 2. Parse Trees. Example Grammar and Derivation

Concepts Introduced in Chapter 2 A more detailed overview of the compilation process. Parsing Scanning Semantic Analysis Syntax-Directed Translation Intermediate Code Generation Context-Free Grammar A

### Introduction to Compiler Design

Introduction to Compiler Design Lecture 1 Chapters 1 and 2 Robb T. Koether Hampden-Sydney College Wed, Jan 14, 2015 Robb T. Koether (Hampden-Sydney College) Introduction to Compiler Design Wed, Jan 14,

### Rationale for TR Extension to the programming language C. Decimal Floating-Point Arithmetic

WG14 N1161 Rationale for TR 24732 Extension to the programming language C Decimal Floating-Point Arithmetic Contents 1 Introduction... 1 1.1 Background... 1 1.2 The Arithmetic Model... 3 1.3 The Encodings...

### Chapter 3. Describing Syntax and Semantics

Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:

### tokens parser 1. postfix notation, 2. graphical representation (such as syntax tree or dag), 3. three address code

Intermediate generation source program lexical analyzer tokens parser parse tree generation intermediate language The intermediate language can be one of the following: 1. postfix notation, 2. graphical

### St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-00 014 Subject: PPL Class : CSE III 1 P a g e DEPARTMENT COMPUTER SCIENCE AND ENGINEERING S No QUESTION Blooms Course taxonomy level Outcomes UNIT-I

### TDDD55 - Compilers and Interpreters Lesson 3

TDDD55 - Compilers and Interpreters Lesson 3 November 22 2011 Kristian Stavåker (kristian.stavaker@liu.se) Department of Computer and Information Science Linköping University LESSON SCHEDULE November 1,

### Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Lecture - 20 Intermediate code generation Part-4 Run-time environments

### 5. Syntax-Directed Definitions & Type Analysis

5. Syntax-Directed Definitions & Type Analysis Eva Rose Kristoffer Rose NYU Courant Institute Compiler Construction (CSCI-GA.2130-001) http://cs.nyu.edu/courses/spring15/csci-ga.2130-001/lecture-5.pdf

### CS202 Compiler Construction. Christian Skalka. Course prerequisites. Solid programming skills a must.

CS202 Compiler Construction Christian Skalka www.cs.uvm.edu/~skalka/202 CS 202-1 Introduction 1 Course prerequisites CS101 Must be able to read assembly CS103 Understand tree operations basic grammars

### COMPILERS AND INTERPRETERS Lesson 4 TDDD16

COMPILERS AND INTERPRETERS Lesson 4 TDDD16 Kristian Stavåker (kristian.stavaker@liu.se) Department of Computer and Information Science Linköping University TODAY Introduction to the Bison parser generator

### SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

SKILL AREA 304: Review Programming Language Concept Computer Programming (YPG) 304.1 Demonstrate an Understanding of Basic of Programming Language 304.1.1 Explain the purpose of computer program 304.1.2

### Problems and Solutions to the January 1994 Core Examination

Problems and Solutions to the January 1994 Core Examination Programming Languages PL 1. Consider the following program written in an Algol-like language: begin integer i,j; integer array A[0..10]; Procedure

### CSE 452: Programming Languages. Outline of Today s Lecture. Expressions. Expressions and Control Flow

CSE 452: Programming Languages Expressions and Control Flow Outline of Today s Lecture Expressions and Assignment Statements Arithmetic Expressions Overloaded Operators Type Conversions Relational and

### CS 426 Fall Machine Problem 1. Machine Problem 1. CS 426 Compiler Construction Fall Semester 2017

CS 426 Fall 2017 1 Machine Problem 1 Machine Problem 1 CS 426 Compiler Construction Fall Semester 2017 Handed Out: September 6, 2017. Due: September 21, 2017, 5:00 p.m. The machine problems for this semester

### Fundamentals of Compilation

PART ONE Fundamentals of Compilation 1 Introduction A compiler was originally a program that compiled subroutines [a link-loader]. When in 1954 the combination algebraic compiler came into use, or rather

### Compiler construction

Compiler construction Martin Steffen January 16, 2017 Contents 1 Abstract 1 1.1 Introduction............................................... 1 1.1.1 Introduction..........................................

### SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF CSE COURSE PLAN

Course Code : CS0301 Course Title : Compiler Design Semester : V Course Time : July Dec 2011 DAY SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF CSE COURSE PLAN SECTION

### Software II: Principles of Programming Languages

Software II: Principles of Programming Languages Lecture 4 Language Translation: Lexical and Syntactic Analysis Translation A translator transforms source code (a program written in one language) into

### GUJARAT TECHNOLOGICAL UNIVERSITY

Type of course: System Programming GUJARAT TECHNOLOGICAL UNIVERSITY SYSTEM PROGRAMMING SUBJECT CODE: 21508 B.E. 5 th SEMESTER Prerequisite: Data Structures and Operating Systems Rationale: NA Teaching

### Chapter 3: Operators, Expressions and Type Conversion

101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To

### LEXIMET: A Lexical Analyzer Generator including McCabe's Metrics.

IOSR Journal of Computer Engineering (IOSR-JCE) e-issn: 2278-0661, p- ISSN: 2278-8727Volume 16, Issue 1, Ver. VI (Feb. 2014), PP 11-18 LEXIMET: A Lexical Analyzer Generator including McCabe's Metrics.

### Semantic Analysis computes additional information related to the meaning of the program once the syntactic structure is known.

SEMANTIC ANALYSIS: Semantic Analysis computes additional information related to the meaning of the program once the syntactic structure is known. Parsing only verifies that the program consists of tokens

### Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University C: A High-Level Language! Gives

### Introduction. Interpreters High-level language intermediate code which is interpreted. Translators. e.g.

Introduction Translators Interpreters High-level intermediate code which is interpreted e.g. Program in a representation translator Program in another representation BASIC, LISP, APL command s, e.g. UNIX-shell

### Chapter 4: Writing and Designing a Complete Program. Programming Logic and Design, Third Edition Introductory

Chapter 4: Writing and Designing a Complete Program Programming Logic and Design, Third Edition Introductory Objectives After studying Chapter 4, you should be able to: Plan the mainline logic for a complete

### Semantic actions for declarations and expressions

Semantic actions for declarations and expressions Semantic actions Semantic actions are routines called as productions (or parts of productions) are recognized Actions work together to build up intermediate

### The Structure of a Compiler

The Structure of a Compiler A compiler performs two major tasks: Analysis of the source program being compiled Synthesis of a target program Almost all modern compilers are syntax-directed: The compilation

### Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University

Semantic Analysis CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Role of Semantic Analysis Syntax vs. Semantics: syntax concerns the form of a

### In this chapter you ll learn:

Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd Will you walk a little faster? said a whiting to a snail, There s a porpoise close behind us, and he s treading on

### Introduction to Programming Languages. CSE 307 Principles of Programming Languages Stony Brook University

Introduction to Programming Languages CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Introduction At the beginning: only machine language: a sequence

### Introduction to Parsing Ambiguity and Syntax Errors

Introduction to Parsing Ambiguity and Syntax rrors Outline Regular languages revisited Parser overview Context-free grammars (CFG s) Derivations Ambiguity Syntax errors Compiler Design 1 (2011) 2 Languages

### Motivation was to facilitate development of systems software, especially OS development.

A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

### SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTER SCIENCE AND ENGINEERING DEPARTMENT OF CSE COURSE PLAN Course Code : CS0301 Course Title : Compiler Design Semester : V Course Time

### Code Structure Visualization

TECHNISCHE UNIVERSITEIT EINDHOVEN Department of Mathematics and Computer Science MASTER S THESIS Code Structure Visualization by G.L.P.M. Lommerse Supervisor: Dr. Ir. A.C. Telea (TUE) Eindhoven, August

### CS 406/534 Compiler Construction Putting It All Together

CS 406/534 Compiler Construction Putting It All Together Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy

### 19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd

19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd Will you walk a little faster? said a whiting to a snail, There s a porpoise close behind us, and he s treading

### TDDD55- Compilers and Interpreters Lesson 3

TDDD55- Compilers and Interpreters Lesson 3 Zeinab Ganjei (zeinab.ganjei@liu.se) Department of Computer and Information Science Linköping University 1. Grammars and Top-Down Parsing Some grammar rules

### programming languages need to be precise a regular expression is one of the following: tokens are the building blocks of programs

Chapter 2 :: Programming Language Syntax Programming Language Pragmatics Michael L. Scott Introduction programming languages need to be precise natural languages less so both form (syntax) and meaning

### Special Section: Building Your Own Compiler

cshtp6_19_datastructures_compiler.fm Page 1 Tuesday, February 14, 2017 10:31 AM 1 Chapter 19 Special Section: Building Your Own Compiler In Exercises8.31 8.33, we introduced Simpletron Machine Language

### CS426 Compiler Construction Fall 2006

CS426 Compiler Construction David Padua Department of Computer Science University of Illinois at Urbana-Champaign 0. Course organization 2 of 23 Instructor: David A. Padua 4227 SC, 333-4223 Office Hours:

### EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing. Görel Hedin Revised:

EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing Görel Hedin Revised: 2017-09-04 This lecture Regular expressions Context-free grammar Attribute grammar

### Introduction To Java. Chapter 1. Origins of the Java Language. Origins of the Java Language. Objects and Methods. Origins of the Java Language

Chapter 1 Getting Started Introduction To Java Most people are familiar with Java as a language for Internet applications We will study Java as a general purpose programming language The syntax of expressions

### Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine

Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction

### Compiler Construction

Compiler Construction Introduction and overview Görel Hedin Reviderad 2013-01-22 2013 Compiler Construction 2013 F01-1 Agenda Course registration, structure, etc. Course overview Compiler Construction

### CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer

CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer Assigned: Thursday, September 16, 2004 Due: Tuesday, September 28, 2004, at 11:59pm September 16, 2004 1 Introduction Overview In this