<translation-unit> ::= {<external-declaration>}*
<external-declaration> ::= <function-definition> //外部聲明
| <declaration>
<function-definition> ::= {<declaration-specifier>}*
<declarator> {<declaration>}* <compound-statement> //函數的定義
<declaration-specifier> ::= <storage-class-specifier> //類的定義
| <type-specifier>
| <type-qualifier>
<storage-class-specifier> ::= "auto" //存儲說明符auto,register,extern,static說明的四種存儲類别。四種存儲類别說明符有兩種存儲期:自動存儲期和靜态存儲期。
| "register"
| "static"
| "extern"
| "typedef"
<type-specifier> ::= "void" //資料類型
| "char"
| "short"
| "int"
| "long"
| "float"
| "double"
| "signed"
| "unsigned"
| <struct-or-union-specifier>
| <enum-specifier>
| <typedef-name>
<struct-or-union-specifier> ::= <struct-or-union>
<identifier> "{" {<struct-declaration>}+ "}" //定義結構體的方法
| <struct-or-union> "{" {<struct-declaration>}+
"}"
| <struct-or-union> <identifier>
<struct-or-union> ::= "struct" //結構體:共用體
| "union"
<struct-declaration> ::= {<specifier-qualifier>}*
<struct-declarator-list>
<specifier-qualifier> ::= <type-specifier>
<struct-declarator-list> ::= <struct-declarator>
| <struct-declarator-list> "," <struct-declarator>
<struct-declarator> ::= <declarator>
| <declarator> ":" <constant-expression>
| ":" <constant-expression>
<declarator> ::= {<pointer>}? <direct-declarator> //“*” 表示定義一個指針 pointer
<pointer> ::= "*" {<type-qualifier>}* {<pointer>}?
<type-qualifier> ::= "const"
//const是一個C語言的關鍵字,它限定一個變量不允許被改變。
| "volatile"
<direct-declarator> ::= <identifier> //括号的用處
| "(" <declarator> ")"
| <direct-declarator> "[" {<constant-expression>}?
"]"
| <direct-declarator> "(" <parameter-type-list>
")"
| <direct-declarator> "(" {<identifier>}* ")"
//以下是運算符的運用 與,或,異或運算,四則運算符(加減乘除求餘),位運算
<constant-expression> ::= <conditional-expression>
<conditional-expression> ::= <logical-or-expression>
| <logical-or-expression> "?" <expression> ":"
<conditional-expression>
<logical-or-expression> ::= <logical-and-expression>
| <logical-or-expression "||" <logical-and-expression>
<logical-and-expression> ::= <inclusive-or-expression>
| <logical-and-expression "&&"
<inclusive-or-expression>
<inclusive-or-expression> ::= <exclusive-or-expression>
| <inclusive-or-expression> "|" <exclusive-or-expression>
<exclusive-or-expression> ::= <and-expression>
| <exclusive-or-expression> "^" <and-expression>
<and-expression> ::= <equality-expression>
| <and-expression> "&" <equality-expression>
<equality-expression> ::= <relational-expression>
| <equality-expression> "==" <relational-expression>
| <equality-expression> "!=" <relational-expression>
<relational-expression> ::= <shift-expression>
| <relational-expression> "<" <shift-expression>
| <relational-expression> ">" <shift-expression>
| <relational-expression> "<=" <shift-expression>
| <relational-expression> ">=" <shift-expression>
<shift-expression> ::= <additive-expression>
| <shift-expression> "<<" <additive-expression>
| <shift-expression> ">>" <additive-expression>
<additive-expression> ::= <multiplicative-expression>
| <additive-expression> "+" <multiplicative-expression>
| <additive-expression> "-" <multiplicative-expression>
<multiplicative-expression> ::= <cast-expression>
| <multiplicative-expression> "*" <cast-expression>
| <multiplicative-expression> "/" <cast-expression>
| <multiplicative-expression> "%" <cast-expression>
<cast-expression> ::= <unary-expression>
| "(" <type-name> ")" <cast-expression>
<unary-expression> ::= <postfix-expression> //自增自減運算符
| "++" <unary-expression>
| "--" <unary-expression>
| <unary-operator> <cast-expression>
| "sizeof" <unary-expression>
| "sizeof" <type-name>
<postfix-expression> ::= <primary-expression> //字尾表達式
| <postfix-expression> "[" <expression> "]"
| <postfix-expression> "(" {<assignment-expression>}*
| <postfix-expression> "." <identifier>
| <postfix-expression> "->" <identifier>
| <postfix-expression> "++"
| <postfix-expression> "--"
<primary-expression> ::= <identifier> //字首表達式
| <constant>
| <string>
| "(" <expression> ")"
<constant> ::= <integer-constant>
| <character-constant>
| <floating-constant>
| <enumeration-constant>
<expression> ::= <assignment-expression> //表達式
| <expression> "," <assignment-expression>
<assignment-expression> ::= <conditional-expression>
| <unary-expression> <assignment-operator>
<assignment-expression>
<assignment-operator> ::= "=" //指派運算符
| "*="
| "/="
| "%="
| "+="
| "-="
| "<<="
| ">>="
| "&="
| "^="
| "|="
<unary-operator> ::= "&" //一進制運算符
| "*"
| "+"
| "-"
| "~"
| "!"
<type-name> ::= {<specifier-qualifier>}+
{<abstract-declarator>}? //定義一個變量的方法
<parameter-type-list> ::= <parameter-list> //函數參數類型分隔符清單
| <parameter-list> "," ...
<parameter-list> ::= <parameter-declaration>
| <parameter-list> "," <parameter-declaration>
<parameter-declaration> ::= {<declaration-specifier>}+
<declarator> //函數嵌套
| {<declaration-specifier>}+ <abstract-declarator>
| {<declaration-specifier>}+
<abstract-declarator> ::= <pointer>
| <pointer> <direct-abstract-declarator>
| <direct-abstract-declarator>
<direct-abstract-declarator> ::= ( <abstract-declarator> )
| {<direct-abstract-declarator>}? "["
{<constant-expression>}? "]"
| {<direct-abstract-declarator>}? "("
{<parameter-type-list>|? ")"
<enum-specifier> ::= "enum" <identifier> "{"
<enumerator-list> "}" //枚舉類型
| "enum" "{" <enumerator-list> "}"
| "enum" <identifier>
<enumerator-list> ::= <enumerator> //枚舉類型清單
| <enumerator-list> "," <enumerator>
<enumerator> ::= <identifier>
//枚舉類型的定義的方法
| <identifier> "=" <constant-expression>
<typedef-name> ::= <identifier> //typedef 類型名
<declaration> ::= {<declaration-specifier>}+
{<init-declarator>}*
<init-declarator> ::= <declarator>
| <declarator> "=" <initializer>
<initializer> ::= <assignment-expression> //初始化
| "{" <initializer-list> "}" //初始化清單
| "{" <initializer-list> "," "}"
<initializer-list> ::= <initializer>
| <initializer-list> "," <initializer>
<compound-statement> ::= "{" {<declaration>}*
{<statement>}* "}"
<statement> ::= <labeled-statement> //标記語句
| <expression-statement>
| <compound-statement>
| <selection-statement>
| <iteration-statement>
| <jump-statement>
<labeled-statement> ::= <identifier> ":" <
statement> //switch用法
| "case" <constant-expression> ":" <statement>
| "default" ":" <statement>
<expression-statement> ::= {<expression>}? ";"
<selection-statement> ::= "if" "(" <expression>
")" <statement> //if-else
用法,以及嵌套
| "if" "(" <expression> ")"
<statement> "else" <statement>
| "switch" "(" <expression> ")"
<statement>
<iteration-statement> ::= "while" "(" <expression>
")" <statement> //do-while用法
| "do" <statement> "while" "("
<expression> ")" ";"
| "for" "(" {<expression>}? ";"
{<expression>}? ";" {<expression>}? ")"
<jump-statement> ::= "goto" <identifier> ";" //goto用法
| "continue" ";"
| "break" ";"
| "return" {<expression>}? ";"