SlideShare a Scribd company logo
1
Headline Goes Here
Speaker Name or Subhead Goes Here
DO NOT USE PUBLICLY
PRIOR TO 10/23/12
Structured Query Language (SQL) Compiler
Mentor : Mr. Ashish Pandey Sir
Objective:
2
Introduction to SQL-compiler.
Language Processing
lex/flex and implementation?
Demonstration
yacc/ bison and implementation
SQL compiler : Working Model
Tools and technologies ?
Functionality
Introduction
3
SQL
Structured Query
Language
Standardized language
for requesting
information from a
database.
COMPILER
Program that
translates source
code into object code
high-level language
statements into a
lower-level
representation.
SQL + COMPILER
SQL-COMPILER
4
Scanner
(lexical analysis)
Machine-specific code
improvement (optional)
Parser
(syntax analysis)
Symantic analysis and code
generation
Machine-independent code
improvement(optional)
Target code generation
Source file
(character stream)
Token stream
Parse Tree
Abstract syntax tree
Modified intermediate
form
Target language
Modified target
language
Language Processing
lex/flex
Lex is a scanner generator.
Input is a set of regular expression and associated (written in c).
Output is a table driven scanner(lex.yy.c).
Flex: an source implementation of the original UNIX lex utility.
Lexical analysis
void swap (int *v1, int *v2)
{
int tmp;
tmp = *v1;
*v1 = *v2;
*v2 = tmp;
}
Scanner: produces a stream
of tokens from the input
source
} ; tmp ( voidswap Parser


lex input
FIRST PART
%%
Pattern action

.
%%
THIRD PART
lex input example (I)
Filename: ex I .I
%%
“hello world” printf(“Goodbyen”) ;
. ;
%% Prints “Goodbye” anytime the string “hello
world” is encountered.
Does nothing for anyother character.
using lex
% lex exI .I
% cc lex.yy.c -II
% ./a.out
hello world
Goodbye
%
Process the lex file to generate a
scanner(gets saved as lex.yy.c)
Run the scanner taking input from standard
input.
Compile the scanner and grab main() from the lex library
(-ll option)
lex pattern examples
abc Match the string “abc”.
[a-z, A-Z] Match any lower or uppercase letter.
dog.*cat Match any string starting with dog. And ending with cat.
(ab)+ Match one or more occurrences of “ab”.
[^a-z] Matches any string of one or more characters that do not
include lowercase a-z.
[+ -]?[0-9]+ Match any string of one or more digits with an optional prefix of
+ or -.
11
yacc/ bison
What is yacc/bison ?
Hows does it works ?
12
Scanner
(lexical analysis)
Machine-specific code
improvement (optional)
Parser
(syntax analysis)
Symantic analysis and code
generation
Machine-independent code
improvement(optional)
Target code generation
Source file
(character stream)
Token stream
Parse Tree
Abstract syntax tree
Modified intermediate
form
Target language
Modified target
language
Language Processing
yacc and lex used together
13
Lex: semantic analysis
Splits the input file into tokens
yacc: yet another compiler compiler
Parses and does semantic processing on the stream of tokens
produced by lex
Bison: GNU parser parser.
lex / yacc
14
mylang.y y.tab.c
lex.yy.c
y.tab.h
mylang.l
yacc
gcc
lex
Source code
mylang
Compiled code
/interpreted output
Yaac input
15
FIRST PART
%%
Production action
%%
THIRD PART
yacc productions
16
$1 , $2 

 $n can be refer to the values associated with
symbols
$$ refer to the value of the left.
Default action :
$$ = $1
Every symbol have a value associated with it
(including token and non-terminals).
yacc example production
17
Source code a = b + c * d
Lexical analyzer
Syntax analyzer
Id1 = id2 + id3 * id4
yacc
lex patterns
grammar
=
id1 +
id2 *
id3 id4
TOOLS USED
Operating System
‱ LINUX
Software
‱ Flex/ lex , Bison/ Yaac
‱ gcc compiler
‱ gedit
TECHNOLOGIES USED
C++
Object oriented Techniques
Flex Analyzer implementation
Bison / YACC programming
technique
FUNCTIONALITY
Compiles the sql queries
Parses the given commands
Detects the errors
Compiler frontened analyses the source code
Manages the symbol table
21
 Ashwin Shahi
 Ankit Verma
 Ajeet Dubey
sql_compiler@gmail.com

More Related Content

What's hot (20)

PPT
Lex and Yacc ppt
pssraikar
 
DOCX
LEX & YACC
Mahbubur Rahman
 
PPTX
Lex & yacc
Taha Malampatti
 
DOC
Lex tool manual
Sami Said
 
PPTX
Introduction of flex
vip_du
 
PPTX
Introduction of bison
vip_du
 
PPT
Lex
BBDITM LUCKNOW
 
PPTX
Yacc
BBDITM LUCKNOW
 
PPTX
Lexical analyzer generator lex
Anusuya123
 
PPTX
Compiler design and lexical analyser
abhishek gupta
 
PPT
02. chapter 3 lexical analysis
raosir123
 
PPT
1.Role lexical Analyzer
Radhakrishnan Chinnusamy
 
PDF
Compiler Construction | Lecture 12 | Virtual Machines
Eelco Visser
 
PDF
Lexical
baran19901990
 
PDF
Compiler Construction | Lecture 3 | Syntactic Editor Services
Eelco Visser
 
PPTX
Lexical analyzer
kiran acharya
 
PPTX
Role-of-lexical-analysis
Dattatray Gandhmal
 
PPTX
Intermediate code- generation
rawan_z
 
PPT
Lecture 13 intermediate code generation 2.pptx
Iffat Anjum
 
PPT
Chapter Eight(3)
bolovv
 
Lex and Yacc ppt
pssraikar
 
LEX & YACC
Mahbubur Rahman
 
Lex & yacc
Taha Malampatti
 
Lex tool manual
Sami Said
 
Introduction of flex
vip_du
 
Introduction of bison
vip_du
 
Lexical analyzer generator lex
Anusuya123
 
Compiler design and lexical analyser
abhishek gupta
 
02. chapter 3 lexical analysis
raosir123
 
1.Role lexical Analyzer
Radhakrishnan Chinnusamy
 
Compiler Construction | Lecture 12 | Virtual Machines
Eelco Visser
 
Lexical
baran19901990
 
Compiler Construction | Lecture 3 | Syntactic Editor Services
Eelco Visser
 
Lexical analyzer
kiran acharya
 
Role-of-lexical-analysis
Dattatray Gandhmal
 
Intermediate code- generation
rawan_z
 
Lecture 13 intermediate code generation 2.pptx
Iffat Anjum
 
Chapter Eight(3)
bolovv
 

Similar to BUILDING BASIC STRECH SQL COMPILER (20)

PDF
Compiler_Lecture1.pdf
AkarTaher
 
PPTX
CD U1-5.pptx
Himajanaidu2
 
PDF
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Prof Chethan Raj C
 
PPT
Lexical analyzer
Ashwini Sonawane
 
PPT
Chapter One
bolovv
 
PDF
List of programming_languages_by_type
Phoenix
 
PDF
Structure-Compiler-phases information about basics of compiler. Pdfpdf
ovidlivi91
 
PDF
Flink Forward Berlin 2018: Robert Bradshaw & Maximilian Michels - "Universal ...
Flink Forward
 
PPTX
Compiler Engineering Lab#5 : Symbol Table, Flex Tool
MashaelQ
 
PPT
ITU - MDD - Textural Languages and Grammars
Tonny Madsen
 
PPTX
Lecture 1 introduction to language processors
Rebaz Najeeb
 
PPTX
Overview of microsoft dot net platforms
Abhijit B.
 
PPT
LexicalAnalysis in Compiler design .pt
Sannidhanapuharika
 
PDF
cs241-f06-final-overview
Colin Bell
 
PPT
Compiler Construction introduction
Rana Ehtisham Ul Haq
 
DOCX
Compiler Design
Anujashejwal
 
PPT
.Net Overview -- Training (Lesson 1)
Rishi Kothari
 
PPT
Cd unit i
Abhimanyu Mishra
 
PPT
A basic introduction to compiler design.ppt
pandaashirbad9
 
Compiler_Lecture1.pdf
AkarTaher
 
CD U1-5.pptx
Himajanaidu2
 
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Prof Chethan Raj C
 
Lexical analyzer
Ashwini Sonawane
 
Chapter One
bolovv
 
List of programming_languages_by_type
Phoenix
 
Structure-Compiler-phases information about basics of compiler. Pdfpdf
ovidlivi91
 
Flink Forward Berlin 2018: Robert Bradshaw & Maximilian Michels - "Universal ...
Flink Forward
 
Compiler Engineering Lab#5 : Symbol Table, Flex Tool
MashaelQ
 
ITU - MDD - Textural Languages and Grammars
Tonny Madsen
 
Lecture 1 introduction to language processors
Rebaz Najeeb
 
Overview of microsoft dot net platforms
Abhijit B.
 
LexicalAnalysis in Compiler design .pt
Sannidhanapuharika
 
cs241-f06-final-overview
Colin Bell
 
Compiler Construction introduction
Rana Ehtisham Ul Haq
 
Compiler Design
Anujashejwal
 
.Net Overview -- Training (Lesson 1)
Rishi Kothari
 
Cd unit i
Abhimanyu Mishra
 
A basic introduction to compiler design.ppt
pandaashirbad9
 
Ad

More from Ajeet Dubey (6)

PDF
Certifications for Doctors - Dashboard UI
Ajeet Dubey
 
PDF
Mobile UX & CX for Edelwises Loan Payment
Ajeet Dubey
 
PDF
Must Try Website and Tools for Designers - Part 2
Ajeet Dubey
 
PDF
Whitespace is not a Passive Background.
Ajeet Dubey
 
PDF
Must Try Website and Tools for Designers
Ajeet Dubey
 
PPTX
Vehicle parking
Ajeet Dubey
 
Certifications for Doctors - Dashboard UI
Ajeet Dubey
 
Mobile UX & CX for Edelwises Loan Payment
Ajeet Dubey
 
Must Try Website and Tools for Designers - Part 2
Ajeet Dubey
 
Whitespace is not a Passive Background.
Ajeet Dubey
 
Must Try Website and Tools for Designers
Ajeet Dubey
 
Vehicle parking
Ajeet Dubey
 
Ad

Recently uploaded (20)

PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 

BUILDING BASIC STRECH SQL COMPILER

  • 1. 1 Headline Goes Here Speaker Name or Subhead Goes Here DO NOT USE PUBLICLY PRIOR TO 10/23/12 Structured Query Language (SQL) Compiler Mentor : Mr. Ashish Pandey Sir
  • 2. Objective: 2 Introduction to SQL-compiler. Language Processing lex/flex and implementation? Demonstration yacc/ bison and implementation SQL compiler : Working Model Tools and technologies ? Functionality
  • 3. Introduction 3 SQL Structured Query Language Standardized language for requesting information from a database. COMPILER Program that translates source code into object code high-level language statements into a lower-level representation. SQL + COMPILER SQL-COMPILER
  • 4. 4 Scanner (lexical analysis) Machine-specific code improvement (optional) Parser (syntax analysis) Symantic analysis and code generation Machine-independent code improvement(optional) Target code generation Source file (character stream) Token stream Parse Tree Abstract syntax tree Modified intermediate form Target language Modified target language Language Processing
  • 5. lex/flex Lex is a scanner generator. Input is a set of regular expression and associated (written in c). Output is a table driven scanner(lex.yy.c). Flex: an source implementation of the original UNIX lex utility.
  • 6. Lexical analysis void swap (int *v1, int *v2) { int tmp; tmp = *v1; *v1 = *v2; *v2 = tmp; } Scanner: produces a stream of tokens from the input source } ; tmp ( voidswap Parser 

  • 7. lex input FIRST PART %% Pattern action 
. %% THIRD PART
  • 8. lex input example (I) Filename: ex I .I %% “hello world” printf(“Goodbyen”) ; . ; %% Prints “Goodbye” anytime the string “hello world” is encountered. Does nothing for anyother character.
  • 9. using lex % lex exI .I % cc lex.yy.c -II % ./a.out hello world Goodbye % Process the lex file to generate a scanner(gets saved as lex.yy.c) Run the scanner taking input from standard input. Compile the scanner and grab main() from the lex library (-ll option)
  • 10. lex pattern examples abc Match the string “abc”. [a-z, A-Z] Match any lower or uppercase letter. dog.*cat Match any string starting with dog. And ending with cat. (ab)+ Match one or more occurrences of “ab”. [^a-z] Matches any string of one or more characters that do not include lowercase a-z. [+ -]?[0-9]+ Match any string of one or more digits with an optional prefix of + or -.
  • 11. 11 yacc/ bison What is yacc/bison ? Hows does it works ?
  • 12. 12 Scanner (lexical analysis) Machine-specific code improvement (optional) Parser (syntax analysis) Symantic analysis and code generation Machine-independent code improvement(optional) Target code generation Source file (character stream) Token stream Parse Tree Abstract syntax tree Modified intermediate form Target language Modified target language Language Processing
  • 13. yacc and lex used together 13 Lex: semantic analysis Splits the input file into tokens yacc: yet another compiler compiler Parses and does semantic processing on the stream of tokens produced by lex Bison: GNU parser parser.
  • 14. lex / yacc 14 mylang.y y.tab.c lex.yy.c y.tab.h mylang.l yacc gcc lex Source code mylang Compiled code /interpreted output
  • 16. yacc productions 16 $1 , $2 

 $n can be refer to the values associated with symbols $$ refer to the value of the left. Default action : $$ = $1 Every symbol have a value associated with it (including token and non-terminals).
  • 17. yacc example production 17 Source code a = b + c * d Lexical analyzer Syntax analyzer Id1 = id2 + id3 * id4 yacc lex patterns grammar = id1 + id2 * id3 id4
  • 18. TOOLS USED Operating System ‱ LINUX Software ‱ Flex/ lex , Bison/ Yaac ‱ gcc compiler ‱ gedit
  • 19. TECHNOLOGIES USED C++ Object oriented Techniques Flex Analyzer implementation Bison / YACC programming technique
  • 20. FUNCTIONALITY Compiles the sql queries Parses the given commands Detects the errors Compiler frontened analyses the source code Manages the symbol table
  • 21. 21  Ashwin Shahi  Ankit Verma  Ajeet Dubey [email protected]