예제 #1
0
파일: parser.c 프로젝트: palmerc/lab
int translation_unit(void) {
	if( external_declaration() ) {
	} else if( translation_unit() ) {
		external_declaration();
	} else {
		abort();
	}
}
예제 #2
0
파일: lib.c 프로젝트: alexanderkyte/sparse
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;
}
예제 #3
0
/**
复合语句
<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();
}
예제 #4
0
파일: parser.c 프로젝트: mdiaztello/zcc
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;
}
예제 #5
0
/**
	@brief 翻译单元
*/
void translation_unit(){

	while(token != TK_EOF){
		external_declaration(SC_GLOBAL);
	}
}
예제 #6
0
/**
翻译单元
<translation_unit>::={<external_declaration>}<TK_EOF>

*/
void translation_unit(){
    while(token != TK_EOF)
        external_declaration(SC_GLOBAL);    /// 函数外部解析状态
}