Preview

Explain the Different Phases of Compiler with a Neat Diagram.

Better Essays
Open Document
Open Document
880 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Explain the Different Phases of Compiler with a Neat Diagram.
A compiler takes as input a source program and produces as output an equivalent sequence of machine instructions. This process is so complex that it is divided into a series of sub-processes called phases. The different phases of the compiler are as follows:

Phase 1: Lexical Analyzer or Scanner
The first phase of the compiler, called Lexical Analyzer or Scanner reads the source program one character at a time, carving the source program into a sequence of atomic units called tokens. The usual tokens are identifiers, keywords, constants, operators and punctuation symbols such as comma and parenthesis. Each token is a sub-string of the source program that is to be treated as a single unit. The Lexical analyzer examines successive character in the source program starting from the first character not yet grouped into a token. It may be required to search many characters beyond the next token in order to determine what the next token actually is.

Phases of a Compiler

Phase 2: Syntax Analyzer or Parser
The second phase of the compiler, called the Syntax Compiler or Parser receives a stream of tokens as the output of the lexical analyzer. The syntax analyzer groups tokens together into syntactic structure called as expression. Expression may further be combined to form statements. The syntactic structure can be regarded as a tree whose leaves are the token called as parse trees. The parser has two functions: i) Firstly, it checks if the tokens from lexical analyzer, occur in pattern that are permitted by the specification for the source language. It also imposes on tokens that are permitted by the specification for the source language. It also imposes on tokens a tree-like structure that is used by the subsequent phases of the compiler. ii) Secondly, it makes explicit the hierarchical structure of the incoming token stream by identifying which parts of the token stream should be grouped.

Phase 3: Intermediate Code Generation

You May Also Find These Documents Helpful

  • Satisfactory Essays

    SD1230 Lab 1

    • 239 Words
    • 2 Pages

    2. What type of instruction is used to execute different code based on a condition? -Jumps…

    • 239 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The second category of fault changes individual instructions in the text segment. These faults are intended to approximate the assembly-level manifestation of real C-level programming…

    • 285 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    In this phase a token is generated against all the lexemes in the source code. These lexemes and tokens are stored in the Symbol Table. Tokens against the lexemes are generated based on some patterns or rules.…

    • 703 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Homework Week 2

    • 743 Words
    • 3 Pages

    A compiler translates one computer language into another. It also pics up errors in the program being put together.…

    • 743 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    Nt1310 Unit 1

    • 4209 Words
    • 17 Pages

    It parses and also executes the statement Displays the execution plan for the select statement automatically…

    • 4209 Words
    • 17 Pages
    Powerful Essays
  • Satisfactory Essays

    1. It keeps a count of the number of times you want to use the program to input data…

    • 351 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    pt1420 exam review

    • 738 Words
    • 3 Pages

    What is used to translate high level language programs to machine language (or machine code)? Compiler…

    • 738 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Unit 5 PT1420

    • 959 Words
    • 7 Pages

    The case structure lets the value of a variable or an expression determine which path of execution the program will take.…

    • 959 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    Intro the Programming

    • 386 Words
    • 5 Pages

    The ________ is a collection of statements enclosed inside a set of curly braces that are performed when the method is…

    • 386 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The expression 1 To 5 in the Case 1 To 5 clause specifies the range of numbers from ____.…

    • 595 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Macro Examples

    • 1120 Words
    • 5 Pages

    7. The If…Then…Else…End If code allows code to be conditionally executed depending on whether a specified logical condition has been met.…

    • 1120 Words
    • 5 Pages
    Good Essays
  • Better Essays

    Symbol Table

    • 1792 Words
    • 8 Pages

    It is useful for a compiler to be able to grow the symbol table dynamically at compile time. If the symbol table is fixed when the compiler is written, the size must be chosen large enough to handle any source program that might be presented.…

    • 1792 Words
    • 8 Pages
    Better Essays
  • Good Essays

    Part of Speech Recognizer

    • 3200 Words
    • 13 Pages

    References: [1] S. L. Abebe and P. Tonella. Natural language parsing of program element names for concept extraction. In 18th IEEE International Conference on Program Comprehension. IEEE, 2010. [2] K. Atkinson. Spell checking oriented word lists (scowl). [3] E. Boschee, R. Weischedel, and A. Zamanian. Automatic information extraction. In Proceedings of the International Conference on Intelligence Analysis, 2005. [4] B. Caprile and P. Tonella. Restructuring program identifier names. In ICSM, 2000. [5] ML Collard, HH Kagdi, and JI Maletic. An XML-based lightweight C++ fact extractor. Program Comprehension, 2003. 11th IEEE International Workshop on, pages 134–143, 2003. [6] E. Høst and B. Østvold. The programmer’s lexicon, volume i: The verbs. In International Working Conference on Source Code Analysis and Manipulation, Beijing, China, September 2008. [7] E. W. Høst and B. M. Østvold. Debugging method names. In ECOOP 09. Springer Berlin / Heidelberg, 2009. [8] J. Jiang and C. Zhai. Instance weighting for domain adaptation in nlp. In ACL 2007, 2007. [9] D. Lawrie, D. Binkley, and C. Morrell. Normalizing source code vocabulary. In Proceedings of the 17th Working Conference on Reverse Engineering, 2010. [10] L. Shen, G. Satta, and A. K. Joshi. Guided learning for bidirectional sequence classification. In ACL 07. ACL, June 2007. [11] D. Shepherd, Z. P. Fry, E. Hill, L. Pollock, and K. Vijay-Shanker. Using natural language program analysis to locate and understand action-oriented conerns. In AOSD 07. ACM, March 2007. [12] K. Toutanova, D. Klein, C. Manning, and Y. Singer. Feature-rich part-of-speech tagging with a cyclic dependency network. In HLTNAACL 2003, 2003.…

    • 3200 Words
    • 13 Pages
    Good Essays
  • Good Essays

    Syntax

    • 268 Words
    • 2 Pages

    Syntax is the grammatical tool that deals with how sentences are put together and the relationship between words. It is a very methodical and logical sequence, ensuring that sentences are put together using subject, verb and object and that the words in the sentence all have agreement, so that the correct forms of words are used.…

    • 268 Words
    • 2 Pages
    Good Essays
  • Good Essays

    My Childhood

    • 582 Words
    • 3 Pages

    understanding of this programming language and inspire me to explore more. It is assumed that…

    • 582 Words
    • 3 Pages
    Good Essays