int function_definition(void) { if( declaration_specifiers() ) { declarator(); if( declaration_list() ) { } } else if ( declarator() ) { if( declaration_list() ) { } } else { abort(); } compound_statement(); }
//program::={<declaration_list><statement_list>} int program() { int es = 0, i; fscanf(fp, "%s %s\n", token, token1); printf("%s %s\n", token, token1); if (strcmp(token, "{"))//判断是否'{' { es = 1; return(es); } fscanf(fp, "%s %s\n", &token, &token1); printf("%s %s\n", token, token1); es = declaration_list(); if (es > 0) return(es); printf(" 符号表\n"); printf(" 名字 地址\n"); for (i = 0; i<vartablep; i++) printf(" %s %d\n", vartable[i].name, vartable[i].address); es = statement_list(); if (es>0) return(es); if (strcmp(token, "}"))//判断是否'}' { es = 2; return(es); } fprintf(fout, " STOP\n");//产生停止指令 return(es); }
int declaration_list(void) { if( declaration() ) { } else if( declaration_list() ) { declaration(); } else { abort(); } }
TOKEN declaration_list(SYMBOL s) { TOKEN dec_list = declaration(s); if( dec_list != NULL) { //FIXME this might be a bug, but I'm not sure yet set_token_link(dec_list, declaration_list(s)); } return dec_list; }
/* construct the parse tree. */ TreeNode * parse (void) { TreeNode * t; token = getToken(); t = declaration_list(); while (token == COMMENT) unexpectedTokenHandling(); if (token != ENDFILE) syntaxError ("Code ends before file\n"); return t; }
int compound_statement(void) { match(LCURLY); if( statement_list() ) { } else if( declaration_list() ) { if( statement_list() ) { } } else { abort(); } match(RCURLY); }