====== C2 - tutorial/cecko2.g ====== Jednoduchá gramatika pro výrazy a příkazy používaná v kapitole "Objektově orientované syntaktické stromy". [[http://gitlab.fjfi.cvut.cz/culikzde/view/-/blob/master/tutorial/cecko2.g|cecko2.g]] while_stat < TWhileStat: TStat > : "while" "(" cond:expr ")" code:inner_stat ; if_stat < TIfStat: TStat > : "if" "(" cond:expr ")" then_code:inner_stat ( "else" else_code:inner_stat )? ; compound_stat < TCompoundStat: TStat > : "{" ( stat )* "}" ; simple_stat < TSimpleStat: TStat >: subexpr:expr ";" ; empty_stat < TEmptyStat: TStat > : ";" ; stat < select TStat > : while_stat | if_stat | compound_stat | simple_stat | empty_stat ; inner_stat < return TStat > : stat ; program < return TStat >: stat ; // < expression TExpr > < struct TExpr { enum kind; } > < struct TBinaryExpr : TExpr { } > variable_expr : name:identifier ; value_expr : value:number ; subexpr_expr : "(" subexpr:expr ")" ; simple_expr