SlideShare una empresa de Scribd logo
1 de 7
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1
bolovv
 
Chapter One
Chapter OneChapter One
Chapter One
bolovv
 
Workshop Assembler
Workshop AssemblerWorkshop Assembler
Workshop Assembler
Tuhin_Das
 

La actualidad más candente (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?
 

Destacado (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
 

Similar a Unit1 cd

Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02
Anil Thakral
 
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
venkatapranaykumarGa
 
Language translators
Language translatorsLanguage translators
Language translators
Aditya Sharat
 

Similar a 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
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
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
QucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Último (20)

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
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...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
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
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

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