NagaKanaparthy / compilersPrj5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project 5 - SQL Grammer with Flex and Bison

Nagavarun Kanaparthy

Purpose

To demonstrate usage of the Flex and Bison to generate the SQL Parser Program. It also help us for the Data Modeling Class here at UNF, since the final project uses this project as assistance during classes between the year of 2014 to 2016.

SQL Grammer

start
        ::= expression

expression
        ::= one-relation-expression | two-relation-expression

one-relation-expression
        ::= renaming | restriction | projection

renaming
        ::= term RENAME attribute AS attribute

term
        ::= relation | ( expression )

restriction
        ::= term WHERE comparison

projection
        ::= term | term [ attribute-commalist ]

attribute-commalist
        ::= attribute | attribute , attribute-commalist

two-relation-expression
        ::= projection binary-operation expression

binary-operation
        ::= UNION | INTERSECT | MINUS | TIMES | JOIN | DIVIDEBY

comparison
        ::= attribute compare number

compare
        ::= < | > | <= | >= | = | <>

number
        ::= val | val number

val
        ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

attribute
        ::= CNO | CITY | CNAME | SNO | PNO | TQTY |
                  SNAME | QUOTA | PNAME | COST | AVQTY |
                  S# | STATUS | P# | COLOR | WEIGHT | QTY

relation
        ::= S | P | SP | PRDCT | CUST | ORDERS

Execution and Compiliation

make
./p5 "Insert your file name here"

Flex Manual Compiliation

felx sql.l

Bison Manual Compiliation

bison sql.y

About


Languages

Language:Yacc 55.7%Language:Lex 36.6%Language:Makefile 7.7%