Skip to content

Simple parser for SQL Insert Statement, this tool is developed using Flex and Yacc.

Notifications You must be signed in to change notification settings

nidhiverma/sql-insert-query-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Insert Query Parser with LEX / YACC

Simple parser for SQL Insert Statement, this tool is developed using Lex and Yacc.

The source file of yacc is defined in sql.y The source file of lex is defined in sql.l

Statement of the problem

Using lex/yacc implement a parser for the insert SQL statement.
The Syntax of Insert statement is

Format 1:
insert into <table-name> (col1, col2, col3, ...., coln) values (val1, val2, val3, ... , valn)

where the (col1, col2, col3, ..., coln) and values (val1, val2, val3, ... , valn) should have the 
same length.

Format 2:
insert into <table-name> values (val1, val2, val3, ... , valn)

Output: Valid/Invalid statement

How to build

When using lex with yacc, either can be run first. The following command generates a parser in the file y.tab.c:

$ yacc -vdy sql.y

Now invoke lex with the following command:

$ flex sql.l

Now compile and link the output files with the command:

$ gcc lex.yy.c y.tab.c

The execuatable is created in ./a.exe

About

Simple parser for SQL Insert Statement, this tool is developed using Flex and Yacc.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published