-
Notifications
You must be signed in to change notification settings - Fork 0
Grammar Specification
Gilberto Barbosa edited this page Jun 4, 2020
·
9 revisions
First of all, we need to specify the basic statement sql:
<statement> -> <dme-statement> | <dde-statement> | ...
Where the ... means the other type of statements that will be included after.
Now we have to specify the dme-statement that will include the SELECT statement.
<dme-statement> -> <selection> | <insertion> | <update> | <deletion>
For now we just need the <selection> specification.
<selection> -> <select-clause> FROM <from-list> <where-clause>
<select-clause> -> SELECT <distinct-clause> <select-list>
<distinct-clause> -> <empty> | DISTINCT
<select-list> -> <select-expr-list> | *
<select-expr-list> -> <select-expr> <select-comma-expr>
<select-comma-expr> -> , <select-expr> <select-comma-expr> | <empty>
<select-expr> -> <field-spec>
<from-list> -> <table-name> <from-list-expr>
<from-list-expr> -> <empty> | , <table-name> <from-list-expr>
<where-clause> -> <empty> | WHERE <boolean>
<nested-select> -> <empty> | <and-or> <table-name> <comparison> LPAR <selection> RPAR
<group-order-clause> -> <empty> | GROUP BY <field-spec-list> | ORDER BY <field-spec-list>
<boolean> -> <boolean-n> <boolean-o>
<boolean-o> -> OR <boolean-n> <boolean-o> | <empty>
<boolean-n> -> <boolean-prim> <boolean-n'>
<boolean-n'> -> AND <boolean-prim> <boolean-n'> | <empty>
<boolean-prim> -> <predicate>
<predicate> -> <expr> <relop> <expr>
<relop> -> NE | GT | LT | LWEDGE | RWEDGE | EQ
<expr> -> <constant> | <field-spec>
<constant> -> TEXT | NUMBER | DATE
<field-spec> -> <table-name> . <field-name>
<field-name> -> IDENTIFIER
<table-name> -> IDENTIFIER
<empty> -> EPSN