Featured

Compiler Design

Understand About Compiler Design :

  • Simply Saying, Compiler Design is a conversion of some HL language ( High Level ) into a LL Language ( Low Level ).
  • In other words, HL language into Machine Language.
  • Some People Says  it as User Understandable language into Machine Understandable Language.
  • All the things which said above are meant to be same, Experts says it in different ways.

* Here, machine understandable language are 0’s and 1’s (Binary).

* User( Programmers ) understandable language are alphabets and numbers.

  • In terms of time and space, it’s expected that a compiler should make the target code efficient and optimized.

PRINCIPLE :

  • It provides a view of the optimization and translation process.
  • It can do both error detection and error recovery.

FRONT END :

  • Lexical analysis
  • Syntax analysis
  • Semantic analysis

BACK END:

  • Code generation
  • Optimization.
Advertisements

Lexical Analyzer

What is the role of lexical analyzer ?

PRIMARY TASK:

  • The lexical analyzer is the first phase of compiler.
  • The main task of lexical analyzer is to read the i/p (input) characters and produce o/p (output) as a sequence of tokens the parser uses it for syntax analysis.
  • It is used as a subroutine or co-routine of the parser.

SECONDARY TASK:

  • Read the source text and detects the token
  • Stripe out comments,white spaces, tab, newline characters
  • Correlates error messages from compilers to source program.

Two Types of Lexical Analysis Processes :

  • Scanning: Simple tasks (to eliminate blanks)
  • Lexical Analysis: Complex Operations

Issues in LA( Lexical Analyzer ) :

  1. Simplicity of design
  2. Improving compiler efficiency
  3. Enhancing compiler portability

—Major Terms for Lexical Analysis?

  • PATTERN

–The rules which characterize the set of strings for a token

–A rule describing the set of lexemes that can represent particular token in the source program

  • TOKEN

–A classification for a common set of strings

–Examples Include <Identifier>, <number>, keywords, operators, punctuation symbols, etc.

  • LEXEME

–Actual sequence of characters in the source program that is matched by the pattern and is classified by a token

–Identifiers: x, count, name, etc…