Changeset 266 for trunk/idl-compiler/parser_c
- Timestamp:
- Mar 25, 2007, 1:07:25 AM (18 years ago)
- Location:
- trunk/idl-compiler/parser_c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/idl-compiler/parser_c/interface_parser.c
r265 r266 45 45 /* The pointer array holding the interfaces we found */ 46 46 extern GPtrArray* pInterfaceArray; 47 47 extern PARSEINFO parseInfo; 48 49 static void registerInterface(void) 50 { 51 PSYMBOL pNewSymbol=g_malloc0(sizeof(SYMBOL)); 52 53 g_ptr_array_add(pInterfaceArray, (gpointer) pCurInterface); 54 55 /* Any found interface is registered as a new type so it can be 56 used in other classes. */ 57 pNewSymbol->chrSymbolName=g_strdup(pCurInterface->chrName); /* We create a copy here because 58 when cleaning up the symbol space 59 the string will be freed. */ 60 pNewSymbol->uiKind=KIND_TYPESPEC; 61 pNewSymbol->uiSymbolToken=IDL_SYMBOL_REGINTERFACE; 62 g_tree_insert(parseInfo.pSymbolTree, pNewSymbol, pNewSymbol->chrSymbolName); 63 g_scanner_scope_add_symbol(gScanner, ID_SCOPE, pNewSymbol->chrSymbolName, 64 pNewSymbol); 65 } 48 66 49 67 static PINTERFACE createInterfaceStruct() … … 178 196 interface is already defined. 179 197 180 IS:= G_TOKEN_INDENTIFIER IB2 198 IS:= G_TOKEN_SYMBOL IB2 199 200 It's G_TOKEN_SYMBOL here because every found interface is registered 201 as a new symbol with GScanner. 181 202 */ 182 203 static void parseSubclassedIFace() 183 204 { 205 PSYMBOL pCurSymbol; 184 206 185 207 /* Parent interface */ 186 if(!matchNext(G_TOKEN_ IDENTIFIER))187 { 188 g_scanner_unexp_token(gScanner, 189 G_TOKEN_ IDENTIFIER,190 NULL, 191 NULL, 192 NULL, 193 "Parent interface name is missing .",208 if(!matchNext(G_TOKEN_SYMBOL)) 209 { 210 g_scanner_unexp_token(gScanner, 211 G_TOKEN_SYMBOL, 212 NULL, 213 NULL, 214 NULL, 215 "Parent interface name is missing or unknown.", 194 216 TRUE); /* is_error */ 195 217 exit(1); 196 218 } 197 219 GTokenValue value=gScanner->value; 198 pCurInterface->chrParent=g_strdup(value.v_identifier); 220 /* Make sure it's the correct symbol */ 221 pCurSymbol=value.v_symbol; 222 223 if(IDL_SYMBOL_REGINTERFACE!=pCurSymbol->uiSymbolToken) 224 { 225 g_scanner_unexp_token(gScanner, 226 G_TOKEN_SYMBOL, 227 NULL, 228 NULL, 229 NULL, 230 "Parent interface name is unknown.", 231 TRUE); /* is_error */ 232 exit(1); 233 } 234 pCurInterface->chrParent=g_strdup(pCurSymbol->chrSymbolName); 199 235 200 236 /* Check if the parent interface is known. */ … … 209 245 TRUE); /* is_error */ 210 246 exit(1); 211 212 247 } 213 248 … … 238 273 interface:= I ';' // Forward declaration 239 274 | I '{' IB '}' 240 | I ':' G_TOKEN_INDENTIFIER '{' IB '}' 275 | I ':' G_TOKEN_SYMBOL '{' IB '}' 276 277 It's G_TOKEN_SYMBOL here because every found interface is registered 278 as a new symbol with GScanner. 241 279 */ 242 280 void parseInterface(GTokenType token) … … 246 284 /* Get the interface name */ 247 285 parseIFace(token); 286 /* It's save to register the interface right here even if the struct is almost empty. 287 If anything goes wrong later we will exit anyway. */ 288 registerInterface(); 248 289 249 290 if(matchNext(';')) 250 291 { 251 292 pCurInterface->fIsForwardDeclaration=TRUE; 252 g_ptr_array_add(pInterfaceArray, (gpointer) pCurInterface);253 254 293 } 255 294 else if(matchNext(':')) 256 295 { 257 296 parseSubclassedIFace(); 258 g_ptr_array_add(pInterfaceArray, (gpointer) pCurInterface);259 297 } 260 298 else if(matchNext('{')) 261 299 { 262 300 parseIFaceBody(); 263 g_ptr_array_add(pInterfaceArray, (gpointer) pCurInterface);264 301 } 265 302 else -
trunk/idl-compiler/parser_c/lineinfo_parser.c
r264 r266 40 40 41 41 extern GScanner *gScanner; 42 42 extern PARSEINFO parseInfo; 43 43 44 44 /* … … 50 50 { 51 51 GTokenValue value; 52 PSYMBOLINFO psi=(PSYMBOLINFO)gScanner->user_data;53 52 54 53 /* Line number */ 55 54 value=gScanner->value; 56 p si->uiLineCorrection=value.v_int;55 parseInfo.uiLineCorrection=g_scanner_cur_line(gScanner)-value.v_int+1; 57 56 58 57 if(!matchNext(G_TOKEN_STRING)) … … 70 69 71 70 /* Current source file */ 72 if(p si->chrCurrentSourceFile)73 g_free(p si->chrCurrentSourceFile);71 if(parseInfo.chrCurrentSourceFile) 72 g_free(parseInfo.chrCurrentSourceFile); 74 73 75 74 value=gScanner->value; 76 p si->chrCurrentSourceFile=g_strdup(value.v_string);75 parseInfo.chrCurrentSourceFile=g_strdup(value.v_string); 77 76 78 77 /* Trailing file include level info isn't used for now. Note that for the root
Note:
See TracChangeset
for help on using the changeset viewer.