⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cp_expression.c

📁 这是一个Linux下的集成开发环境
💻 C
📖 第 1 页 / 共 3 页
字号:
   case SN_CATCH    :   case SN_CLASS    :   case SN_DELETE   :   case SN_FRIEND   :   case SN_INLINE   :   case SN_NEW      :   case SN_OPERATOR :   case SN_OVERLOAD :   case SN_PRIVATE  :   case SN_PROTECTED:   case SN_PUBLIC   :   case SN_TEMPLATE :/* case SN_THIS     : */   case SN_THROW    :   case SN_TRY      :   case SN_VIRTUAL  :   case SN_VOLATILE :      Expr = ExprCreateName( f_NameCreate( ident( 0 )));      Expr->lineno_beg = f_lineno( 0 );      Expr->charno_beg = f_charno( 0 );      Expr->lineno_end = f_lineno( 0 );      Expr->charno_end = f_charno( 0 ) + identlen( 0 );      step( 1 );      goto ret;   case SN_INTEGERconstant:      Type = f_TypeCreateInt();      Expr = ExprCreateType( Type );      Expr->lineno_beg = f_lineno( 0 );      Expr->charno_beg = f_charno( 0 );      Expr->lineno_end = f_lineno( 0 );      Expr->charno_end = f_charno( 0 ) + identlen( 0 );      step( 1 );      goto ret;   case SN_LONGconstant:      Type = f_TypeCreateLong();      Expr = ExprCreateType( Type );      Expr->lineno_beg = f_lineno( 0 );      Expr->charno_beg = f_charno( 0 );      Expr->lineno_end = f_lineno( 0 );      Expr->charno_end = f_charno( 0 ) + identlen( 0 );      step( 1 );      goto ret;   case SN_CHARACTERconstant:      Type = f_TypeCreateChar();      Expr = ExprCreateType( Type );      Expr->lineno_beg = f_lineno( 0 );      Expr->charno_beg = f_charno( 0 );      Expr->lineno_end = f_lineno( 0 );      Expr->charno_end = f_charno( 0 ) + identlen( 0 );      step( 1 );      goto ret;   case SN_FLOATINGconstant:      Type = f_TypeCreateFloat();      Expr = ExprCreateType( Type );      Expr->lineno_beg = f_lineno( 0 );      Expr->charno_beg = f_charno( 0 );      Expr->lineno_end = f_lineno( 0 );      Expr->charno_end = f_charno( 0 ) + identlen( 0 );      step( 1 );      goto ret;   case SN_STRINGliteral:      Type = f_TypeCreateString();      Expr = ExprCreateType( Type );      Expr->lineno_beg = f_lineno( 0 );      Expr->charno_beg = f_charno( 0 );      step( 1 );      while( token( 0 ) == SN_STRINGliteral )      {         step( 1 );      }      Expr->lineno_end = f_lineno( -1 );      Expr->charno_end = f_charno( -1 ) + identlen( -1 );      goto ret;   case SN_THIS:      Type = f_TypeCreate();      Expr = ExprCreateType( Type );      Expr->lineno_beg = f_lineno( 0 );      Expr->charno_beg = f_charno( 0 );      Expr->lineno_end = f_lineno( 0 );      Expr->charno_end = f_charno( 0 ) + identlen( 0 );      step( 1 );      goto ret;   case SN_CLCL:      step( 1 );      lineno_beg = f_lineno( 0 );      charno_beg = f_charno( 0 );      if(( Name = f_Name()))      {         char *pcName = Malloc( strlen( Name->pcName ) + 2 + 1 );         strcpy( pcName, "::" );         strcat( pcName, Name->pcName );         ckfree( (char*)Name->pcName );         Name->pcName = pcName;         Expr = ExprCreateName( Name );         Expr->lineno_beg = lineno_beg;         Expr->charno_beg = charno_beg;         Expr->lineno_end = f_lineno( -1 );         Expr->charno_end = f_charno( -1 ) + identlen( -1 );         goto ret;      }      else      {         Restore();         Expr = 0;         goto ret;      }   case '(':      step( 1 );      if(( Expr = expression()) == 0 )      {         Restore();         goto ret;      }      if( token( 0 ) == ')' )      {         step( 1 );         goto ret;      }      else  /* 03.02.97 rigo */      {         Restore();         f_ExprDestroy( Expr );         Expr = 0;         goto ret;      }   default: /* name *//*    printf( "vor f_Name: %s\n", ident( 0 )); */      lineno_beg = f_lineno( 0 );      charno_beg = f_charno( 0 );      if(( Name = f_Name()))      {/*          printf( "after f_Name: OK: %s\n", ident( 0 )); */         Expr = ExprCreateName( Name );         Expr->lineno_beg = lineno_beg;         Expr->charno_beg = charno_beg;         Expr->lineno_end = f_lineno( -1 );         Expr->charno_end = f_charno( -1 ) + identlen( -1 );         goto ret;      }      else      {/*          printf( "after f_Name: false: %s\n", ident( 0 )); */         Restore();         Expr = 0;         goto ret;      }   }ret:#ifdef TRACE   printf( "primary_expression: return: %d\n", Expr != 0 );#endif   return Expr;}static Expr_t allocation_expression( void ){   Expr_t Expr1;   Expr_t Expr;   List_t ListExpr;   Type_t Type;   Init_t Init;   int lineno_beg;   int charno_beg;   Save();#ifdef TRACE   printf( "allocation_expression: %s\n", ident( 0 ));#endif   if( token( 0 ) == SN_CLCL )   {      step( 1 );   }   if( token( 0 ) == SN_NEW )   {      step( 1 );      ListExpr = placement_opt();      lineno_beg = f_lineno( 0 );      charno_beg = f_charno( 0 );      if( token( 0 ) == '(' )      {         step( 1 );         if(( Type = f_TypeName( ")" )))         {            Expr1 = ExprCreateType( Type );            Expr1->lineno_beg = lineno_beg;            Expr1->charno_beg = charno_beg;            Expr1->lineno_end = f_lineno( 0 );            Expr1->charno_end = f_charno( 0 ) + identlen( 0 );            if( token( 0 ) == ')' )            {               step( 1 );            }            Init = f_NewInitializer();            Expr = ExprCreateNew( Expr1, Init, ListExpr );            return Expr;         }      }       else      {         if(( Type = f_NewTypeName()))         {            Expr1 = ExprCreateType( Type );            Expr1->lineno_beg = lineno_beg;            Expr1->charno_beg = charno_beg;            Expr1->lineno_end = f_lineno( -1 );            Expr1->charno_end = f_charno( -1 ) + identlen( -1 );            Init = f_NewInitializer();            Expr = ExprCreateNew( Expr1, Init, ListExpr );            return Expr;         }      }      f_ListDestroy( ListExpr, (void(*)()) f_ExprDestroy ); /* 08.12.97 rigo */   }   Restore();   return 0;}static List_t placement_opt( void ){   List_t ListExpr;   Save();   if( token( 0 ) == '(' )   {      step( 1 );      if(( ListExpr = expression_list()))      {         if( token( 0 ) == ')' )         {            step( 1 );         }         return ListExpr;      }   }   Restore();   return 0;}static Expr_t deallocation_expression( void ){   Expr_t Expr1;   Save();#ifdef TRACE   printf( "deallocation_expression: %s\n", ident( 0 ));#endif   if( token( 0 ) == SN_CLCL )   {      step( 1 );   }   if( token( 0 ) == SN_DELETE )   {      step( 1 );      /* opcionalis [] */      if( token( 0 ) == '[' && token( 1 ) == ']' )      {         step( 2 );      }      if(( Expr1 = cast_expression()))      {         return ExprCreateOp1( OPERATOR_DELETE, Expr1 );      }   }   Restore();   return 0;}static List_t expression_list( void ){   List_t ListExpr;   Expr_t Expr;   Save();   niveau++;   if(( Expr = assignment_expression()) == 0 )   {      Restore();      niveau--;      return 0;   }   ListExpr = f_ListCreate();   f_ListAddLast( &ListExpr, (Elem_t) Expr );   while( True )   {      switch( token( 0 ))      {      case ',': break;      default :         niveau--;         return ListExpr;      }      step( 1 );      if(( Expr = assignment_expression()) == 0 )      {         f_ListDestroy( ListExpr, (void(*)()) f_ExprDestroy );         Restore();         niveau--;         return 0;      }      f_ListAddLast( &ListExpr, (Elem_t) Expr );   }}static List_t expression_list_opt( void ){   List_t ListExpr;   Expr_t Expr;/*   Save(); */   niveau++;   ListExpr = f_ListCreate();   if(( Expr = assignment_expression()) == 0 )   {      niveau--;      return ListExpr;   }   f_ListAddLast( &ListExpr, (Elem_t) Expr );   while( True )   {      switch( token( 0 ))      {      case ',':         break;      default :         niveau--;         return ListExpr;      }      step( 1 );      if(( Expr = assignment_expression()) == 0 )      {/*           f_ListDestroy( ListExpr, (void(*)()) f_ExprDestroy ); *//*           Restore(); */         niveau--;         return ListExpr;      }      f_ListAddLast( &ListExpr, (Elem_t) Expr );   }}static Expr_t expression_member_name( void ){   Expr_t Expr;   Name_t Name;   int lineno_beg;   int charno_beg;   Save();   switch( token( 0 ))   {   case SN_ASM      :   case SN_CATCH    :   case SN_CLASS    :   case SN_DELETE   :   case SN_FRIEND   :   case SN_INLINE   :   case SN_NEW      :/* case SN_OPERATOR : */   case SN_OVERLOAD :   case SN_PRIVATE  :   case SN_PROTECTED:   case SN_PUBLIC   :   case SN_TEMPLATE :   case SN_THIS     :   case SN_THROW    :   case SN_TRY      :   case SN_VIRTUAL  :   case SN_VOLATILE :      Expr = ExprCreateMemberName( f_NameCreate( ident( 0 )));      Expr->lineno_beg = f_lineno( 0 );      Expr->charno_beg = f_charno( 0 );      Expr->lineno_end = f_lineno( 0 );      Expr->charno_end = f_charno( 0 ) + identlen( 0 );      step( 1 );      return Expr;   }   lineno_beg = f_lineno( 0 );   charno_beg = f_charno( 0 );   if(( Name = f_Name()))   {      Expr = ExprCreateMemberName( Name );      Expr->lineno_beg = lineno_beg;      Expr->charno_beg = charno_beg;      Expr->lineno_end = f_lineno( -1 );      Expr->charno_end = f_charno( -1 ) + identlen( -1 );      return Expr;   }   else   {      Restore();      return 0;   }}/*static void skip_function_arg( void ){   int paren = 0;   niveau++;   while( True )   {      switch( token( 0 ))      {      case '(':         paren++;         break;      case ')':         paren--;         if( paren == 0 )         {            step( 1 );            niveau--;            return;         }         break;      }      step( 1 );   }}*/static Expr_t ExprCreateOp1( int operator, Expr_t Expr1 ){   Expr_t Expr = (Expr_t) Malloc( sizeof( Expr[0] ));   Expr->ExprNext  = 0;   Expr->iCheck    = EXPR_CHECK;   Expr->_operator = operator;   Expr->Name      = 0;   Expr->Type      = 0;   Expr->Expr1     = Expr1;   Expr->Expr2     = 0;   Expr->Expr3     = 0;   Expr->Init      = 0;   Expr->ListExpr  = 0;   return Expr;}static Expr_t ExprCreateOp2( int operator, Expr_t Expr1, Expr_t Expr2 ){   Expr_t Expr = (Expr_t) Malloc( sizeof( Expr[0] ));   Expr->ExprNext  = 0;   Expr->iCheck    = EXPR_CHECK;   Expr->_operator = operator;   Expr->Name      = 0;   Expr->Type      = 0;   Expr->Expr1     = Expr1;   Expr->Expr2     = Expr2;   Expr->Expr3     = 0;   Expr->Init      = 0;   Expr->ListExpr  = 0;   return Expr;}static Expr_t ExprCreateOp3( int operator, Expr_t Expr1, Expr_t Expr2, Expr_t Expr3 ){   Expr_t Expr = (Expr_t) Malloc( sizeof( Expr[0] ));   Expr->ExprNext  = 0;   Expr->iCheck    = EXPR_CHECK;   Expr->_operator = operator;   Expr->Name      = 0;   Expr->Type      = 0;   Expr->Expr1     = Expr1;   Expr->Expr2     = Expr2;   Expr->Expr3     = Expr3;   Expr->Init      = 0;   Expr->ListExpr  = 0;   return Expr;}static Expr_t ExprCreateOp2List( int operator, Expr_t Expr1, List_t ListExpr ){   Expr_t Expr = (Expr_t) Malloc( sizeof( Expr[0] ));   Expr->ExprNext  = 0;   Expr->iCheck    = EXPR_CHECK;   Expr->_operator = operator;   Expr->Name      = 0;   Expr->Type      = 0;   Expr->Expr1     = Expr1;   Expr->Expr2     = 0;   Expr->Expr3     = 0;   Expr->Init      = 0;   Expr->ListExpr  = ListExpr;   return Expr;}static Expr_t ExprCreateName( Name_t Name ){   Expr_t Expr = (Expr_t) Malloc( sizeof( Expr[0] ));   Expr->ExprNext  = 0;   Expr->iCheck    = EXPR_CHECK;   Expr->_operator = OPERATOR_NAME;   Expr->Name      = Name;   Expr->Type      = 0;   Expr->Expr1     = 0;   Expr->Expr2     = 0;   Expr->Expr3     = 0;   Expr->Init      = 0;   Expr->ListExpr  = 0;   return Expr;}static Expr_t ExprCreateMemberName( Name_t Name ){   Expr_t Expr = (Expr_t) Malloc( sizeof( Expr[0] ));   Expr->ExprNext  = 0;   Expr->iCheck    = EXPR_CHECK;   Expr->_operator = OPERATOR_NAME;   Expr->Name      = Name;   Expr->Type      = 0;   Expr->Expr1     = 0;   Expr->Expr2     = 0;   Expr->Expr3     = 0;   Expr->Init      = 0;   Expr->ListExpr  = 0;   return Expr;}static Expr_t ExprCreateType( Type_t Type ){   Expr_t Expr = (Expr_t) Malloc( sizeof( Expr[0] ));   Expr->ExprNext  = 0;   Expr->iCheck    = EXPR_CHECK;   Expr->_operator = OPERATOR_TYPE;   Expr->Name      = 0;   Expr->Type      = Type;   Expr->Expr1     = 0;   Expr->Expr2     = 0;   Expr->Expr3     = 0;   Expr->Init      = 0;   Expr->ListExpr  = 0;   return Expr;}static Expr_t ExprCreateNew( Expr_t Expr1, Init_t Init, List_t ListExpr ){   Expr_t Expr = (Expr_t) Malloc( sizeof( Expr[0] ));   Expr->ExprNext  = 0;   Expr->iCheck    = EXPR_CHECK;   Expr->_operator = OPERATOR_NEW;   Expr->Name      = 0;   Expr->Type      = 0;   Expr->Expr1     = Expr1;      /* ExprType */   Expr->Expr2     = 0;   Expr->Expr3     = 0;   Expr->Init      = Init;   Expr->ListExpr  = ListExpr;   return Expr;}extern void f_ExprDestroy( Expr_t Expr ){   if( Expr )   {      if( Expr->iCheck != EXPR_CHECK ) Abort();      if( Expr->Name      ) f_NameDestroy( Expr->Name  );      if( Expr->Type      ) f_TypeDestroy( Expr->Type  );      if( Expr->Expr1     ) f_ExprDestroy( Expr->Expr1 );      if( Expr->Expr2     ) f_ExprDestroy( Expr->Expr2 );      if( Expr->Expr3     ) f_ExprDestroy( Expr->Expr3 );      if( Expr->Init      ) f_InitDestroy( Expr->Init  );      if( Expr->ListExpr  ) f_ListDestroy( Expr->ListExpr, (void(*)()) f_ExprDestroy );      ckfree( (char*)Expr );   }}static Boolean_t f_IsNameSimpleTypeName( Name_t Name ){   char *pcLess  ;   char *pcColon ;   pcLess  = strrchr( Name->pcName, '<' );   pcColon = strrchr( Name->pcName, ':' );   if( pcLess  == 0 ) return False;   if( pcColon == 0 ) return True;   if( pcLess > pcColon ) return True;   return False;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -