Skip to content

Grammar

Adharsh Kamath edited this page Nov 9, 2020 · 1 revision

The grammar used in this project

program ->   statements;


statements  ->   statements statement

            |   %empty;


final       ->   NEWLINE

            |   END;


statement   ->   NEWLINE

            |   expression final;


identifier  ->   IDENTIFIER  dimensions;


dimensions  ->   dimensions LEFTSQR offset RIGHTSQR

            |   %empty;


offset  ->   offset_type

        |   offset OPERATOR offset_type;


intermediate_expr   ->   OPERATOR expression

                    |   %empty;


expression  ->   term

            |   term OPERATOR expression

            |   identifier EQUALS expression

            |   SQRT LEFTPAR expression RIGHTPAR

            |   LEFTPAR expression RIGHTPAR  intermediate_expr

            |   forall_stmt

            |   prod_sum_stmt;


term    ->   identifier

        |   number;


forall_stmt ->   FORALL LEFTPAR IDENTIFIER RIGHTPAR WHERE bound LEFTCURLY NEWLINE;


prod_sum_stmt  ->   control LEFTPAR expression RIGHTPAR WHERE bound;


control ->  PRODUCT 

        |  SIGMA;


offset_type ->   INTCONST

            |   IDENTIFIER;


number      ->   INTCONST

            |   FLOATCONST;


bound   ->  expression COMPARISON IDENTIFIER COMPARISON expression;

Clone this wiki locally