加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
grammer.txt 3.05 KB
一键复制 编辑 原始数据 按行查看 历史
天命昭昭 提交于 2021-04-28 15:28 . wyz
*terminals
ID
VOID
INT
CHAR
FLOAT
LONG
DOUBLE
SHORT
STRING_LITERAL
(
)
[
]
,
;
{
}
=
:
>
<
>=
<=
!=
==
=
+=
-=
*=
/=
%=
+
-
*
/
%
&
~
++
--
!
#
int
float
double
short
long
while
if
else
*productions
<s> ::= <translation_unit>
<translation_unit> ::= <external_declaration> <translation_unit>
<translation_unit> ::=
<external_declaration> ::= <func_declaration>
<declaration> ::= <declaration_specifiers> P21 ;
<init_declarator> ::=
<init_declarator> ::= <initializer>
<initializer> ::= <assignment_expression>
<initializer> ::= { <initializer_list> }
<initializer_list> ::= <initializer> , <initializer_list>
<func_declaration>::= <declaration_specifiers> <declarator> <declaration_list> <compound_stmt>
<declaration_list> ::=
<declaration_list> ::= <declaration> P22 <declaration_list>
<declaration_specifiers> ::= <type_specifier> ID P31
<declarator> ::= ( <parameter_type_list> )
<declarator> ::=
<parameter_type_list> ::= <parameter_list>
<parameter_type_list> ::=
<parameter_list> ::= <parameter_declaration>
<parameter_declaration> ::= <declaration_specifiers> <declarator>
<parameter_declaration> ::= <declaration_specifiers>
<stmt> ::= <compound_stmt>
<stmt> ::= <iter_stmt>
<stmt> ::= <selection_stmt>
<stmt> ::= <expression_stmt>
<expression_stmt> ::= ;
<expression_stmt> ::= <expression> ;
<compound_stmt> ::= { <stmt_list> }
<compound_stmt> ::= { <declaration_list> <stmt_list> }
<stmt_list> ::=
<stmt_list> ::= <stmt> <stmt_list>
<iter_stmt> ::= while ( <primary_expression> ) P91 <stmt> P92
<selection_stmt>::= if ( <primary_expression> ) P81 <stmt> P82
<type_specifier> ::= int P11
<type_specifier> ::= float P12
<type_specifier> ::= double P13
<type_specifier> ::= short P14
<type_specifier> ::= long P15
<constant> ::= INT P41
<constant> ::= FLOAT P42
<constant> ::= SHORT P43
<constant> ::= LONG P44
<compare_op> ::= >
<compare_op> ::= <
<compare_op> ::= ==
<compare_op> ::= >=
<compare_op> ::= <=
<compare_op> ::= ==
<compare_op> ::= !=
<unary_op> ::= &
<unary_op> ::= *
<unary_op> ::= +
<unary_op> ::= -
<unary_op> ::= ~
<unary_op> ::= !
<assignment_op> ::= =
<assignment_op> ::= -=
<assignment_op> ::= +=
<assignment_op> ::= *=
<assignment_op> ::= /=
<assignment_op> ::= %=
<expression> ::= ID = <unary_expression> P62 <factor_expression> P61
<factor_expression> ::=
<factor_expression> ::= + <unary_expression> P101
<factor_expression> ::= * <unary_expression> P102
<compare_expression> ::= <primary_expression> <compare_op> <primary_expression>
<assignment_expression>::= += <unary_expression>
<assignment_expression>::= -= <unary_expression>
<primary_expression> ::= ID P51
<primary_expression> ::= <constant> P52
<primary_expression> ::= STRING_LITERAL
<primary_expression> ::= ( <expression> )
<unary_expression> ::= <primary_expression> P71
<unary_expression> ::= ++ <unary_expression> P72
<unary_expression> ::= -- <unary_expression> P73
<unary_expression> ::= <unary_op> <unary_expression>
*end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化