Changeset 385


Ignore:
Timestamp:
Jul 5, 2008, 5:58:51 PM (17 years ago)
Author:
cinc
Message:

Reworked class-, metod- and typespec parsers.

Location:
trunk/nomc
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/nomc/c/util.c

    r383 r385  
    258258void exitIfNotMatchNextKind(guint uiKind, gchar* msg)
    259259{
     260  printToken(gScanner->token);
    260261  if(!matchNextKind(uiKind))
    261262  {
  • trunk/nomc/parser_c/class_parser.c

    r383 r385  
    160160    }
    161161
    162     /* Check if the token is a known (registered) type */
    163     if(matchNextKind(KIND_TYPESPEC)) /* Be aware that we don't compare types here */
    164     {
    165       /* Get name, parameters and stuff. Print the body. */
    166       parseClassMethod();
    167     }
    168     else
    169     {
    170       getNextToken();
    171       g_scanner_unexp_token(gScanner,
    172                             G_TOKEN_IDENTIFIER,
    173                             NULL, NULL, NULL,
    174                             "Expected return type specifier.",
    175                             TRUE); /* is_error */
    176       cleanupAndExit(1);
    177     }
     162    /* Get name, parameters and stuff. Print the body. */
     163    parseClassMethod();
    178164  };
    179165
     
    225211  else
    226212  {
    227     if(matchNext(G_TOKEN_SYMBOL))
    228     {
    229       /* If the interface name is a symbol, it means the interface was
    230        already registered before. Maybe because of a forward statement.
    231        We will check that in the function which called us. */
    232      
    233       /* Check if it's one of our interface symbols */
    234       PSYMBOL pCurSymbol;
    235       GTokenValue value;
    236      
    237       value=gScanner->value;
    238       pCurSymbol=value.v_symbol;
    239       if(IDL_SYMBOL_REGINTERFACE!=pCurSymbol->uiSymbolToken)
    240       {
    241         /* No, some other symbol */
    242         g_scanner_unexp_token(gScanner,
    243                               G_TOKEN_SYMBOL,
    244                               NULL, NULL, NULL,
    245                               "Keyword 'class' is not followed by a valid identifier.",
    246                               TRUE); /* is_error */
    247         cleanupAndExit(1);
    248       }
    249 
    250       /* Save interface name */
    251       return g_strdup(pCurSymbol->chrSymbolName);
    252     }
    253     else
    254     {
     213    PSYMBOL pCurSymbol;
     214    GTokenValue value;
     215
     216    /* If the interface name is a symbol, it means the interface was
     217     already registered before. Maybe because of a forward statement.
     218     We will check that in the function which called us. */   
     219    exitIfNotMatchNext(G_TOKEN_SYMBOL, "Keyword 'class' must be followed by an identifier");
     220   
     221    /* Check if it's one of our interface symbols */
     222    value=gScanner->value;
     223    pCurSymbol=value.v_symbol;
     224    if(IDL_SYMBOL_REGINTERFACE!=pCurSymbol->uiSymbolToken)
     225    {
     226      /* No, some other symbol */
    255227      g_scanner_unexp_token(gScanner,
    256                             G_TOKEN_IDENTIFIER,
     228                            G_TOKEN_SYMBOL,
    257229                            NULL, NULL, NULL,
    258                             "Keyword 'class' must be followed by an identifier",
     230                            "Keyword 'class' is not followed by a valid identifier.",
    259231                            TRUE); /* is_error */
    260232      cleanupAndExit(1);
    261233    }
     234   
     235    /* Save interface name */
     236    return g_strdup(pCurSymbol->chrSymbolName);   
    262237  }
    263238}
     
    352327         | CLASSIDENT ':' PARENTCLASSIDENT CLASSBODY // Subclass (not used yet!)
    353328         | CLASSIDENT CLASSBODY
    354  
    355329 */
    356330void parseClass(GTokenType token)
  • trunk/nomc/parser_c/classmethod_parser.c

    r383 r385  
    109109    }
    110110   
     111    parseTypeSpec(pParam);
     112#if 0
    111113    /* Typespec */
    112114    if(matchNextKind(KIND_TYPESPEC)) /* Be aware that we don't compare types here */
     
    124126        cleanupAndExit(1);
    125127      }
    126 
     128#endif
    127129    //pParam->chrType=getTypeSpecStringFromCurToken();
    128130    //g_printf("%s %d", __FUNCTION__, __LINE__);
     
    312314  /* Parse method */
    313315  parseMethod(pMethod);
    314  
    315316}
    316317
     
    318319 
    319320 CLASSMETHODS:=  IMPL METHOD
    320  ^             | IMPL METHOD  CLASSMETHODS
     321               | IMPL METHOD  CLASSMETHODS
    321322*/
    322323 void parseClassMethods(void)
  • trunk/nomc/parser_c/interface_parser.c

    r383 r385  
    137137    //printToken(gScanner->token);
    138138
     139    parseInterfaceMethod();
     140   
     141#if 0
    139142    /* Typespec check must be first */
    140143    if(matchNextKind(KIND_TYPESPEC)) /* Be aware that we don't compare types here */
     
    189192        exit(1);
    190193      }
     194#endif
    191195    }while(g_scanner_peek_next_token(gScanner)!='}');
    192196  //g_printf("%d: ", __LINE__);
  • trunk/nomc/parser_c/interfacemethod_parser.c

    r383 r385  
    107107
    108108    /* Typespec */
     109    parseTypeSpec(pParam);
     110   
     111#if 0
    109112    if(matchNextKind(KIND_TYPESPEC)) /* Be aware that we don't compare types here */
    110113      parseTypeSpec(pParam);
     
    121124        cleanupAndExit(1);
    122125      }
    123 
     126#endif
     127   
    124128    //pParam->chrType=getTypeSpecStringFromCurToken();
    125129    //g_printf("%s %d", __FUNCTION__, __LINE__);
  • trunk/nomc/parser_c/typespec_parser.c

    r383 r385  
    5454 
    5555 */
    56 void parseTypeSpec2(PMETHODPARAM pMethodParam)
     56void parseTypeSpec(PMETHODPARAM pMethodParam)
    5757{
    5858  char *chrTemp;
     
    6868}
    6969
    70 
     70#if 0
    7171/*
    7272  Parse a typespec e.g. 'gulong' or 'gulong*'.
     
    103103    pMethodParam->uiStar++;
    104104}
     105#endif
    105106
    106 
    107 
    108 
    109 
Note: See TracChangeset for help on using the changeset viewer.