SlideShare une entreprise Scribd logo
1  sur  7
Télécharger pour lire hors ligne
UNIT –1
                              2 Marks and Answers
1. Define Compiler.

    Compiler is a program which takes one language (Source program) as input and translates it
into an equivalent another language (Target program).

              Input                           Output
                             Compiler
   Source program                             Target program

   During this process if some errors are encountered then compiler displays them as error
messages.

2. Describe the analysis-synthesis model of compiler.

    In the analysis part the source program is read and broken down into constituent pieces. The
syntax and the meaning of the source program is determined and then the intermediate code is
created.

    In the synthesis part this intermediate form of the source program is taken and converted into
a equivalent target program.

                                           Compiler


     Source                                                                               Target
    program                     Analysis               synthesis
                                                                                          program




3. Define a symbol table.

   The task of symbol table is to store identifiers used in the program. It also stores information
about attributes of each identifier such as its type, its scope, and storage allocated for it.

   It also stores information about the subroutines used in the program. In this case the attributes
may be name of the subroutine, number of arguments passed to it, its type and the method of
passing these arguments (call by value or call by reference) and the return type.

   Basically it is a data structure which stores information about all tokens.
4. What are the functions of pre-processor?

   Pre-processor allow users to use macros in the program. Macros are some set of instructions
   which can be repeatedly used in the program. Macro is a small set of instruction, whenever a
   macro name is defined. The macro names which are used in the program are expanded by the
   macro definition. Example for macro definition

   #define PI 3.14

   The PI value wherever used in the program are replaced by 3.14 during compilation by the
   preprocessor.

   #include <stdio.h> - this code will include the header file stdio.h before execution.



5. What is CFG? Give an example.

     Context free grammar is a notations used to specify the syntax of programming language and
it consists of

              1)   Terminals
              2)   Non-terminals
              3)   Start symbols
              4)   Productions

   Example-

       Expr  expr op expr

       Expr id

       Op  +

       Op  -

       Terminlas  id, +, -

       Non-terminals  expr, op

       Start symbols  expr

       Productions  4 productions (given)
6. List out any two compiler construction tools.
          1) Scanner generators
          2) Parser generators
          3) Syntax directed translation engines
          4) Data flow engines
          5) Automatic code generators

7. Mention some of the cousins of the compiler.
         1) Compiler
         2) Interpreter
         3) Assembler
         4) Preprocessor
         5) Loader & Linker

8. Define Pre processor.

   It is a program which performs some preliminary functions such as macros and file inclusion.
   Macros are small programs that are executed frequently. The macro names which are used in
   the program are expanded by the macro definition. Example for macro definition

   #define PI 3.14

   The PI value wherever used in the program are replaced by 3.14 during compilation by the
   preprocessor.

   #include <stdio.h> - this code will include the header file stdio.h before execution.


                                          Preprocessor
              Skeleton program                                 source program

9. Define Tokens, Lexeme and Attributes.

    Token - The meaningful collection of characters over the character set of the programming
language is called as the token.

    Lexeme - A lexeme is a sequence of tokens in the source program that is matched by the rule
for a token.

    Attributes – attributes specify the properties of tokens. The lexical analyzer collects
information about tokens and stores them as their attributes.
10. Define Translator and give example.

    A translator is one kind of program that takes one form of program that takes one form of
program as the input and converts it into another form. The input program is called source
language and the output program is called target language.

   Source                                           target
                              Translator
   language                                         language



11. Draw the transition diagram for a*/b*.
                                                        a
                                  a
                                               S1

            S0

                              b                S2


                                                         b




12. What is the function of a loader?

    Loader is a program which performs two functions: loading and link editing. Loading is a
process in which the relocatable machine code is read and the relocateable addresses are altered.
Then that code with altered instructions and data is placed the memory at proper location. The
job of link editor is to make a single program from several files of relocatable machine code. If
code in on file refers the location in another file then such a reference is called external
reference.

13. What is regular expression? Give an example.

    Regular expressions are mathematical symbolisms which describe the set of strings of
language. It provides convenient and useful notation for representing tokens.

Example-

      A regular expression (R.E) for a language containing the strings of length two over
∑={0,1}.

                 R.E = (0/1) (0/1)
14. Check whether the input string abab is accepted by the given production.

                        S  aSbS/bSaS/d

       Productions S  aSbS, S  bSaS, S  d To get the input string abab the derivation may
be

                        S  aSbS

                        S  abSabS

                        S  abaSbS

                        S ababS

                        S  abab

The input string abab is accepted.

15. Difference between Pass and Phase.

                    PHASE                                                 PASS
The process of compilation is carried out in        Various phases are logically grouped together
various steps.                                      to form a pass.
These steps are referred as phases.                 The process of compilation can be carried out
                                                    in single pass or in multiple passes.
The phases of compilation are lexical analysis,
syntax analysis, intermediate code,
Generation, code generation, code
optimization.


16. Write short notes on transition table and transition diagram with suitable example.

Transition table-

       This is a tabular representation of finite automata. For transition table the transition
function is used.

                    states                  A                b
                      q0                    q1                -
                      q1                     -               q2
                      q2                    q2                -


Transition diagram-

       A transition diagram or transition graph can be defined as collection of
1)   Finite set of states k
   2)   Finite set of symbols ∑
   3)   A non empty set states S of k. It is called start symbol.
   4)   A set F≤K of final
   5)   A transition function K*AK with K as states and A as input from ∑*.
        Example :

        The transition diagram for the input abb is

                       a                 b                  b
             S0               S1                  S2               S3




17. Write any 3 difference between compiler and interpreter.

               INTERPRETER                                              COMPILER
Demerit:                                              Merit:
       The source program gets interpreted                  In the process of compilation the program
every time it is to be executed, and every time       is analyzed only once and then the code is
the source program is analyzed. Hence,                generated. Hence compiler is efficient than
interpretation is less efficient than compiler.       interpreter.
The interpreter s do not produce object code.         The compilers produce object code.
Merit:                                                Demerits:
       The interpreters can be made portal                  The compiler has to present on the host
because they do not produce object code.              machine when particular needs to be compiled.
Merits:                                               Demerits:
       Interpreters are simpler and give us                  The compiler is a complex program and
improved debugging environment.                       it requires large amount of memory.


18. Mention some of the issues of lexical analyzer.

The various issues in lexical analysis are

   1) The lexical analysis and syntax analysis are separated out for simplifying the task of one
      or other phases. This separation reduces the burden on parsing phase.
   2) Compiler efficiency gets increased if the lexical analyzer is separated. This is because a
      large amount of time is spent on reading the source file. And it would be inefficient if
      each phase has to read the source file. Lexical analyzer uses buffering techniques for
      efficient scan of source file. The tokens obtained can be stored in input buffer to increase
      performance of compiler.
3) Input alphabet peculiarities and other device specific anomalies can be restricted to the
      lexical analyzer can be isolated in lexical analyzer. For example, in pascal, ↑ can be
      isolated in lexical analyzer.

19. What do you meant by sentinel?

The ‘eof’’ character, which is introduced at the end of the buffer is called sentinel. It is used to
identify the end of the buffer.

                             Buffer 1             bp

                i        n    t         i    =      i
                    +    1    ;    J    =   1      eof

                    fp       buffer 2           sentinal


20. Define book keeping.
    ‘Symbol table’ is also called as Book keeping. All the information about the tokens are in
    the symbol table.

   The task of symbol table is to store identifiers used in the program. It also stores information
about attributes of each identifier such as its type, its scope, and storage allocated for it.

   It also stores information about the subroutines used in the program. In this case the attributes
may be name of the subroutine, number of arguments passed to it, its type and the method of
passing these arguments (call by value or call by reference) and the return type.

Basically it is a data structure which stores information about all tokens

Contenu connexe

Tendances

Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1bolovv
 
Compiler design important questions
Compiler design   important questionsCompiler design   important questions
Compiler design important questionsakila viji
 
Compiler design
Compiler designCompiler design
Compiler designsanchi29
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compilerIffat Anjum
 
Chapter One
Chapter OneChapter One
Chapter Onebolovv
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overviewamudha arul
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler ConstructionSarmad Ali
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop AssemblerTuhin_Das
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Tirumala Rao
 
Declare Your Language: What is a Compiler?
Declare Your Language: What is a Compiler?Declare Your Language: What is a Compiler?
Declare Your Language: What is a Compiler?Eelco Visser
 
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Rohit Singh
 
Introduction to programming with c,
Introduction to programming with c,Introduction to programming with c,
Introduction to programming with c,Hossain Md Shakhawat
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programmingMithun DSouza
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Eelco Visser
 

Tendances (20)

Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1
 
Compiler design important questions
Compiler design   important questionsCompiler design   important questions
Compiler design important questions
 
Compiler design
Compiler designCompiler design
Compiler design
 
Compiler unit 1
Compiler unit 1Compiler unit 1
Compiler unit 1
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
Ch1
Ch1Ch1
Ch1
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Chapter One
Chapter OneChapter One
Chapter One
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overview
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop Assembler
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02
 
Declare Your Language: What is a Compiler?
Declare Your Language: What is a Compiler?Declare Your Language: What is a Compiler?
Declare Your Language: What is a Compiler?
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)
 
Introduction to programming with c,
Introduction to programming with c,Introduction to programming with c,
Introduction to programming with c,
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
 

En vedette (6)

Ths091010
Ths091010Ths091010
Ths091010
 
June 2009 Newsletter A
June 2009 Newsletter AJune 2009 Newsletter A
June 2009 Newsletter A
 
Guide
GuideGuide
Guide
 
2014 Homecoming information
2014 Homecoming information2014 Homecoming information
2014 Homecoming information
 
Guest Form Twirp
Guest Form TwirpGuest Form Twirp
Guest Form Twirp
 
Wk3 Ppcd Presentation2
Wk3   Ppcd Presentation2Wk3   Ppcd Presentation2
Wk3 Ppcd Presentation2
 

Similaire à Unit1 cd

Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)guest91cc85
 
Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Anil Thakral
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in detailskazi_aihtesham
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docxvenkatapranaykumarGa
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdfAkarTaher
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxdawod yimer
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptxssuser3b4934
 
Language translators
Language translatorsLanguage translators
Language translatorsAditya Sharat
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfDrIsikoIsaac
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction Thapar Institute
 
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATORPSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATORijistjournal
 
design intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdfdesign intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdfadvRajatSharma
 
Chapter-1.pptx compiler Design Course Material
Chapter-1.pptx compiler Design Course MaterialChapter-1.pptx compiler Design Course Material
Chapter-1.pptx compiler Design Course MaterialgadisaAdamu
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introductionRana Ehtisham Ul Haq
 
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGESOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGEIJCI JOURNAL
 

Similaire à Unit1 cd (20)

Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
 
Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
 
Language translators
Language translatorsLanguage translators
Language translators
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
 
3.2
3.23.2
3.2
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
 
Compiler
Compiler Compiler
Compiler
 
Compiler Design Introduction
Compiler Design Introduction Compiler Design Introduction
Compiler Design Introduction
 
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATORPSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
PSEUDOCODE TO SOURCE PROGRAMMING LANGUAGE TRANSLATOR
 
design intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdfdesign intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdf
 
Chapter-1.pptx compiler Design Course Material
Chapter-1.pptx compiler Design Course MaterialChapter-1.pptx compiler Design Course Material
Chapter-1.pptx compiler Design Course Material
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGESOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
SOFTWARE TOOL FOR TRANSLATING PSEUDOCODE TO A PROGRAMMING LANGUAGE
 

Dernier

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Dernier (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

Unit1 cd

  • 1. UNIT –1 2 Marks and Answers 1. Define Compiler. Compiler is a program which takes one language (Source program) as input and translates it into an equivalent another language (Target program). Input Output Compiler Source program Target program During this process if some errors are encountered then compiler displays them as error messages. 2. Describe the analysis-synthesis model of compiler. In the analysis part the source program is read and broken down into constituent pieces. The syntax and the meaning of the source program is determined and then the intermediate code is created. In the synthesis part this intermediate form of the source program is taken and converted into a equivalent target program. Compiler Source Target program Analysis synthesis program 3. Define a symbol table. The task of symbol table is to store identifiers used in the program. It also stores information about attributes of each identifier such as its type, its scope, and storage allocated for it. It also stores information about the subroutines used in the program. In this case the attributes may be name of the subroutine, number of arguments passed to it, its type and the method of passing these arguments (call by value or call by reference) and the return type. Basically it is a data structure which stores information about all tokens.
  • 2. 4. What are the functions of pre-processor? Pre-processor allow users to use macros in the program. Macros are some set of instructions which can be repeatedly used in the program. Macro is a small set of instruction, whenever a macro name is defined. The macro names which are used in the program are expanded by the macro definition. Example for macro definition #define PI 3.14 The PI value wherever used in the program are replaced by 3.14 during compilation by the preprocessor. #include <stdio.h> - this code will include the header file stdio.h before execution. 5. What is CFG? Give an example. Context free grammar is a notations used to specify the syntax of programming language and it consists of 1) Terminals 2) Non-terminals 3) Start symbols 4) Productions Example- Expr  expr op expr Expr id Op  + Op  - Terminlas  id, +, - Non-terminals  expr, op Start symbols  expr Productions  4 productions (given)
  • 3. 6. List out any two compiler construction tools. 1) Scanner generators 2) Parser generators 3) Syntax directed translation engines 4) Data flow engines 5) Automatic code generators 7. Mention some of the cousins of the compiler. 1) Compiler 2) Interpreter 3) Assembler 4) Preprocessor 5) Loader & Linker 8. Define Pre processor. It is a program which performs some preliminary functions such as macros and file inclusion. Macros are small programs that are executed frequently. The macro names which are used in the program are expanded by the macro definition. Example for macro definition #define PI 3.14 The PI value wherever used in the program are replaced by 3.14 during compilation by the preprocessor. #include <stdio.h> - this code will include the header file stdio.h before execution. Preprocessor Skeleton program source program 9. Define Tokens, Lexeme and Attributes. Token - The meaningful collection of characters over the character set of the programming language is called as the token. Lexeme - A lexeme is a sequence of tokens in the source program that is matched by the rule for a token. Attributes – attributes specify the properties of tokens. The lexical analyzer collects information about tokens and stores them as their attributes.
  • 4. 10. Define Translator and give example. A translator is one kind of program that takes one form of program that takes one form of program as the input and converts it into another form. The input program is called source language and the output program is called target language. Source target Translator language language 11. Draw the transition diagram for a*/b*. a a S1 S0 b S2 b 12. What is the function of a loader? Loader is a program which performs two functions: loading and link editing. Loading is a process in which the relocatable machine code is read and the relocateable addresses are altered. Then that code with altered instructions and data is placed the memory at proper location. The job of link editor is to make a single program from several files of relocatable machine code. If code in on file refers the location in another file then such a reference is called external reference. 13. What is regular expression? Give an example. Regular expressions are mathematical symbolisms which describe the set of strings of language. It provides convenient and useful notation for representing tokens. Example- A regular expression (R.E) for a language containing the strings of length two over ∑={0,1}. R.E = (0/1) (0/1)
  • 5. 14. Check whether the input string abab is accepted by the given production. S  aSbS/bSaS/d Productions S  aSbS, S  bSaS, S  d To get the input string abab the derivation may be S  aSbS S  abSabS S  abaSbS S ababS S  abab The input string abab is accepted. 15. Difference between Pass and Phase. PHASE PASS The process of compilation is carried out in Various phases are logically grouped together various steps. to form a pass. These steps are referred as phases. The process of compilation can be carried out in single pass or in multiple passes. The phases of compilation are lexical analysis, syntax analysis, intermediate code, Generation, code generation, code optimization. 16. Write short notes on transition table and transition diagram with suitable example. Transition table- This is a tabular representation of finite automata. For transition table the transition function is used. states A b q0 q1 - q1 - q2 q2 q2 - Transition diagram- A transition diagram or transition graph can be defined as collection of
  • 6. 1) Finite set of states k 2) Finite set of symbols ∑ 3) A non empty set states S of k. It is called start symbol. 4) A set F≤K of final 5) A transition function K*AK with K as states and A as input from ∑*. Example : The transition diagram for the input abb is a b b S0 S1 S2 S3 17. Write any 3 difference between compiler and interpreter. INTERPRETER COMPILER Demerit: Merit: The source program gets interpreted In the process of compilation the program every time it is to be executed, and every time is analyzed only once and then the code is the source program is analyzed. Hence, generated. Hence compiler is efficient than interpretation is less efficient than compiler. interpreter. The interpreter s do not produce object code. The compilers produce object code. Merit: Demerits: The interpreters can be made portal The compiler has to present on the host because they do not produce object code. machine when particular needs to be compiled. Merits: Demerits: Interpreters are simpler and give us The compiler is a complex program and improved debugging environment. it requires large amount of memory. 18. Mention some of the issues of lexical analyzer. The various issues in lexical analysis are 1) The lexical analysis and syntax analysis are separated out for simplifying the task of one or other phases. This separation reduces the burden on parsing phase. 2) Compiler efficiency gets increased if the lexical analyzer is separated. This is because a large amount of time is spent on reading the source file. And it would be inefficient if each phase has to read the source file. Lexical analyzer uses buffering techniques for efficient scan of source file. The tokens obtained can be stored in input buffer to increase performance of compiler.
  • 7. 3) Input alphabet peculiarities and other device specific anomalies can be restricted to the lexical analyzer can be isolated in lexical analyzer. For example, in pascal, ↑ can be isolated in lexical analyzer. 19. What do you meant by sentinel? The ‘eof’’ character, which is introduced at the end of the buffer is called sentinel. It is used to identify the end of the buffer. Buffer 1 bp i n t i = i + 1 ; J = 1 eof fp buffer 2 sentinal 20. Define book keeping. ‘Symbol table’ is also called as Book keeping. All the information about the tokens are in the symbol table. The task of symbol table is to store identifiers used in the program. It also stores information about attributes of each identifier such as its type, its scope, and storage allocated for it. It also stores information about the subroutines used in the program. In this case the attributes may be name of the subroutine, number of arguments passed to it, its type and the method of passing these arguments (call by value or call by reference) and the return type. Basically it is a data structure which stores information about all tokens