📄 cparser.c
字号:
{ skip_declaration(); } }#endif}extern int _declaration( Declaration_t Declaration ){ int iRetval; sDeclaration_t sDeclaration; niveau++; sDeclaration.Declaration = Declaration; sDeclaration.type = DECLARATION_UNKNOWN; LongStringInit( &sDeclaration.name, -1 ); sDeclaration.storage_class = 0; sDeclaration.fct_specifier = 0; sDeclaration.s_const = 0; sDeclaration.s_volatile = 0; sDeclaration.s_char = 0; sDeclaration.s_short = 0; sDeclaration.s_int = 0; sDeclaration.s_long = 0; sDeclaration.s_signed = 0; sDeclaration.s_unsigned = 0; sDeclaration.s_float = 0; sDeclaration.s_double = 0; sDeclaration.s_bool = 0; sDeclaration.s_void = 0; LongStringInit( &sDeclaration.type_name, -1 ); sDeclaration.type_of_type_name = 0; LongStringInit( &sDeclaration.complete_class_name, -1 ); sDeclaration.lineno_beg = 0; sDeclaration.charno_beg = 0; sDeclaration.lineno_end = 0; sDeclaration.charno_end = 0; sDeclaration.sClass.ClassParent = 0; LongStringInit( &sDeclaration.sClass.name, -1 ); sDeclaration.sClass.access = 0; sDeclaration.sClass.lineno_beg = 0; sDeclaration.sClass.charno_beg = 0; sDeclaration.sClass.lineno_end = 0; sDeclaration.sClass.charno_end = 0; LongStringInit( &sDeclaration.sEnum.name, -1 ); sDeclaration.sEnum.lineno_beg = 0; sDeclaration.sEnum.charno_beg = 0; sDeclaration.sEnum.lineno_end = 0; sDeclaration.sEnum.charno_end = 0; switch( token( 0 )) { case SN_ASM : iRetval = asm_declaration ( &sDeclaration ); break; case SN_TEMPLATE : iRetval = template_declaration( &sDeclaration ); break; case SN_NAMESPACE: iRetval = namespace_definition( &sDeclaration ); break; case SN_USING : iRetval = using ( &sDeclaration ); break; case SN_EXTERN : iRetval = extern_declaration ( &sDeclaration ); break; default : iRetval = obj_declaration ( &sDeclaration ); break; } LongStringMyFree( &sDeclaration.name ); LongStringMyFree( &sDeclaration.type_name ); LongStringMyFree( &sDeclaration.complete_class_name ); LongStringMyFree( &sDeclaration.sClass.name ); LongStringMyFree( &sDeclaration.sEnum.name ); niveau--; return iRetval;}extern int asm_declaration( Declaration_t Declaration ){ niveau++; Declaration->type = DECLARATION_ASM; while( True ) { switch( token( 0 )) { case 0 : case ';': step( 1 ); niveau--; return True; break; } step( 1 ); }}extern int template_declaration( Declaration_t Declaration ){ int t; Save_d(); niveau++; Declaration->type = DECLARATION_TEMPLATE; step( 1 ); if(( t = token( 0 )) == SN_CLASS || t == SN_INTERFACE ) {/* template class Vector<const CmdLineApp::AppChar *>; miatt */ step( 1 ); if( token( 0 ) == SN_IDENTIFIER ) { step( 1 ); } } if( token( 0 ) == '<' ) { template_argument_skip( &Declaration->name ); declaration( Declaration ); niveau--; return True; } else { Restore_d(); niveau--; return False; } niveau--;}extern int extern_declaration( Declaration_t Declaration ){ int ret; niveau++; if( token( 1 ) == SN_STRINGliteral ) { ret = linkage_specification( Declaration ); niveau--; return ret; } else { ret = obj_declaration( Declaration ); niveau--; return ret; } niveau--;}extern int linkage_specification( Declaration_t Declaration ){ int t; niveau++; Declaration->type = DECLARATION_LINKAGE_SPECIFICATION; step( 1 ); do { step( 1 ); } while( token( 0 ) == SN_STRINGliteral ); if( token( 0 ) == LBRACE ) { step( 1 ); while(( t = token( 0 )) != RBRACE && t != 0 ) /* t != 0 10.02.97 rigo */ { declaration( Declaration ); } step( 1 ); } else { declaration( Declaration ); } niveau--; return True;}extern int using( Declaration_t Declaration ){ Save_d(); int lineno; int charno; niveau++; Declaration->type = DECLARATION_USING; if( token( 1 ) == SN_NAMESPACE ) { step( 1 ); step( 1 ); lineno = f_lineno( 0 ); charno = f_charno( 0 ); if( namespace_name( &Declaration->name )) {/* report_using_directive( filename_g *//* , lineno *//* , charno *//* , f_lineno(0) *//* , f_charno(0) *//* , Declaration->name ); */ niveau--; return True; } else { Restore_d(); niveau--; return False; } } else { step( 1 ); lineno = f_lineno( 0 ); charno = f_charno( 0 ); if( namespace_name( &Declaration->name )) {/* report_using_declaration( filename_g *//* , lineno *//* , charno *//* , f_lineno(0) *//* , f_charno(0) *//* , Declaration->name ); */ niveau--; return True; } else { Restore_d(); niveau--; return False; } } niveau--;}extern int namespace_definition( Declaration_t Declaration ){ Save_d(); int lineno; int charno; int t; niveau++; Declaration->type = DECLARATION_NAMESPACE; if( token( 1 ) == SN_IDENTIFIER ) { lineno = f_lineno( 1 ); charno = f_charno( 1 ); step( 1 ); step( 1 ); if( token( 0 ) == '=' ) { step( 1 ); if( namespace_name( &Declaration->name )) {/* report_namespace_alias_definition( filename_g *//* , lineno *//* , charno *//* , f_lineno(0) *//* , f_charno(0) *//* , id *//* , Declaration->name ); */ } else { Restore_d(); niveau--; return False; } } else {/* report_namespace_definition( filename_g *//* , lineno *//* , charno *//* , f_lineno(0) *//* , f_charno(0) *//* , id ); */ } } else {/* report_namespace_definition( filename_g *//* , f_lineno( 0 ) *//* , f_charno( 0 ) *//* , f_lineno(0) *//* , f_charno(0) *//* , ANONYM ); */ step( 1 ); } if( token( 0 ) == LBRACE ) { step( 1 ); while(( t = token( 0 )) != RBRACE && t != 0 ) /* t != 0 10.02.97 rigo */ { declaration( Declaration ); } step( 1 ); } else { Restore_d(); niveau--; return False; } niveau--; return True;}extern int obj_declaration( Declaration_t Declaration ){ int retval; Save_d(); int lineno_beg; int charno_beg; niveau++; Declaration->type = DECLARATION_OBJECT; while( True ) { switch( token( 0 )) { case ';' : step( 1 ); Return( True ); case SN_INTERFACE : case SN_CLASS : case SN_STRUCT : case SN_UNION : if( ! f_class( Declaration, &Declaration->sClass )) { Restore_d(); Return( False ); } break; case SN_ENUM : if( ! f_enum( Declaration, &Declaration->sEnum )) { Restore_d(); Return( False ); } break; case SN_AUTO : Declaration->storage_class = SN_AUTO ; step( 1 ); break; case SN_REGISTER : Declaration->storage_class = SN_REGISTER; step( 1 ); break; case SN_STATIC : Declaration->storage_class = SN_STATIC ; step( 1 ); break; case SN_EXTERN : Declaration->storage_class = SN_EXTERN ; step( 1 ); break; case SN_INLINE : Declaration->fct_specifier = SN_INLINE ; step( 1 ); break; case SN_VIRTUAL : Declaration->fct_specifier = SN_VIRTUAL ; step( 1 ); break; case SN_FRIEND : Declaration->storage_class = SN_FRIEND ; step( 1 ); break; case SN_TYPEDEF : Declaration->storage_class = SN_TYPEDEF ; step( 1 ); break; case SN_CONST : Declaration->s_const = True ; step( 1 ); break; case SN_VOLATILE : Declaration->s_volatile = True ; step( 1 ); break; case SN_CHAR : Declaration->s_char = True ; step( 1 ); break; case SN_SHORT : Declaration->s_short = True ; step( 1 ); break; case SN_INT : Declaration->s_int = True ; step( 1 ); break; case SN_LONG : Declaration->s_long = True ; step( 1 ); break; case SN_SIGNED : Declaration->s_signed = True ; step( 1 ); break; case SN_UNSIGNED : Declaration->s_unsigned = True ; step( 1 ); break; case SN_FLOAT : Declaration->s_float = True ; step( 1 ); break; case SN_DOUBLE : Declaration->s_double = True ; step( 1 ); break; case SN_BOOL : Declaration->s_bool = True; ; step( 1 ); break; case SN_VOID : Declaration->s_void = True ; step( 1 ); break; case SN_IDENTIFIER : /* ha az ident utan * vagy & vagy ident all ( kiveve az 'ident iden ((' konstrukciot ), akkor nem lehet deklarator_list */ if(( token( 1 ) == '*' ) || ( token( 1 ) == '&' ) || ( token( 1 ) == SN_IDENTIFIER && ( token( 2 ) != '(' || token( 3 ) != '(' )) ) { } else { if( declarator_list( Declaration )) { Return( True ); } } LongStringMySetLen( &Declaration->type_name, 0 ); Declaration->type_of_type_name = 0; lineno_beg = f_lineno( 0 ); charno_beg = f_charno( 0 ); if( ! complete_class_name( &Declaration->type_name )) { Restore_d(); Return( False ); } else { LongStringsMyCopy( &Declaration->complete_class_name , &Declaration->type_name ); Declaration->lineno_beg = lineno_beg; Declaration->charno_beg = charno_beg; Declaration->lineno_end = f_lineno( -1 ); Declaration->charno_end = f_charno( -1 ) + 1; } break; case SN_CLCL : if( declarator_list( Declaration )) { Return( True ); } LongStringMySetLen( &Declaration->type_name, 0 ); Declaration->type_of_type_name = 0; lineno_beg = f_lineno( 0 ); charno_beg = f_charno( 0 ); if( ! complete_class_name( &Declaration->type_name )) { Restore_d(); Return( False ); } else { LongStringsMyCopy( &Declaration->complete_class_name , &Declaration->type_name ); Declaration->lineno_beg = lineno_beg; Declaration->charno_beg = charno_beg; Declaration->lineno_end = f_lineno( -1 ); Declaration->charno_end = f_charno( -1 ) + 1; } break; case SN_OPERATOR : case '(' : case '*' : case '&' : case '~' : if( declarator_list( Declaration )) { Return( True ); } else { Restore_d(); Return( False ); } break; default : Restore_d(); Return( False ); break; } }return_label: niveau--; return retval;}extern int declarator_list( Declaration_t Declaration ){ Save_d(); sDeclarator_t sDeclarator; niveau++; LongStringInit( &sDeclarator.name , -1 ); LongStringInit( &sDeclarator.type , -1 ); LongStringInit( &sDeclarator.types, -1 ); LongStringInit( &sDeclarator.names, -1 );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -