Changeset 382


Ignore:
Timestamp:
Jul 1, 2008, 9:49:27 PM (17 years ago)
Author:
cinc
Message:

Allow for empty class bodies.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/nomc/parser_c/class_parser.c

    r381 r382  
    124124
    125125
     126/*
     127 Function to parse the body of a class.
     128 Current token is '{'.
     129 
     130 CBODY:= '}'   //This is an empty class body
     131        | CLASSMETHODS '}'
     132 */
     133/*
     134 
     135 CLASSMETHODS:=  CLASSMETHOD
     136               | CLASSMETHOD CLASSMETHODS
     137 */
    126138
    127139/*
     
    129141  Current token is '{'.
    130142
    131   CBODY:=
     143  CBODY:= '}'   //This is an empty class body
     144         | IMPL CLASSMETHODS '}'
    132145 
    133146 */
    134147static void parseCBody(void)
    135148{
    136   /* Current token is '{' */
    137   PPARSEINFO pParseInfo=(PPARSEINFO)gScanner->user_data;
    138 
    139 
    140   do{
     149  PPARSEINFO pParseInfo=(PPARSEINFO)gScanner->user_data;
     150
     151  while(g_scanner_peek_next_token(gScanner)!= G_TOKEN_EOF && g_scanner_peek_next_token(gScanner)!='}')
     152  {
    141153    PSYMBOL pCurSymbol;
    142154    GTokenValue value;
    143        
    144     //pParseInfo->fPrintToken=TRUE;
    145     //printToken(gScanner->token);
    146155   
    147156    /* Method implementations must start with "impl" which is registered as a symbol. Here we check if
    148157     the token is a symbol. */
    149     TST_NEXT_TOKEN_NOT_OK(G_TOKEN_SYMBOL, "Method implementation must start with 'impl'.");
     158    exitIfNotMatchNext(G_TOKEN_SYMBOL, "Method implementation must start with 'impl'.");
    150159
    151160    value=gScanner->value;
     
    157166      g_scanner_unexp_token(gScanner,
    158167                            G_TOKEN_SYMBOL,
    159                             NULL,
    160                             NULL,
    161                             NULL,
     168                            NULL, NULL, NULL,
    162169                            "'impl'.",
    163170                            TRUE); /* is_error */
     
    176183      g_scanner_unexp_token(gScanner,
    177184                            G_TOKEN_IDENTIFIER,
    178                             NULL,
    179                             NULL,
    180                             NULL,
     185                            NULL, NULL, NULL,
    181186                            "Expected return type specifier.",
    182187                            TRUE); /* is_error */
    183188      cleanupAndExit(1);
    184189    }
    185   }while(g_scanner_peek_next_token(gScanner)!= G_TOKEN_EOF && g_scanner_peek_next_token(gScanner)!='}');
    186 
     190  };
     191
     192  exitIfNotMatchNext('}',  "No closing of 'class' section.");
    187193}
    188194
     
    193199  Current token is CLASSIDENT.
    194200
    195   CLASSBODY:=  '{' CBODY '}'
    196              | '{' CBODY '}' ';'
     201  CLASSBODY:=  '{' CBODY
     202             | '{' CBODY ';'
    197203
    198204*/
     
    203209   
    204210  parseCBody();
    205 
    206   exitIfNotMatchNext('}',  "No closing of 'interface' section.");
    207211   
    208212  /* Remove a terminating ';' from the input if present. */
Note: See TracChangeset for help on using the changeset viewer.