prekl:c1
This is an old revision of the document!
C1 - tutorial/cecko.g
Jednoduchá gramatika pro výrazy a příkazy používaná v kapitole “Strojově generované syntaktické analyzátory”
while_stat : "while" "(" expr ")" stat ; if_stat : "if" "(" expr ")" stat ( "else" stat )? ; compound_stat : "{" ( stat )* "}" ; simple_stat : expr ";" ; empty_stat : ";" ; stat : while_stat | if_stat | compound_stat | simple_stat | empty_stat ; simple_expr : identifier | number | "(" expr ")" ; mult_expr : simple_expr ( ("*"|"/") simple_expr )* ; add_expr : mult_expr ( ("+"|"-") mult_expr )* ; expr : add_expr ( "=" expr )? ; program : stat;
Vstupní soubor s jedním příkazem c1.cc
{ while ( n ) if ( n ) n = n + 2; else n = n * 2; }
Obrázek použitý v kapitole Parser
prekl/c1.1589019194.txt.gz · Last modified: 2020/05/09 10:13 by 127.0.0.1