Changeset 271 for trunk/idl-compiler
- Timestamp:
- Mar 25, 2007, 8:32:59 PM (18 years ago)
- Location:
- trunk/idl-compiler
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/idl-compiler/Makefile
r269 r271 12 12 13 13 PARSERDIR = ./parser_c 14 HEMITTERDIR = ./h-emitter_c 14 15 15 16 CFLAGS = -Zmt -Zcrtdll -D__OS2__ -D__ST_MT_ERRNO__ -c -Wall … … 35 36 $(OBJDIR)/lineinfo_parser.o \ 36 37 $(OBJDIR)/metaclass_parser.o \ 38 $(OBJDIR)/h_file_emitter.o \ 37 39 $(OBJDIR)/printdata.o 38 40 … … 66 68 $(CC) -I $(INC) $(CFLAGS) -o$@ $< 67 69 70 $(OBJDIR)/%.o: $(HEMITTERDIR)/%.c $(INCDIR)/parser.h 71 $(CC) -I $(INC) $(CFLAGS) -o$@ $< 68 72 69 73 # Create the directories for temp files -
trunk/idl-compiler/c/nom-idl-compiler.c
r269 r271 109 109 110 110 GScanner *gScanner; 111 GTokenType curToken=G_TOKEN_EOF;112 PINTERFACE pCurInterface=NULL;113 111 114 112 /* Holding info about current token. Referenced by gScanner. */ 115 SYMBOLINFO curSymbol;113 //SYMBOLINFO curSymbol; 116 114 117 115 /* Holding the current state of parsing and pointers to necessary lists. */ 118 116 PARSEINFO parseInfo={0}; 117 PPARSEINFO pParseInfo=&parseInfo; 119 118 120 119 /** … … 151 150 value=gScanner->value; 152 151 153 switch( curToken)152 switch(gScanner->token) 154 153 { 155 154 case G_TOKEN_IDENTIFIER: … … 395 394 GTokenType token; 396 395 397 curToken=g_scanner_get_next_token(gScanner);398 token= curToken;396 g_scanner_get_next_token(gScanner); 397 token=gScanner->token; 399 398 GTokenValue value=gScanner->value; 400 399 401 switch( curToken)400 switch(token) 402 401 { 403 402 case '#': … … 465 464 #endif 466 465 default: 467 printToken( curToken);466 printToken(token); 468 467 break; 469 468 } … … 535 534 /* Vars for filename building */ 536 535 char* chrOutputFileName=""; 536 char* chrTemp; 537 537 538 538 GError *gError = NULL; … … 557 557 a++; 558 558 559 #if 0560 559 if(!a){ 561 560 g_printf("An emitter must be specified.\n\n"); … … 566 565 outputCompilerHelp(gContext, argv[0]); 567 566 } 568 #endif569 567 570 568 if(strlen(chrOutputName)==0) … … 602 600 chrOutputFileName=chrOutputName; 603 601 604 //g_message("Output file: %s", chrOutputFileName); 602 /* Add emitter extension */ 603 if(fOptionEmitH) 604 chrTemp=g_strconcat(chrOutputFileName, ".h", NULL); 605 else if(fOptionEmitIH) 606 chrTemp=g_strconcat(chrOutputFileName, ".ih", NULL); 607 else if(fOptionEmitC) 608 chrTemp=g_strconcat(chrOutputFileName, ".c", NULL); 609 g_free(chrOutputFileName); 610 chrOutputFileName=chrTemp; 611 612 g_message("Output file: %s", chrOutputFileName); 605 613 606 614 /* Open input */ … … 622 630 623 631 gScanner=g_scanner_new(NULL); 624 gScanner->user_data=(gpointer)&curSymbol; 625 curSymbol.pSymbols=idlSymbols; 632 //gScanner->user_data=(gpointer)&curSymbol; 626 633 627 634 gScanner->msg_handler=funcMsgHandler; … … 650 657 parseIt(); 651 658 659 /* Write the output file */ 660 if(fOptionEmitH) 661 emitHFile(pInterfaceArray); 662 663 #if 0 664 else if(fOptionEmitIH) 665 666 else if(fOptionEmitC) 667 a++; 668 652 669 if(pInterfaceArray->len) 653 670 printInterface(); 671 #endif 654 672 655 673 g_scanner_destroy(gScanner); -
trunk/idl-compiler/c/printdata.c
r270 r271 144 144 g_printf("\tMinor:\t\t%ld\n", pif->ulMinor); 145 145 g_printf("\tForward decl.:\t%s\n", (pif->fIsForwardDeclaration ? "Yes" : "No")); 146 g_printf("\tMetaclass::\t%s\n", (pif->chrMetaClass ? pif->chrMetaClass : "None")); 146 g_printf("\tMetaclass:\t%s\n", (pif->chrMetaClass ? pif->chrMetaClass : "None")); 147 g_printf("\tSource file:\t%s\n", pif->chrSourceFileName); 147 148 /* Print instance vars */ 148 149 g_printf("\tInstance vars:\t%d\n", pif->pInstanceVarArray->len); -
trunk/idl-compiler/c/token.c
r265 r271 40 40 41 41 extern GScanner *gScanner; 42 extern GTokenType curToken;42 extern PPARSEINFO pParseInfo; 43 43 44 44 /* … … 48 48 void setCurSymbolInfo(void) 49 49 { 50 PSYMBOLINFO psi; 51 52 psi=(PSYMBOLINFO)gScanner->user_data; 53 54 switch(curToken) 50 switch(gScanner->token) 55 51 { 56 52 case G_TOKEN_IDENTIFIER: … … 58 54 break; 59 55 default: 60 p si->uiCurSymbolKind=KIND_UNKNOWN;61 break; 62 } 63 if( curToken==G_TOKEN_SYMBOL)56 pParseInfo->uiCurSymbolKind=KIND_UNKNOWN; 57 break; 58 } 59 if(gScanner->token==G_TOKEN_SYMBOL) 64 60 { 65 61 GTokenValue value; … … 69 65 pCurSymbol=value.v_symbol; 70 66 71 p si->uiCurSymbolKind=pCurSymbol->uiKind;67 pParseInfo->uiCurSymbolKind=pCurSymbol->uiKind; 72 68 } 73 69 } … … 75 71 guint queryCurTokensKind(void) 76 72 { 77 PSYMBOLINFO psi; 78 79 psi=(PSYMBOLINFO)gScanner->user_data; 80 return psi->uiCurSymbolKind; 73 return pParseInfo->uiCurSymbolKind; 81 74 } 82 75 … … 121 114 void getNextToken(void) 122 115 { 123 curToken =g_scanner_get_next_token(gScanner);116 g_scanner_get_next_token(gScanner); 124 117 setCurSymbolInfo(); 125 118 } … … 138 131 gboolean matchCur(GTokenType token) 139 132 { 140 if(token== curToken)133 if(token==gScanner->token) 141 134 { 142 135 return TRUE; … … 190 183 default: 191 184 { 192 PSYMBOLINFO psi;193 psi=(PSYMBOLINFO)gScanner->user_data;194 195 185 g_message("Token: %d (%s)\t\t\t (LINE %d)", pCurSymbol->uiSymbolToken, 196 186 pCurSymbol->chrSymbolName, g_scanner_cur_line(gScanner)); -
trunk/idl-compiler/include/parser.h
r269 r271 84 84 gulong ulMinor; /* Class version */ 85 85 gboolean fIsForwardDeclaration; 86 gboolean fIsInRootFile; 86 87 gchar* chrMetaClass; /* Pointer to metaclass name or NULL*/ 88 char* chrSourceFileName; /* The preprocessor includes files for us. This is the info 89 about the file this interface is defined in. */ 87 90 GPtrArray *pMethodArray; 88 91 GPtrArray *pOverrideArray; … … 101 104 typedef struct 102 105 { 103 const SYMBOL *pSymbols; /* List of our introduced symbols */ 104 guint uiCurSymbolKind; 105 guint uiLineCorrection; /* This is the line number put by the preprocessor into 106 the source file. It's used to calculate proper line numbers 107 for errors. */ 108 char* chrCurrentSourceFile;/* The preprocessor includes files for us. This is the info 109 about their name. */ 106 guint _uiCurSymbolKind; 110 107 }SYMBOLINFO,*PSYMBOLINFO; 111 108 112 109 typedef struct 113 110 { 111 PINTERFACE pCurInterface; /* The interface we are currently parsing. This is a working pointer. */ 112 guint uiCurSymbolKind; /* This may be e.g. KIND_TYPESPEC */ 114 113 GTree* pSymbolTree; /* Our introduced symbols */ 115 114 guint uiLineCorrection; /* This is the line number put by the preprocessor into 116 115 the source file. It's used to calculate proper line numbers 117 116 for errors. */ 117 char* chrRootSourceFile; /* File we are intending to parse. Others may get included. */ 118 118 char* chrCurrentSourceFile;/* The preprocessor includes files for us. This is the info 119 119 about their name. */ … … 179 179 void parsePreprocLineInfo(void); 180 180 void parseMetaClass(void); 181 182 void emitHFile(GPtrArray* pInterfaceArray); -
trunk/idl-compiler/parser_c/classversion_parser.c
r267 r271 40 40 41 41 extern GScanner *gScanner; 42 extern PINTERFACE pCurInterface; 42 extern PPARSEINFO pParseInfo; 43 43 44 /* 44 45 Parse the class version. Note that the identifier is the current symbol.. … … 76 77 } 77 78 value=gScanner->value; 78 p CurInterface->ulMajor=value.v_int;79 pParseInfo->pCurInterface->ulMajor=value.v_int; 79 80 80 81 if(!matchNext(',')) … … 103 104 } 104 105 value=gScanner->value; 105 p CurInterface->ulMinor=value.v_int;106 pParseInfo->pCurInterface->ulMinor=value.v_int; 106 107 107 108 if(!matchNext(')')) -
trunk/idl-compiler/parser_c/instancevar_parser.c
r267 r271 40 40 41 41 extern GScanner *gScanner; 42 extern P INTERFACE pCurInterface;42 extern PPARSEINFO pParseInfo; 43 43 44 44 /* … … 122 122 exit(1); 123 123 } 124 if(!p CurInterface)124 if(!pParseInfo->pCurInterface) 125 125 { 126 126 g_message("Error: no interface for some reason"); 127 127 } 128 128 129 g_ptr_array_add(p CurInterface->pInstanceVarArray , (gpointer) pInstanceVar);129 g_ptr_array_add(pParseInfo->pCurInterface->pInstanceVarArray , (gpointer) pInstanceVar); 130 130 } -
trunk/idl-compiler/parser_c/interface_parser.c
r270 r271 41 41 42 42 extern GScanner *gScanner; 43 extern GTokenType curToken;44 extern PINTERFACE pCurInterface;45 43 /* The pointer array holding the interfaces we found */ 46 44 extern GPtrArray* pInterfaceArray; 47 extern P ARSEINFO parseInfo;45 extern PPARSEINFO pParseInfo; 48 46 49 47 static void registerInterface(void) … … 51 49 PSYMBOL pNewSymbol=g_malloc0(sizeof(SYMBOL)); 52 50 53 g_ptr_array_add(pInterfaceArray, (gpointer) pCurInterface); 51 if(!strcmp(pParseInfo->chrRootSourceFile, pParseInfo->pCurInterface->chrSourceFileName)) 52 pParseInfo->pCurInterface->fIsInRootFile=TRUE; 53 54 g_ptr_array_add(pInterfaceArray, (gpointer) pParseInfo->pCurInterface); 54 55 55 56 /* Any found interface is registered as a new type so it can be 56 57 used in other classes. */ 57 pNewSymbol->chrSymbolName=g_strdup(p CurInterface->chrName); /* We create a copy here because58 when cleaning up the symbol space59 the string will be freed. */58 pNewSymbol->chrSymbolName=g_strdup(pParseInfo->pCurInterface->chrName); /* We create a copy here because 59 when cleaning up the symbol space 60 the string will be freed. */ 60 61 pNewSymbol->uiKind=KIND_TYPESPEC; 61 62 pNewSymbol->uiSymbolToken=IDL_SYMBOL_REGINTERFACE; 62 g_tree_insert(p arseInfo.pSymbolTree, pNewSymbol, pNewSymbol->chrSymbolName);63 g_tree_insert(pParseInfo->pSymbolTree, pNewSymbol, pNewSymbol->chrSymbolName); 63 64 g_scanner_scope_add_symbol(gScanner, ID_SCOPE, pNewSymbol->chrSymbolName, 64 65 pNewSymbol); … … 68 69 pNewSymbol->uiKind=KIND_TYPESPEC; 69 70 pNewSymbol->uiSymbolToken=IDL_SYMBOL_REGINTERFACE; 70 pNewSymbol->chrSymbolName=g_strconcat("P", pCurInterface->chrName, NULL); 71 g_message("%s: %s", __FUNCTION__, pNewSymbol->chrSymbolName); 72 g_tree_insert(parseInfo.pSymbolTree, pNewSymbol, pNewSymbol->chrSymbolName); 71 pNewSymbol->chrSymbolName=g_strconcat("P", pParseInfo->pCurInterface->chrName, NULL); 72 g_tree_insert(pParseInfo->pSymbolTree, pNewSymbol, pNewSymbol->chrSymbolName); 73 73 g_scanner_scope_add_symbol(gScanner, ID_SCOPE, pNewSymbol->chrSymbolName, 74 74 pNewSymbol); 75 //g_message("%s: %s", __FUNCTION__, pNewSymbol->chrSymbolName); 75 76 } 76 77 … … 179 180 /* Save interface info */ 180 181 GTokenValue value=gScanner->value; 181 p CurInterface->chrName=g_strdup(value.v_identifier);182 pParseInfo->pCurInterface->chrName=g_strdup(value.v_identifier); 182 183 } 183 184 … … 247 248 exit(1); 248 249 } 249 p CurInterface->chrParent=g_strdup(pCurSymbol->chrSymbolName);250 pParseInfo->pCurInterface->chrParent=g_strdup(pCurSymbol->chrSymbolName); 250 251 251 252 /* Check if the parent interface is known. */ 252 if(!findInterfaceFromName(p CurInterface->chrParent))253 if(!findInterfaceFromName(pParseInfo->pCurInterface->chrParent)) 253 254 { 254 255 g_scanner_unexp_token(gScanner, … … 295 296 void parseInterface(GTokenType token) 296 297 { 297 p CurInterface=createInterfaceStruct();298 pParseInfo->pCurInterface=createInterfaceStruct(); 298 299 299 300 /* Get the interface name */ 300 301 parseIFace(token); 302 pParseInfo->pCurInterface->chrSourceFileName=g_strdup(pParseInfo->chrCurrentSourceFile); 303 301 304 /* It's save to register the interface right here even if the struct is almost empty. 302 305 If anything goes wrong later we will exit anyway. */ … … 305 308 if(matchNext(';')) 306 309 { 307 p CurInterface->fIsForwardDeclaration=TRUE;310 pParseInfo->pCurInterface->fIsForwardDeclaration=TRUE; 308 311 } 309 312 else if(matchNext(':')) -
trunk/idl-compiler/parser_c/lineinfo_parser.c
r267 r271 41 41 42 42 extern GScanner *gScanner; 43 extern P ARSEINFO parseInfo;43 extern PPARSEINFO pParseInfo; 44 44 45 45 /* … … 54 54 /* Line number */ 55 55 value=gScanner->value; 56 p arseInfo.uiLineCorrection=g_scanner_cur_line(gScanner)-value.v_int+1;56 pParseInfo->uiLineCorrection=g_scanner_cur_line(gScanner)-value.v_int+1; 57 57 58 58 if(!matchNext(G_TOKEN_STRING)) … … 69 69 } 70 70 71 value=gScanner->value; 72 73 /* Root source file? */ 74 if(!pParseInfo->chrRootSourceFile) 75 pParseInfo->chrRootSourceFile=g_strdup(value.v_string); 76 71 77 /* Current source file */ 72 if(p arseInfo.chrCurrentSourceFile)73 g_free(p arseInfo.chrCurrentSourceFile);78 if(pParseInfo->chrCurrentSourceFile) 79 g_free(pParseInfo->chrCurrentSourceFile); 74 80 75 value=gScanner->value; 76 parseInfo.chrCurrentSourceFile=g_strdup(value.v_string); 81 pParseInfo->chrCurrentSourceFile=g_strdup(value.v_string); 77 82 78 83 /* Trailing file include level info isn't used for now. Note that for the root -
trunk/idl-compiler/parser_c/method_parser.c
r269 r271 41 41 extern GScanner *gScanner; 42 42 extern GTokenType curToken; 43 extern P INTERFACE pCurInterface;43 extern PPARSEINFO pParseInfo; 44 44 45 45 /* In override_parser.c */ … … 180 180 pMethod->chrName=g_strdup(value.v_identifier); 181 181 182 /* Now check if the method was introduced by some parent */ 183 if((pif=findInterfaceForMethod(pCurInterface, pMethod->chrName))!=NULL) 182 /* Now check if the method was introduced by some parent. The interface struct contains 183 the parent name if any and the function will follow the chain of parents. */ 184 if((pif=findInterfaceForMethod(pParseInfo->pCurInterface, pMethod->chrName))!=NULL) 184 185 { 185 186 gchar* chrMessage; … … 226 227 exit(1); 227 228 } 228 g_ptr_array_add( p CurInterface->pMethodArray, (gpointer) pMethod);229 g_ptr_array_add( pParseInfo->pCurInterface->pMethodArray, (gpointer) pMethod); 229 230 return; 230 231 } … … 259 260 } 260 261 261 g_ptr_array_add( p CurInterface->pMethodArray, (gpointer) pMethod);262 g_ptr_array_add( pParseInfo->pCurInterface->pMethodArray, (gpointer) pMethod); 262 263 } -
trunk/idl-compiler/parser_c/override_parser.c
r267 r271 42 42 43 43 extern GScanner *gScanner; 44 extern PINTERFACE pCurInterface; 44 //extern PINTERFACE pCurInterface; 45 extern PPARSEINFO pParseInfo; 45 46 46 47 PINTERFACE findInterfaceForMethod(PINTERFACE pStartInterface, gchar* chrMethodName) … … 105 106 106 107 /* Now check if the method was introduced by some parent */ 107 if((pif=findInterfaceForMethod(p CurInterface, pOMethod->chrName))==NULL)108 if((pif=findInterfaceForMethod(pParseInfo->pCurInterface, pOMethod->chrName))==NULL) 108 109 { 109 110 … … 139 140 exit(1); 140 141 } 141 g_ptr_array_add(p CurInterface->pOverrideArray, (gpointer) pOMethod);142 g_ptr_array_add(pParseInfo->pCurInterface->pOverrideArray, (gpointer) pOMethod); 142 143 }
Note:
See TracChangeset
for help on using the changeset viewer.