Ignore:
Timestamp:
Mar 25, 2007, 2:35:35 PM (18 years ago)
Author:
cinc
Message:

IDL file parsing more or less working.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/idl-compiler/c/nom-idl-compiler.c

    r267 r269  
    8383  {"NOMOVERRIDE", IDL_SYMBOL_OVERRIDE, KIND_UNKNOWN},
    8484  {"NOMREGISTEREDIFACE", IDL_SYMBOL_REGINTERFACE, KIND_TYPESPEC},
     85  {"NOMCLASSNAME", IDL_SYMBOL_CLSNAME, KIND_UNKNOWN},
     86  {"NOMMETACLASS", IDL_SYMBOL_OLDMETACLASS, KIND_UNKNOWN},
     87  {"MetaClass", IDL_SYMBOL_METACLASS, KIND_UNKNOWN},
    8588  {"native", IDL_SYMBOL_NATIVE, KIND_UNKNOWN},
    8689  {"gulong", IDL_SYMBOL_GULONG, KIND_TYPESPEC},
     
    9295
    9396  {"boolean", IDL_SYMBOL_BOOLEAN, KIND_TYPESPEC},
    94   {"String", IDL_SYMBOL_STRING, KIND_TYPESPEC},
     97  {"string", IDL_SYMBOL_STRING, KIND_TYPESPEC},
     98  {"long", IDL_SYMBOL_LONG, KIND_TYPESPEC},
     99  {"unsigned", IDL_SYMBOL_LONG, KIND_TYPESPEC},
    95100
    96101  {"in", IDL_SYMBOL_IN, KIND_DIRECTION},
     
    172177    }
    173178  return "unknown";
     179}
     180
     181/**
     182   This function is only for removing the NOMCLASSNAME() definition from
     183   the input stream. When everything is moved to the new IDL compiler
     184   those statements will be removed and this parsing function eventually
     185   removed.
     186
     187   The current token is the NOMCLASSNAME keyword.
     188
     189   CN:= G_TOKEN_SYMBOL '(' INDENT ')' ';'
     190 */
     191static void parseClassName(void)
     192{
     193
     194  if(!matchNext('('))
     195    {
     196      getNextToken(); /* Make sure error references the correct token */
     197      g_scanner_unexp_token(gScanner,
     198                            '(',
     199                            NULL,
     200                            NULL,
     201                            NULL,
     202                            "Error in NOMCLASSNAME()",
     203                            TRUE); /* is_error */
     204      exit(1);
     205    }
     206
     207  /* Identifier. We discard it. */
     208  if(!matchNext(G_TOKEN_IDENTIFIER))
     209    {
     210      g_scanner_unexp_token(gScanner,
     211                            G_TOKEN_IDENTIFIER,
     212                            NULL,
     213                            NULL,
     214                            NULL,
     215                            "Class name is not a valid identifier.",
     216                            TRUE); /* is_error */
     217      exit(1);
     218    }
     219
     220  if(!matchNext(')'))
     221    {
     222      getNextToken(); /* Make sure error references the correct token */
     223      g_scanner_unexp_token(gScanner,
     224                            ')',
     225                            NULL,
     226                            NULL,
     227                            NULL,
     228                            "Error in NOMCLASSNAME().",
     229                            TRUE); /* is_error */
     230      exit(1);
     231    }
     232
     233    if(!matchNext(';'))
     234      {
     235        getNextToken(); /* Make sure error references the correct token */
     236        g_scanner_unexp_token(gScanner,
     237                              ';',
     238                              NULL,
     239                              NULL,
     240                              NULL,
     241                              "Error in NOMCLASSNAME() definition, Missing semicolon at the end.",
     242                              TRUE); /* is_error */
     243        exit(1);
     244      }
     245}
     246
     247/**
     248   This function is only for removing the NOMMETACLASS() definition from
     249   the input stream. When everything is moved to the new IDL compiler
     250   those statements will be removed and this parsing function eventually
     251   removed.
     252
     253   The current token is the NOMMETACLASS keyword.
     254
     255   CN:= G_TOKEN_SYMBOL '(' INDENT ')' ';'
     256 */
     257static void parseOldMetaClass(void)
     258{
     259
     260  if(!matchNext('('))
     261    {
     262      getNextToken(); /* Make sure error references the correct token */
     263      g_scanner_unexp_token(gScanner,
     264                            '(',
     265                            NULL,
     266                            NULL,
     267                            NULL,
     268                            "Error in NOMMETACLASS()",
     269                            TRUE); /* is_error */
     270      exit(1);
     271    }
     272
     273  /* Identifier. We discard it. */
     274  if(!matchNext(G_TOKEN_IDENTIFIER))
     275    {
     276      g_scanner_unexp_token(gScanner,
     277                            G_TOKEN_IDENTIFIER,
     278                            NULL,
     279                            NULL,
     280                            NULL,
     281                            "Class name is not a valid identifier.",
     282                            TRUE); /* is_error */
     283      exit(1);
     284    }
     285
     286  if(!matchNext(')'))
     287    {
     288      getNextToken(); /* Make sure error references the correct token */
     289      g_scanner_unexp_token(gScanner,
     290                            ')',
     291                            NULL,
     292                            NULL,
     293                            NULL,
     294                            "Error in NOMMETACLASS().",
     295                            TRUE); /* is_error */
     296      exit(1);
     297    }
     298
     299    if(!matchNext(';'))
     300      {
     301        getNextToken(); /* Make sure error references the correct token */
     302        g_scanner_unexp_token(gScanner,
     303                              ';',
     304                              NULL,
     305                              NULL,
     306                              NULL,
     307                              "Error in NOMMETACLASS() definition, Missing semicolon at the end.",
     308                              TRUE); /* is_error */
     309        exit(1);
     310      }
    174311}
    175312
     
    278415              parseNative();
    279416              break;
     417            case IDL_SYMBOL_CLSNAME:
     418              parseClassName();
     419              break;
     420            case IDL_SYMBOL_OLDMETACLASS:
     421              parseOldMetaClass();
     422              break;
    280423            default:
    281424              break;
     
    378521void funcMsgHandler(GScanner *gScanner, gchar *message, gboolean error)
    379522{
    380   g_printf("In file %s, line %d:\n\t%s\n", parseInfo.chrCurrentSourceFile,
    381            g_scanner_cur_line(gScanner)-parseInfo.uiLineCorrection, message);
     523  g_printf("%s:%d: error: %s (%d %d)\n", parseInfo.chrCurrentSourceFile,
     524           g_scanner_cur_line(gScanner)-parseInfo.uiLineCorrection, message,
     525           g_scanner_cur_line(gScanner), parseInfo.uiLineCorrection);
    382526}
    383527
     
    485629
    486630  g_scanner_input_file(gScanner, fd);
     631  gScanner->config->case_sensitive=TRUE;
    487632  /* No single line comments */
    488633  gScanner->config->skip_comment_single=FALSE;
Note: See TracChangeset for help on using the changeset viewer.