2.

r_disj  : r_disj "|" r_concat
        | r_concat
        ;

r_concat : r_concat r_modified
         | r_modified
         ;

r_modified : r_modified "*"
           | r_modified "+"
           | r_modified "?"
           | r_elem
           ;

r_elem  : "a"
        | "b"
        | "(" r_disj ")"
        ;

(ab)*(ab?a|b)+

r_disj =>
r_concat =>
r_concat r_modified =>
r_concat r_modified + =>
r_concat r_elem + =>
r_concat ( r_disj )+ =>
r_concat ( r_disj | r_concat )+ =>
r_concat ( r_disj | r_modified )+ =>
r_concat ( r_disj | r_elem )+ =>
r_concat ( r_disj | b )+ =>
r_concat ( r_concat | b )+ =>
r_concat ( r_concat r_modified | b )+ =>
r_concat ( r_concat r_elem | b )+ =>
r_concat ( r_concat a | b )+ =>
r_concat ( r_concat r_modified a | b )+ =>
r_concat ( r_concat r_modified? a | b )+ =>
r_concat ( r_concat r_elem? a | b )+ =>
r_concat ( r_concat b? a | b )+ =>
r_concat ( r_modified b? a | b )+ =>
r_concat ( r_elem b? a | b )+ =>
r_concat ( a b? a | b )+ =>
r_modified ( a b? a | b )+ =>
r_modified * ( a b? a | b )+ =>
r_elem * ( a b? a | b )+ =>
( r_disj )* ( a b? a | b )+ =>
( r_concat )* ( a b? a | b )+ =>
( r_concat r_modified )* ( a b? a | b )+ =>
( r_concat r_elem )* ( a b? a | b )+ =>
( r_concat b )* ( a b? a | b )+ =>
( r_modified b )* ( a b? a | b )+ =>
( r_elem b )* ( a b? a | b )+ =>
( a b )* ( a b? a | b )+

3.
dat : %% niz_pravila %%                            Izbor = {%%}
    ;

niz_pravila : pravilo niz_pravila                  Izbor = {SIMBOL}
            |                                      Izbor = {%%}
            ;

pravilo : SIMBOL ":" niz_alternativa ";"           Izbor = {SIMBOL}
        ;


niz_alternativa : niz_simbola niz_alternativa'     Izbor = {SIMBOL}
                ;

niz_alternativa' :  "|" niz_alternativa            Izbor = {|}
                 |                                 Izbor = {;}
                 ;

niz_simbola : SIMBOL niz_simbola                   Izbor = {SIMBOL}
            |                                      Izbor = {|, ;}
            ;
