int translation_unit(void) { if( external_declaration() ) { } else if( translation_unit() ) { external_declaration(); } else { abort(); } }
static struct symbol_list *sparse_tokenstream(struct token *token) { // Preprocess the stream token = preprocess(token); if (preprocess_only) { while (!eof_token(token)) { int prec = 1; struct token *next = token->next; const char *separator = ""; if (next->pos.whitespace) separator = " "; if (next->pos.newline) { separator = "\n\t\t\t\t\t"; prec = next->pos.pos; if (prec > 4) prec = 4; } printf("%s%.*s", show_token(token), prec, separator); token = next; } putchar('\n'); return NULL; } // Parse the resulting C code while (!eof_token(token)) token = external_declaration(token, &translation_unit_used_list); return translation_unit_used_list; }
/** 复合语句 <compound_statement>::=<TK_BEGIN>{<declaration>}{<statement>}<TK_END> */ void compound_statement(){ syntax_state = SNTX_LF_HT; syntax_level++; ///复合语句,缩� get_token(); while(is_type_specifier(token)){ external_declaration(SC_LOCAL); get_token(); } while(TK_END != token) statement(); syntax_state = SNTX_LF_HT; get_token(); }
TOKEN translation_unit(void) { TOKEN trans_unit = NULL; TOKEN next = NULL; TOKEN tok = peek_token(); if(tok != NULL) { trans_unit = external_declaration(); next = translation_unit(); if(trans_unit != NULL) { set_token_link(trans_unit, next); } else { trans_unit = next; } } return trans_unit; }
/** @brief 翻译单元 */ void translation_unit(){ while(token != TK_EOF){ external_declaration(SC_GLOBAL); } }
/** 翻译单元 <translation_unit>::={<external_declaration>}<TK_EOF> */ void translation_unit(){ while(token != TK_EOF) external_declaration(SC_GLOBAL); /// 函数外部解析状态 }