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

PPT
Yacc lex
PDF
Lexyacc
PPT
Lexyacc
PPTX
Yacc (yet another compiler compiler)
DOCX
Yacc topic beyond syllabus
PPTX
Lex Tool
Yacc lex
Lexyacc
Lexyacc
Yacc (yet another compiler compiler)
Yacc topic beyond syllabus
Lex Tool

What's hot (20)

PPT
Lex and Yacc ppt
DOCX
LEX & YACC
PPTX
Lex & yacc
DOC
Lex tool manual
PPTX
Introduction of flex
PPTX
Introduction of bison
PPTX
PPTX
Lexical analyzer generator lex
PPTX
Compiler design and lexical analyser
PPT
02. chapter 3 lexical analysis
PPT
1.Role lexical Analyzer
PDF
Compiler Construction | Lecture 12 | Virtual Machines
PDF
Lexical
PDF
Compiler Construction | Lecture 3 | Syntactic Editor Services
PPTX
Lexical analyzer
PPTX
Role-of-lexical-analysis
PPTX
Intermediate code- generation
PPT
Lecture 13 intermediate code generation 2.pptx
PPT
Chapter Eight(3)
Lex and Yacc ppt
LEX & YACC
Lex & yacc
Lex tool manual
Introduction of flex
Introduction of bison
Lexical analyzer generator lex
Compiler design and lexical analyser
02. chapter 3 lexical analysis
1.Role lexical Analyzer
Compiler Construction | Lecture 12 | Virtual Machines
Lexical
Compiler Construction | Lecture 3 | Syntactic Editor Services
Lexical analyzer
Role-of-lexical-analysis
Intermediate code- generation
Lecture 13 intermediate code generation 2.pptx
Chapter Eight(3)
Ad

Similar to BUILDING BASIC STRECH SQL COMPILER (20)

PPTX
Compiler project
PPTX
Compiler Engineering Lab#5 : Symbol Table, Flex Tool
PPT
Lex and Yacc Tool M1.ppt
PPT
Module4 lex and yacc.ppt
PPT
Ch4c.ppt
PDF
Lex and Yacc.pdf
PPT
531AlmadhorAlwageed2010.ppt
PPT
Compiler Design Tutorial
PPTX
Lexing and parsing
PPT
Compiler Design Brief in Computer Application
PPT
lex&yacc - Rules may be recursive Rules may be ambiguous Uses bottom-up Shift...
PPTX
module 4.pptx
PDF
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
PDF
PDF
Assignment2
PPT
compiler Design laboratory lex and yacc tutorial
PPTX
Systems Programming & Operating Systems - Overview of LEX-and-YACC
PDF
How to create a programming language
PPT
SS & CD Module 3
Compiler project
Compiler Engineering Lab#5 : Symbol Table, Flex Tool
Lex and Yacc Tool M1.ppt
Module4 lex and yacc.ppt
Ch4c.ppt
Lex and Yacc.pdf
531AlmadhorAlwageed2010.ppt
Compiler Design Tutorial
Lexing and parsing
Compiler Design Brief in Computer Application
lex&yacc - Rules may be recursive Rules may be ambiguous Uses bottom-up Shift...
module 4.pptx
Prof. Chethan Raj C, BE, M.Tech (Ph.D) Dept. of CSE. System Software & Operat...
Assignment2
compiler Design laboratory lex and yacc tutorial
Systems Programming & Operating Systems - Overview of LEX-and-YACC
How to create a programming language
SS & CD Module 3
Ad

More from Ajeet Dubey (6)

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

Recently uploaded (20)

PDF
top salesforce developer skills in 2025.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Digital Strategies for Manufacturing Companies
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
assetexplorer- product-overview - presentation
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Introduction to Artificial Intelligence
PPTX
L1 - Introduction to python Backend.pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
medical staffing services at VALiNTRY
top salesforce developer skills in 2025.pdf
Odoo Companies in India – Driving Business Transformation.pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Digital Strategies for Manufacturing Companies
Softaken Excel to vCard Converter Software.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
assetexplorer- product-overview - presentation
Which alternative to Crystal Reports is best for small or large businesses.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Introduction to Artificial Intelligence
L1 - Introduction to python Backend.pptx
Design an Analysis of Algorithms II-SECS-1021-03
Wondershare Filmora 15 Crack With Activation Key [2025
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
VVF-Customer-Presentation2025-Ver1.9.pptx
Operating system designcfffgfgggggggvggggggggg
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
How to Choose the Right IT Partner for Your Business in Malaysia
medical staffing services at VALiNTRY

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 sql_compiler@gmail.com