<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>
| <type-qualifier>
<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>}? ")"
<statement>
<jump-statement> ::= "goto" <identifier> ";" //goto用法
| "continue" ";"
| "break" ";"
| "return" {<expression>}? ";"