SlideShare a Scribd company logo
2
Most read
7
Most read
9
Most read
Sardar VallabhBhai Patel Institute
Of Technology
 Name: RAJAN
SHAH
 Topic: LEX
TOOL
Language Processor Development
Tools
 The analysis phase of language processor has
a std form irrespective of its purpose, the
source text is subjected to lexical, syntax,
semantic analysis and the results of analysis
are represented in an IR (Intermediate
Representation).
 LPDT’s focus on generation of the analysis
phase of language processors.
LEXICAL ANALYZER
 Lexical analysis identifies the lexical units in the
source statement.
 It then classifies them into different lexical
classes, e.g. id’s, constants etc. and enter them
into different tables.
 Lexical analysis builds a descriptor, called a
TOKEN, for each lexical unit.
 A Token contains two fields: class code, and
number in class.
 Token is depicted as : Code#no, e.g. Id#2.
LEX
 Lexical analyzers tokenize input streams
 Tokens are the terminals of a language
 English: words, punctuation marks, …
 Programming language: Identifiers, operators,
keywords, …
 Regular expressions define terminals/tokens
Continue...
 LEX accepts an i/p specification which
consists of following two part:
1. Specification of strings representing the
lexical units in L, e.g. Id’s and constants.
2. Specification of semantic actions aimed at
building an IR. The semantic actions makes
new entries in the tables and build tokens for
the lexical units.
LEX Program
 %{
letter [A-Za-z]
digit [0-9]
}%
 This component defines the symbol used in
specifying the string of L. It defines the symbol
‘letter’ to stand for any upper/lower case letter.
Continue...
 %%
begin {return (BEGIN); }
end {return (END); }
“:=” {return (ASGOP); }
{letter} ({letter} ¦ {digit}) * {yylval=enter_id();
return (ID); }
{digit}+ {yylval=enter_num();
return (num); }
%%
Continue...
 enter_id()
{ /* enters the id in the symbol table and
returns the entry number. */ }
 enter_num()
{ /* enters the number in the constants table
and returns entry number */ }
Overview of LEX
 Lexical Analyzer lex.yy.c
 lex.yy.c a.out
 Input tokens
Lex
C compiler
a.out
LEX with YACC
THANKY
OU

More Related Content

PPTX
Intermediate code
PPT
Intermediate code generation (Compiler Design)
PDF
Compiler Design Lecture Notes
PDF
Code optimization in compiler design
PDF
Oops concepts || Object Oriented Programming Concepts in Java
PPT
Assembler
PPTX
PDF
Basic blocks and flow graph in Compiler Construction
Intermediate code
Intermediate code generation (Compiler Design)
Compiler Design Lecture Notes
Code optimization in compiler design
Oops concepts || Object Oriented Programming Concepts in Java
Assembler
Basic blocks and flow graph in Compiler Construction

What's hot (20)

PPTX
Phases of Compiler
PDF
Symbol table in compiler Design
PPTX
Single pass assembler
PPTX
Problem reduction AND OR GRAPH & AO* algorithm.ppt
PPT
Bottom - Up Parsing
PPTX
Introduction to loaders
PPTX
Lexical Analysis - Compiler Design
PPTX
System software - macro expansion,nested macro calls
PPTX
Principle source of optimazation
PPT
Introduction to c programming
PPT
Intermediate code generation
PPTX
Compiler construction
PPTX
System Programming Overview
PPT
Unit 2 Principles of Programming Languages
PPTX
Lexical analysis - Compiler Design
PPTX
CONTEXT FREE GRAMMAR
PPTX
Assembler - System Programming
PPTX
Recognition-of-tokens
PPTX
Phases of compiler
PPTX
Back patching
Phases of Compiler
Symbol table in compiler Design
Single pass assembler
Problem reduction AND OR GRAPH & AO* algorithm.ppt
Bottom - Up Parsing
Introduction to loaders
Lexical Analysis - Compiler Design
System software - macro expansion,nested macro calls
Principle source of optimazation
Introduction to c programming
Intermediate code generation
Compiler construction
System Programming Overview
Unit 2 Principles of Programming Languages
Lexical analysis - Compiler Design
CONTEXT FREE GRAMMAR
Assembler - System Programming
Recognition-of-tokens
Phases of compiler
Back patching
Ad

Similar to Lex Tool (20)

PDF
Handout#02
PPTX
Language for specifying lexical Analyzer
PPT
Module4 lex and yacc.ppt
PPT
LEX Intrduction Compiler Construction_VIET.ppt
PPT
module 4_ Lex_new.ppt
PDF
role of lexical parser compiler design1-181124035217.pdf
PPT
1.Role lexical Analyzer
PPTX
Compiler Design_LEX Tool for Lexical Analysis.pptx
DOCX
Compiler Design
PDF
11700220036.pdf
PPTX
Cd ch2 - lexical analysis
PPTX
Chapter 2.pptx compiler design lecture note
PDF
COMPILER DESIGN.pdf
PPT
Lexical Analysis
PPT
Chapter-2-lexical-analyser and its property lecture note.ppt
PDF
An Introduction to the Compiler Designss
PDF
LANGUAGE PROCESSOR
PPT
Data design and analysis of computing tools
PPTX
Role-of-lexical-analysis
Handout#02
Language for specifying lexical Analyzer
Module4 lex and yacc.ppt
LEX Intrduction Compiler Construction_VIET.ppt
module 4_ Lex_new.ppt
role of lexical parser compiler design1-181124035217.pdf
1.Role lexical Analyzer
Compiler Design_LEX Tool for Lexical Analysis.pptx
Compiler Design
11700220036.pdf
Cd ch2 - lexical analysis
Chapter 2.pptx compiler design lecture note
COMPILER DESIGN.pdf
Lexical Analysis
Chapter-2-lexical-analyser and its property lecture note.ppt
An Introduction to the Compiler Designss
LANGUAGE PROCESSOR
Data design and analysis of computing tools
Role-of-lexical-analysis
Ad

More from Rajan Shah (10)

PPTX
Xml dtd- Document Type Definition- Web Technology
PPTX
Timing and control circuit
PPTX
Rethrowing exception- JAVA
PPTX
Np Completeness
PPTX
Files and streams In Java
PPTX
Deadlock- Operating System
PPTX
Data Reduction
PPTX
Cyclic Redundancy Check
PPTX
Client server s/w Engineering
PPTX
Bluetooth protocol
Xml dtd- Document Type Definition- Web Technology
Timing and control circuit
Rethrowing exception- JAVA
Np Completeness
Files and streams In Java
Deadlock- Operating System
Data Reduction
Cyclic Redundancy Check
Client server s/w Engineering
Bluetooth protocol

Recently uploaded (20)

PDF
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PPTX
Information Storage and Retrieval Techniques Unit III
PPTX
Current and future trends in Computer Vision.pptx
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PPTX
Artificial Intelligence
PDF
PPT on Performance Review to get promotions
PPT
Occupational Health and Safety Management System
PDF
737-MAX_SRG.pdf student reference guides
PPT
introduction to datamining and warehousing
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
PPTX
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Information Storage and Retrieval Techniques Unit III
Current and future trends in Computer Vision.pptx
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Artificial Intelligence
PPT on Performance Review to get promotions
Occupational Health and Safety Management System
737-MAX_SRG.pdf student reference guides
introduction to datamining and warehousing
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
86236642-Electric-Loco-Shed.pdf jfkduklg
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
Safety Seminar civil to be ensured for safe working.
III.4.1.2_The_Space_Environment.p pdffdf
Fundamentals of Mechanical Engineering.pptx
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT

Lex Tool

  • 1. Sardar VallabhBhai Patel Institute Of Technology  Name: RAJAN SHAH  Topic: LEX TOOL
  • 2. Language Processor Development Tools  The analysis phase of language processor has a std form irrespective of its purpose, the source text is subjected to lexical, syntax, semantic analysis and the results of analysis are represented in an IR (Intermediate Representation).  LPDT’s focus on generation of the analysis phase of language processors.
  • 3. LEXICAL ANALYZER  Lexical analysis identifies the lexical units in the source statement.  It then classifies them into different lexical classes, e.g. id’s, constants etc. and enter them into different tables.  Lexical analysis builds a descriptor, called a TOKEN, for each lexical unit.  A Token contains two fields: class code, and number in class.  Token is depicted as : Code#no, e.g. Id#2.
  • 4. LEX  Lexical analyzers tokenize input streams  Tokens are the terminals of a language  English: words, punctuation marks, …  Programming language: Identifiers, operators, keywords, …  Regular expressions define terminals/tokens
  • 5. Continue...  LEX accepts an i/p specification which consists of following two part: 1. Specification of strings representing the lexical units in L, e.g. Id’s and constants. 2. Specification of semantic actions aimed at building an IR. The semantic actions makes new entries in the tables and build tokens for the lexical units.
  • 6. LEX Program  %{ letter [A-Za-z] digit [0-9] }%  This component defines the symbol used in specifying the string of L. It defines the symbol ‘letter’ to stand for any upper/lower case letter.
  • 7. Continue...  %% begin {return (BEGIN); } end {return (END); } “:=” {return (ASGOP); } {letter} ({letter} ¦ {digit}) * {yylval=enter_id(); return (ID); } {digit}+ {yylval=enter_num(); return (num); } %%
  • 8. Continue...  enter_id() { /* enters the id in the symbol table and returns the entry number. */ }  enter_num() { /* enters the number in the constants table and returns entry number */ }
  • 9. Overview of LEX  Lexical Analyzer lex.yy.c  lex.yy.c a.out  Input tokens Lex C compiler a.out