[コンパイラ]日記2号クラスC言語の文法

<プログラム> - > <12月> <プログラム> | ^
<12月> - > <タイプ>のident <dectail> | SEMICON | rsv_extern <タイプ>のident SEMICON
<タイプ> - > rsv_void | rsv_int | rsv_char
<dectail> - > SEMICON | <変数リスト> SEMICON | lparen <パラ> RPAREN <funtail>
<funtail> - > <ブロック> | SEMICON
<変数リスト> - >コンマのident <変数リスト> | ^
<パラ> - > <タイプ>のident <paralist> | ^
<paralist> - >コンマ<> identを入力し、<paralist> | ^

<ブロック> - > lbrac <childprogram> rbrac
<childprogram> - > <localdec> <childprogram> | <文> <childprogram> | ^
<localdec>- > <タイプ>のident <lcoaldectail> SEMICON
<localvartail> - >コンマのident <localvartail> | ^

<声明> - >のident <idtail> SEMICON | <whilestat> | <ifstat> | <RETSTAT> | SEMICON
            | rsv_breakセミコン| rsv_continueセミコン
            | rsv_in入力<identを> SEMICON | rsv_out出力<exprの> SEMICON
<whilestat> - > rsv_while lparen <exprの> RPAREN <ブロック>
<ifstat> - > rsv_if lparen <exprの> RPAREN <ブロック> rsv_else <ブロック>
<RETSTAT> - > rsv_return <returntail> SEMICON
<returntail> - > <exprの> | ^
<idtail> - >割り当て<EXP> | lparen <realarg> RPAREN
<realarg> - > <exprの> <引数リスト> | ^
<引数リスト> - >コンマ<exprの> <引数リスト> | ^

<exprの> - ><aloexp> <exptail>
<exptail> - > <CMPS> <exprの> | ^
<CMPS> - > GT | GE | LS |ル| EQU | nequ
<aloexp> - > <item>の<itemtail>
<itemtail> - > <追加> <aloexp> | ^
<追加> - >を追加|サブ
の<item> - > <要因> <factortail>
<factortail> - > <MULS> <項目> | ^
<要因> - > IDENT <idtail> |数|キャラ| lparen <exprの> RPAREN |文字列
<MULS> - > MUL |のdiv

おすすめ

転載: www.cnblogs.com/onetrainee/p/11857992.html