COMPILER DESIGN LEXICAL ANALYSIS, PARSING

Similar documents
4. An interpreter is a program that

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

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

1. The output of lexical analyser is a) A set of RE b) Syntax Tree c) Set of Tokens d) String Character

CST-402(T): Language Processors

LECTURE NOTES ON COMPILER DESIGN P a g e 2

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

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTER SCIENCE AND ENGINEERING COURSE PLAN

1. (a) What are the closure properties of Regular sets? Explain. (b) Briefly explain the logical phases of a compiler model. [8+8]


2) Save the Macro definition:- The processor must store the macro instruction definitions which it will need for expanding macro calls.

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

SYED AMMAL ENGINEERING COLLEGE (An ISO 9001:2008 Certified Institution) Dr. E.M. Abdullah Campus, Ramanathapuram

CS606- compiler instruction Solved MCQS From Midterm Papers

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY

COMPILER DESIGN. For COMPUTER SCIENCE

Question Bank. 10CS63:Compiler Design

INSTITUTE OF AERONAUTICAL ENGINEERING (AUTONOMOUS)

B. the address of the data is supplied by the users C. there is no need for an address i.e. the data is used as an address

The analysis part breaks up the source program into constituent pieces and creates an intermediate representation of the source program.

PRINCIPLES OF COMPILER DESIGN

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILING

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER-15 EXAMINATION Model Answer Paper

CS 4201 Compilers 2014/2015 Handout: Lab 1

SYSTEMS PROGRAMMING. Srimanta Pal. Associate Professor Indian Statistical Institute Kolkata OXFORD UNIVERSITY PRESS

COMPILER DESIGN LECTURE NOTES

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

Life Cycle of Source Program - Compiler Design

AS-2883 B.Sc.(Hon s)(fifth Semester) Examination,2013 Computer Science (PCSC-503) (System Software) [Time Allowed: Three Hours] [Maximum Marks : 30]

Compiler Design Aug 1996

Working of the Compilers

VIVA QUESTIONS WITH ANSWERS

Compiler Design. Computer Science & Information Technology (CS) Rank under AIR 100

SYLLABUS UNIT - I UNIT - II UNIT - III UNIT - IV CHAPTER - 1 : INTRODUCTION CHAPTER - 4 : SYNTAX AX-DIRECTED TRANSLATION TION CHAPTER - 7 : STORA

Computer Hardware and System Software Concepts

PSD3A Principles of Compiler Design Unit : I-V. PSD3A- Principles of Compiler Design

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

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

2068 (I) Attempt all questions.

Building a Runnable Program and Code Improvement. Dario Marasco, Greg Klepic, Tess DiStefano

Compiler, Assembler, and Linker

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

CS131: Programming Languages and Compilers. Spring 2017

COP 3402 Systems Software. Lecture 4: Compilers. Interpreters

Compiler Design Overview. Compiler Design 1

Syntax Analysis. Chapter 4

Compilers and Interpreters

MODEL ANSWER SUMMER 17 EXAMINATION 17517

MidTerm Papers Solved MCQS with Reference (1 to 22 lectures)

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

SEM / YEAR : VI / III CS2352 PRINCIPLES OF COMPLIERS DESIGN UNIT I - LEXICAL ANALYSIS PART - A

Section A. A grammar that produces more than one parse tree for some sentences is said to be ambiguous.

Introduction to Compiler Construction

Front End. Hwansoo Han


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

Formal Languages and Compilers Lecture I: Introduction to Compilers

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

Introduction to Compiler Construction

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation

Gujarat Technological University Sankalchand Patel College of Engineering, Visnagar B.E. Semester VII (CE) July-Nov Compiler Design (170701)

Compiler Design. Lecture 1

VALLIAMMAI ENGINEERING COLLEGE

Compiler Code Generation COMP360

VETRI VINAYAHA COLLEGE OF ENGINEERING AND TECHNOLOGY

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

KALASALINGAM UNIVERSITY ANAND NAGAR, KRISHNAN KOIL DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ODD SEMESTER COURSE PLAN

DEPARTMENT OF INFORMATION TECHNOLOGY / COMPUTER SCIENCE AND ENGINEERING UNIT -1-INTRODUCTION TO COMPILERS 2 MARK QUESTIONS

SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION SECTION -A

Alternatives for semantic processing

COMPILER DESIGN UNIT I LEXICAL ANALYSIS. Translator: It is a program that translates one language to another Language.

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

GUJARAT TECHNOLOGICAL UNIVERSITY

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

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

G.PULLAIH COLLEGE OF ENGINEERING & TECHNOLOGY

Compiling Regular Expressions COMP360

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

Compilers. Prerequisites

Compiler Design (40-414)

Compilers. Computer Science 431

Programmiersprachen (Programming Languages)

GUJARAT TECHNOLOGICAL UNIVERSITY

CJT^jL rafting Cm ompiler

Sardar Vallabhbhai Patel Institute of Technology (SVIT), Vasad M.C.A. Department COSMOS LECTURE SERIES ( ) (ODD) Code Optimization

INSTITUTE OF AERONAUTICAL ENGINEERING

A simple syntax-directed

MODULE 5 LINKERS AND LOADERS

COLLEGE OF ENGINEERING, NASHIK. LANGUAGE TRANSLATOR

1. INTRODUCTION TO LANGUAGE PROCESSING The Language Processing System can be represented as shown figure below.

Decompilation of Binary Programs & Structuring Decompiled Graphs

Introduction to Compiler Construction

1. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail.

Model Answer of System Software B. Tech. (4 th Semester Examination) Paper Code: AR Branch: Information Technology

Introduction to Compiler Construction

CS5363 Final Review. cs5363 1

Name of chapter & details

Dixita Kagathara Page 1

Assembly Language Fundamentals

Transcription:

COMPILER DESIGN LEXICAL ANALYSIS, PARSING 1. Which of the following system program forgoes the production of object code to generate absolute machine code and load it into the Physical main storage location from which it will be executed immediately upon completion of the assembly? (a) Two pass assembler (b) Load-and-go assembler (c) Macro processor (d) Compiler 2. System program such as compiler are designed so that they are (a) Re-enterable (b) Non-reusable (c) Serially usable (d) Recursive 3. A system program that set-up an executable program in main memory ready for execution is (a) Assembler (b) Linker (c) Loader (d) Text editor 4. Assembler is a program that (a) Places programs into memory and prepares them for execution (b) Automates the translation of assembly language into machine language (c) Accepts a program written in a high level language and produces an object program. (d) Appears to execute a resource as if it were machine language. 5. An interpreter is a program that (a) Places programs into memory and prepares them for execution. (b) Automates the translation of assembly language into machine language. (c) Accesses a program written in a high level language and produces an object program. (d) Appears to execute a source program as if it were machine language. 6. A compiler is a program that (a) Places programs into memory and prepares them for execution. (b) Automates the translation of assembly language into machine language. (c) Accepts a program written in a high level language and produces an object program. (d) Appears to execute a source program as if it were machine language. 7. A compiler program written language is called (a) Source program (b) Object program

(c) Machine language program 8. Compiler can diagnose (a) Grammatical errors only (b) Logical errors only (c) Grammatical as well as logical errors (d) Neither grammatical nor logical errors 9. A programmer, by mistake, writes an instruction to divide, instead of a multiply, such error can be detected by a/an (a) Compiler (b) Interpreter (c) Compiler or interpreter test 10. A series of statements explaining how the data is to be processed is called (a) Assembly (b) Machine (c) Pascal (d) Program 11. The computer language generally translated to pseudocode is (a) Assembly (b) Machine (c) Pascal (d) PL I 12. Language which have many types, but the type of every name and expression must be calculated at complete time are (a) Strongly-type languages (b) Weakly typed languages (c) Loosely typed languages 13. A system program that sets up an executable program in main memory ready for execution is (a) Assembler (b) Linker (c) Loader (d) Load and go 14. A system program that combines separately compiled modules of a program into a form suitable for execution is (a) Assembler (b) Linking loader (c) Cross compiler (d) Load and go

15. Advantage of using assembly language rather than machine language is that (a) It is mnemonic and easy to read (b) Addresses any symbolic not absolute (c) Introduction of data to program is easier (d) All of these 16. Advantage of incorporating the macro-processor into pass-i is that (a) Many functions do not have to be implemented twice. (b) Functions are combined and it is not necessary to create intermediate files as output from the macro-processor and input to the assembler. (c) More flexibility is available to the programmer in that he may use all the features of the assembler in conjunction with macros. (d) All of these 17. In which way a macro processor for assembly language can be implemented? (a) Independent two-pass processor (b) Independent one-pass processor (c) Processor incorporated into pass 1 of a standard two pass assembler (d) All of these 18. In an absolute loading scheme, which loader function is accomplished by programmer? (a) Allocation (b) Linking (c) Reallocation (d) Both (a) and (b) 19. Uniform symbol table (a) Contains all constants in the program. (b) Is a permanent table of decision rules in the form of patterns for matching with the uniform symbol table to discover syntactic structure. (c) Consists of full or partial list of the token's as they appear in the program. Created by Lexical analysis and used for syntax analysis and interpretation. (d) A permanent table which lists all key words and special symbols of the language in symbolic form. 20. Which of the following is a phase of a compilation process? (a) Lexical analysis (b) Code generation (c) Both (a) and (b)

SYNTAX DIRECTED TRANSLATION 21. Which of the following translation program converts assembly language programs to object program? (a)assembler (b) Compiler (c) Macro processor (d) Linker 22. In a single pass assembler, most of the forward references can he avoided by putting the restriction (a) On the number of strings/ life- reacts., (b) That the data segment must be defined after the code segment. (c) On unconditional rump. (d) That the data segment be defined before the code segment. 23. The segment base is specified using the register named is a) ORG instructions (b) TITLE instruction (c) ASSUME instruction (d) SEGMENT instruction 24. Which is not true about syntax and semantic parts of a computer language? (a) Syntax is generally checked by the programmer. (b) Semantics is the responsibility of the programmer. (c) Semantics is checked mechanically by a computer (d) Both (b) and (c) 25. Left factoring is the process of factoring out common (a) Prefixed of alternates (b) Suffixes of alternates (c) Predictive parsing 26. A linker is given object module for a set of programs that were compiled separately. What information need not be included in an object module? (a) Object code (b) Relocation bits (c) Names and locations of all external symbols defined in the object module (d) Absolute addresses of internal symbols. 27. The root directory of a disk should be placed (a) at a fixed address in main memory at a fixed location On the disk (C) anywhere on the disk (d) On a fixed location on system disk 28. Which of the following is true for machine language? (a) Repeated execution of program segments

(b) Depicting flow of data in a system (c) A sequence of instructions which, when followed properly, solves a problem (d) The language which communicates with the computer using only the binary digits 1. and 0. 29. Which of the following statement is true? (a) SLR parser is more powerful than LALR. (b) LAIR parser is more powerful than Canonical LR parser. (c) canonical LR parser is more powerful than LALR parser. (d) The parsers SLR, Canonical LR and LALR have the same power. 30. Which of the following strings can definitely be said to be tokens without looking at the next input character while compiling a Pascal program? (a) Begin (b) Program (c)< > (d) All of these 31. Relative mode of addressing most relevant to writing (a) Co-routines (b) position-independent code (c) shareable code (d) interrupt handlers 32. An ideal compiler should (a) be smaller in size and take less time for compiling (b) be written in a high level language (c) produce object code that is smaller in size and executes faster 33. Syntax directed translation scheme is desirable because (a) it is based on the syntax (b) its description is independent Of any implementation (c) it is easy to modify

RUNTIME ENVIRONMENTS, INTERMEDIATE AND TARGET CODE 34. In which of the following no information hiding is done? (a) compile prog 1, prog 2 (b) run test, prog (c) load R 1, A (d) 001001000010101 35. The identification of common sub-expression and replacement of run-time computations by compile-time computations is (a) local optimization (b) loop optimization (c) constant d) data flow analysis 36. The graph that shows basic blocks and their successor relationship is called (a) DAG (b) Flow graph (c) Control graph (d) Hamiltonian graph 37. The specific tasks storage manager performs are (a)allocation/de-allocation of storage to programs (b) protection of storage area allocated to a program from illegal access by other programs in the system. (c) the status of each program (d) both (a) and (b) 38. When a computer is first turned on or restarted, a special type of absolute loader is executed called (a) "Compile and GO" loader (b) Boot loader (c) Boot strap loader (d) Relating loader 39. Disadvantage of "Compile and go" loading scheme is that (a) a portion of memory is wasted because the case occupied by the assembler is unavailable to the object program. (b) it is necessary to retranslate the users program deck every time it is run. (c) it is very difficult to handle multiple segments, especially if the source programs are in different languages and to produce orderly modular programs. (4) all of these

BASICS OF CODE OPTIMIZATION 40. In analyzing the compilation of PL/I program the description "resolving symbolic address (labels) and generating machine language" is associated with (a) assembly and output (b) code generation (c) storage assignment (d) syntax analysis 41. In analyzing the compilation of PL/I program the description "creation of more optimal matrix" is associated with (a) assembly and output (b) code generation (c) syntax analysis (d) machine independent optimization 42. Peephole optimization is a form of (a) loop optimization (b) local optimization (c) constant folding (d) data flow analysis 43. Substitution of values for names whose values are constant, is done in (a) local optimization (b) loop optimization (c) 4 constant folding (d) none of these 44. Local and loop optimization inturn provide motivation for (a) data flow analysis (b) constant folding (c) peephole optimization (d) DFA and constant folding 45. A compiler for a high level language that runs on one machine and produces code for a different machine is called (a) optimizing compiler (b) one pass compiler j cross compiler (d) multipass compiler 46. An optimizing compiler (a) is optimized to occupy less space (b) is optimized to take less time for execution (c) optimizes the code (d) none of these 47. Whether a given pattern constitutes a token or not, depends on the (a) source language (b) target language

(c) Compiler 48. The optimization technique which is typically applied on loops is (a) removal of invariant computation (b) peephole optimization (c) constant folding 49. Ud-chaining is useful for (a) determining whether a particular definition is used anywhere or not (b) constant folding (c) checking whether a variable is used, without prior assignment 50. Concept which can be used to identify loops is (a) dominators (b) reducible graphs (c) depth first ordering