Ignore:
Timestamp:
Mar 24, 2007, 12:51:37 AM (18 years ago)
Author:
cinc
Message:

More work on the IDL compiler

File:
1 edited

Legend:

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

    r260 r261  
    8585
    8686
     87PINTERFACE findInterfaceFromName(gchar* chrName)
     88{
     89  int a;
     90
     91  for(a=0;a<pInterfaceArray->len;a++)
     92    {
     93      PINTERFACE pif=g_ptr_array_index(pInterfaceArray, a);
     94      if(!strcmp(chrName, pif->chrName))
     95        return pif;
     96    }
     97
     98  return NULL;
     99}
     100
    87101
    88102gchar* getTypeSpecStringFromCurToken(void)
     
    111125}
    112126
    113 void parseIt()
    114 {
    115 
    116 }
    117 
    118 
    119 /*
    120   Main entry point. This function is called from the EMX wrapper. Be aware that gtk_init()
    121   is already called in the wrapper.
     127/**
     128   This is the root parse function. Here starts the fun...
    122129 */
    123 int main(int argc, char **argv)
    124 {
    125   int a;
    126   int fd;
    127  
    128   int idScope=0;
    129 
    130   if(argc<2)
    131     return 1;
    132 
    133   for(a=0; a<argc; a++)
    134     {
    135       g_message("arg %d: %s", a, argv[a]);
    136     }
    137 
    138   fd=open(argv[1], O_RDONLY);
    139  
    140   if(-1==fd)
    141     {
    142       g_message("Can't open input file %s", argv[1]);
    143       exit(1);
    144     }
    145  
    146   g_printf("\n");
    147 
    148   gScanner=g_scanner_new(NULL);
    149   gScanner->user_data=(gpointer)&curSymbol;
    150   curSymbol.pSymbols=idlSymbols;
    151 
    152   pInterfaceArray=g_ptr_array_new();
    153 
    154   g_scanner_input_file(gScanner, fd);
    155   /* No single line comments */
    156   gScanner->config->skip_comment_single=FALSE;
    157   gScanner->config->cpair_comment_single="";
    158   gScanner->input_name=IDL_COMPILER_STRING;
    159 
    160   g_scanner_set_scope(gScanner, idScope);
    161   /* Load our own symbols into the scanner. We use the defualt scope for now. */
    162   while(pSymbols->chrSymbolName)
    163     {
    164       g_scanner_scope_add_symbol(gScanner, idScope, pSymbols->chrSymbolName, GINT_TO_POINTER(pSymbols->uiSymbolToken));
    165       pSymbols++;
    166     }
    167   gScanner->config->symbol_2_token=TRUE;
    168 
     130void parseIt(void)
     131{
    169132  while(g_scanner_peek_next_token(gScanner) != G_TOKEN_EOF) {
    170     /* get the next token */
    171133    GTokenType token;
     134
    172135    curToken=g_scanner_get_next_token(gScanner);
    173136    token=curToken;
     
    179142        parseInterface(token);
    180143        break;
     144
     145#if 0
    181146      case G_TOKEN_IDENTIFIER:
    182147        g_message("Token: %d (G_TOKEN_IDENTIFIER)\t\t%s", token, value.v_identifier);
     
    218183        g_message("Token: %d (IDL_SYMBOL_ENDIF)\t\t\t", token);
    219184        break;
     185#endif
    220186      default:
    221         g_message("Token: %d (---)\t\t\t%c (LINE %d)", token, token, g_scanner_cur_line(gScanner));
     187        printToken(curToken);
     188        //  g_message("Token: %d (---)\t\t\t%c (LINE %d)", token, token, g_scanner_cur_line(gScanner));
    222189        break;
    223190      }
    224191  }
    225   if(pCurInterface)
     192}
     193
     194
     195/*
     196
     197 */
     198int main(int argc, char **argv)
     199{
     200  int a;
     201  int fd;
     202 
     203  int idScope=0;
     204
     205  if(argc<2)
     206    return 1;
     207
     208  for(a=0; a<argc; a++)
     209    {
     210      g_message("arg %d: %s", a, argv[a]);
     211    }
     212
     213  fd=open(argv[1], O_RDONLY);
     214 
     215  if(-1==fd)
     216    {
     217      g_message("Can't open input file %s", argv[1]);
     218      exit(1);
     219    }
     220 
     221  g_printf("\n");
     222
     223  gScanner=g_scanner_new(NULL);
     224  gScanner->user_data=(gpointer)&curSymbol;
     225  curSymbol.pSymbols=idlSymbols;
     226
     227  pInterfaceArray=g_ptr_array_new();
     228
     229  g_scanner_input_file(gScanner, fd);
     230  /* No single line comments */
     231  gScanner->config->skip_comment_single=FALSE;
     232  gScanner->config->cpair_comment_single="";
     233  /* This string is used in error messages of the parser */
     234  gScanner->input_name=IDL_COMPILER_STRING;
     235
     236  g_scanner_set_scope(gScanner, idScope);
     237  /* Load our own symbols into the scanner. We use the default scope for now. */
     238  while(pSymbols->chrSymbolName)
     239    {
     240      g_scanner_scope_add_symbol(gScanner, idScope, pSymbols->chrSymbolName, GINT_TO_POINTER(pSymbols->uiSymbolToken));
     241      pSymbols++;
     242    }
     243  gScanner->config->symbol_2_token=TRUE;
     244
     245  parseIt();
     246
     247  if(pInterfaceArray->len)
    226248    printInterface();
    227249
Note: See TracChangeset for help on using the changeset viewer.