View on Codeberg

Relational

Educational tool for relational algebra

Downloads | Screenshots | Query language | Grammar | Types | GUI | Optimizations |

Grammar definition

This page defines the formal grammar that is used by relational.

Literals

Ident literals are recognized by the regular expression:

( letter | '_')( letter | digit | '_')*

String literals String have the form 'x', where x is any sequence of any characters except " and '.

Reserved words and symbols, separated by a space

For the query

    * - ∪ ∩ ÷ ⋈ ⧑ ⧒ ⧓ π σ ρ ➡ ( ) , - *

For the expression in the select, the python operators:

    + - * / > < >= <= == != and or not in **

Grammar


    Query := Ident
    Query := Query BinaryOp Query
    Query := (Query)
    Query := σ PYExprWithoutParenthesis (Query) | σ (PYExpr) (Query)
    Query := π FieldList (Query)
    Query := ρ RenameList (Query)
    FieldList := Ident | Ident , FieldList
    RenameList := Ident ➡ Ident | Ident ➡ Ident , RenameList
    BinaryOp := * | - | ∪ | ∩ | ÷ | ⋈ | ⧑ | ⧒ | ⧓

Note the double definition of the select. It means that if the selection expression contains parenthesis, then the entire expression must be enclosed in an extra set of parenthesis.