-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
qihaoyu
committed
May 14, 2021
1 parent
e4e099b
commit 6f6fb55
Showing
6 changed files
with
136 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Program ::= <声明串> | ||
<声明串> ::=<声明>{<声明>} | ||
<声明> ::=int <ID> <声明类型> | void <ID> <函数声明> | ||
<声明类型>::=<变量声明> | <函数声明> | <数组声明> | ||
<变量声明> ::= ; | ||
<函数声明> ::= ‘(’<形参>‘)’ <语句块> | ||
<数组声明> ::= ‘[’ (数字)+ ‘]’{‘[’ (数字)+ ‘]’} | ||
<形参>::= <参数列表> | void | ||
<参数列表> ::= <参数> {, <参数>} | ||
<参数> ::= int <ID> | ||
<语句块> ::= ‘{’<内部声明> <语句串>‘}’ | ||
<内部声明> ::= 空 | <内部变量声明>;{<内部变量声明>;} | ||
// TODO:内部变量声明是不是没有包括数组结构啊 | ||
<内部变量声明>::=int <ID> | ||
<语句串> ::= <语句>{ <语句> } | ||
<语句> ::= <if语句> |< while语句> | <return语句> | <赋值语句> | ||
<赋值语句> ::= <ID>‘=’<表达式> | <数组>‘=’<表达式>; | ||
<return语句> ::= return [ <表达式> ] ;(注:[ ]中的项表示可选) | ||
<while语句> ::= while ‘( ’<表达式> ‘)’ <语句块> | ||
<if语句> ::= if ‘(‘<表达式>‘)’ <语句块> [ else <语句块> ](注:[ ]中的项表示可选) | ||
<表达式>::=<加法表达式>{ relop <加法表达式> } (注:relop-> <|<=|>|>=|==|!=) | ||
<加法表达式> ::= <项> {+ <项> | -<项>} | ||
<项> ::= <因子> {* <因子> | /<因子>} | ||
<因子> ::=num | ‘(’<表达式>‘)’ |<ID> FTYPE |<数组> | ||
FTYPE ::= <call> | 空 | ||
<call> ::=‘(’<实参> ‘) ’ | ||
<数组>::=<ID> ‘[’<表达式>‘]’ | <数组> ‘[’<表达式>‘]’ | ||
<实参> ::=<实参列表> | 空 | ||
<实参列表> ::= <表达式>{, <表达式>} | ||
<ID>::=字母(字母|数字)* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters