Exemplo n.º 1
0
Arquivo: parser.c Projeto: palmerc/lab
int struct_or_union_specifier(void) {
	struct_or_union();
	
	if( lookaheadT.type == ID ) {
		match(ID);
	}
	if( lookaheadT.type == LCURLY ) {
		match(LCURLY);
		struct_declaration_list();
		match(RCURLY);
	}
}
Exemplo n.º 2
0
/**
结构区分符
<struct_specifier>::=
    <KW_STRUCT><IDENTIFIER><TK_BEGIN><struct_declaration_list><TK_END>
    |<KW_STURCT><IDENTIFIER>

parse struct

*/
void struct_specifier(){
    int v;
    get_token();
    v = token;
    syntax_state = SNTX_DELAY;  /// determing output format until take out the next word
    get_token();
    if(token == TK_BEGIN)   /// apply for struct definition
        syntax_state = SNTX_LF_HT;
    else if(token == TK_CLOSEPA)    /// apply for sizeof(struct struct_name)
        syntax_state = SNTX_NUL;
    else
        syntax_state = SNTX_SP;
    syntax_indent();

    if(v < TK_IDENT)
        expect("struct name");  /// key word can't apply for struct name
    if(token == TK_BEGIN)
        struct_declaration_list();
}
Exemplo n.º 3
0
Arquivo: parser.c Projeto: palmerc/lab
int struct_declaration_list(void) {
	if( struct_declaration_list() ) {
	}
	struct_declaration();
}