Created
June 17, 2015 10:28
-
-
Save tianzhi0549/18255c12f71a4ab262d3 to your computer and use it in GitHub Desktop.
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
program (program->declaration-list) | |
declaration-list (declaration-list->declaration-list declaration) | |
declaration-list (declaration-list->declaration) | |
declaration (declaration->fun-declaration) | |
fun-declaration (fun-declaration->type-specifier ID ( params ) compound-stmt) | |
type-specifier (type-specifier->int) | |
int | |
ID | |
( | |
params (params->param-list) | |
param-list (param-list->param-list , param) | |
param-list (param-list->param) | |
param (param->type-specifier ID) | |
type-specifier (type-specifier->int) | |
int | |
ID | |
, | |
param (param->type-specifier ID) | |
type-specifier (type-specifier->int) | |
int | |
ID | |
) | |
compound-stmt (compound-stmt->{ local-declarations statement-list }) | |
{ | |
local-declarations (local-declarations->) | |
statement-list (statement-list->statement-list statement) | |
statement-list (statement-list->) | |
statement (statement->selection-stmt) | |
selection-stmt (selection-stmt->if ( expression ) statement else statement) | |
if | |
( | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression relop additive-expression) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->var) | |
var (var->ID) | |
ID | |
relop (relop->==) | |
== | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->NUM) | |
NUM | |
) | |
statement (statement->compound-stmt) | |
compound-stmt (compound-stmt->{ local-declarations statement-list }) | |
{ | |
local-declarations (local-declarations->) | |
statement-list (statement-list->statement-list statement) | |
statement-list (statement-list->) | |
statement (statement->return-stmt) | |
return-stmt (return-stmt->return expression ;) | |
return | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->var) | |
var (var->ID) | |
ID | |
; | |
} | |
else | |
statement (statement->compound-stmt) | |
compound-stmt (compound-stmt->{ local-declarations statement-list }) | |
{ | |
local-declarations (local-declarations->) | |
statement-list (statement-list->statement-list statement) | |
statement-list (statement-list->) | |
statement (statement->return-stmt) | |
return-stmt (return-stmt->return expression ;) | |
return | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->call) | |
call (call->ID ( args )) | |
ID | |
( | |
args (args->arg-list) | |
arg-list (arg-list->arg-list , expression) | |
arg-list (arg-list->expression) | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->var) | |
var (var->ID) | |
ID | |
, | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression) | |
additive-expression (additive-expression->additive-expression addop term) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->var) | |
var (var->ID) | |
ID | |
addop (addop->-) | |
- | |
term (term->term mulop factor) | |
term (term->term mulop factor) | |
term (term->factor) | |
factor (factor->var) | |
var (var->ID) | |
ID | |
mulop (mulop->/) | |
/ | |
factor (factor->var) | |
var (var->ID) | |
ID | |
mulop (mulop->*) | |
* | |
factor (factor->var) | |
var (var->ID) | |
ID | |
) | |
; | |
} | |
} | |
declaration (declaration->fun-declaration) | |
fun-declaration (fun-declaration->type-specifier ID ( params ) compound-stmt) | |
type-specifier (type-specifier->void) | |
void | |
ID | |
( | |
params (params->void) | |
void | |
) | |
compound-stmt (compound-stmt->{ local-declarations statement-list }) | |
{ | |
local-declarations (local-declarations->local-declarations var-declaration) | |
local-declarations (local-declarations->local-declarations var-declaration) | |
local-declarations (local-declarations->) | |
var-declaration (var-declaration->type-specifier ID ;) | |
type-specifier (type-specifier->int) | |
int | |
ID | |
; | |
var-declaration (var-declaration->type-specifier ID ;) | |
type-specifier (type-specifier->int) | |
int | |
ID | |
; | |
statement-list (statement-list->statement-list statement) | |
statement-list (statement-list->statement-list statement) | |
statement-list (statement-list->statement-list statement) | |
statement-list (statement-list->) | |
statement (statement->expression-stmt) | |
expression-stmt (expression-stmt->expression ;) | |
expression (expression->var = expression) | |
var (var->ID) | |
ID | |
= | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->call) | |
call (call->ID ( args )) | |
ID | |
( | |
args (args->) | |
) | |
; | |
statement (statement->expression-stmt) | |
expression-stmt (expression-stmt->expression ;) | |
expression (expression->var = expression) | |
var (var->ID) | |
ID | |
= | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->call) | |
call (call->ID ( args )) | |
ID | |
( | |
args (args->) | |
) | |
; | |
statement (statement->expression-stmt) | |
expression-stmt (expression-stmt->expression ;) | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->call) | |
call (call->ID ( args )) | |
ID | |
( | |
args (args->arg-list) | |
arg-list (arg-list->expression) | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->call) | |
call (call->ID ( args )) | |
ID | |
( | |
args (args->arg-list) | |
arg-list (arg-list->arg-list , expression) | |
arg-list (arg-list->expression) | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->var) | |
var (var->ID) | |
ID | |
, | |
expression (expression->simple-expression) | |
simple-expression (simple-expression->additive-expression) | |
additive-expression (additive-expression->term) | |
term (term->factor) | |
factor (factor->var) | |
var (var->ID) | |
ID | |
) | |
) | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment