Changeset 309 for trunk/idl-compiler/parser_c
- Timestamp:
- Sep 30, 2007, 8:45:15 PM (18 years ago)
- Location:
- trunk/idl-compiler/parser_c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/idl-compiler/parser_c/interface_parser.c
r290 r309 32 32 * 33 33 * ***** END LICENSE BLOCK ***** */ 34 35 /* 36 Main file containing the interface parser. Whenever a valid keyword is found 37 a specialized parser function in another source file is called from here. 38 */ 34 39 #include <os2.h> 35 40 #include <stdlib.h> … … 113 118 /* 114 119 Function to parse the body of an interface declaration. 120 Current token is '{'. 115 121 116 122 IB:= CV // NOMCLASSVERSION() … … 134 140 else if(matchNext('#')) 135 141 parseHash(); 142 else if(matchNext(G_TOKEN_IDENTIFIER)) 143 { 144 /* This may be an override statement */ 145 parseOverrideMethodFromIdentifier(); 146 } 136 147 else if(matchNext(G_TOKEN_SYMBOL)) 137 148 { … … 143 154 switch(pCurSymbol->uiSymbolToken) 144 155 { 156 case IDL_SYMBOL_OVERRIDE: /* This one is deprecated */ 157 parseOverrideMethod(); 158 break; 145 159 case IDL_SYMBOL_CLSVERSION: 146 160 parseClassVersion(); 147 break;148 case IDL_SYMBOL_OVERRIDE:149 parseOverrideMethod();150 161 break; 151 162 case IDL_SYMBOL_INSTANCEVAR: … … 159 170 break; 160 171 default: 161 g_scanner_unexp_token(gScanner, 162 G_TOKEN_SYMBOL, 163 NULL, 164 NULL, 165 NULL, 166 "Trying to parse interface body.", 167 TRUE); /* is_error */ 168 exit(1); 172 { 173 g_scanner_unexp_token(gScanner, 174 G_TOKEN_SYMBOL, 175 NULL, 176 NULL, 177 NULL, 178 "Trying to parse interface body.", 179 TRUE); /* is_error */ 180 exit(1); 181 } 169 182 }/* switch */ 170 183 } -
trunk/idl-compiler/parser_c/override_parser.c
r271 r309 38 38 39 39 #include <glib.h> 40 #include <glib/gprintf.h> 40 41 #include "parser.h" 41 42 … … 67 68 68 69 /* 69 Parse the class version. Note that the identifieris the current symbol..70 Parse override. Note that 'NOMOVERRIDE' is the current symbol.. 70 71 71 72 OM:= IDL_SYMBOL_OVERRIDE '(' IDENT ')' ';' … … 90 91 } 91 92 93 /* This is the method we actually try to override */ 92 94 if(!matchNext(G_TOKEN_IDENTIFIER)) 93 95 { … … 98 100 NULL, 99 101 NULL, 100 "Error in NOMOVERRIDE() ",102 "Error in NOMOVERRIDE(). Identifier expected.", 101 103 TRUE); /* is_error */ 102 104 exit(1); … … 108 110 if((pif=findInterfaceForMethod(pParseInfo->pCurInterface, pOMethod->chrName))==NULL) 109 111 { 110 111 g_message("%s:%d: Method '%s' was not introduced by some parent interface.", gScanner->input_name,112 g_scanner_cur_line(gScanner),pOMethod->chrName);112 g_printf("%s:%d: error: Method '%s' was not introduced by some parent interface.\n", 113 pParseInfo->chrCurrentSourceFile, g_scanner_cur_line(gScanner)-pParseInfo->uiLineCorrection, 114 pOMethod->chrName); 113 115 exit(1); 114 116 } … … 124 126 NULL, 125 127 NULL, 126 "Error in NOMOVERRIDE() ",128 "Error in NOMOVERRIDE(). Closing ')' is missing.", 127 129 TRUE); /* is_error */ 128 130 exit(1); … … 136 138 NULL, 137 139 NULL, 138 "Error in NOMOVERRIDE() ",140 "Error in NOMOVERRIDE(). Missing ';' at end of statement.", 139 141 TRUE); /* is_error */ 140 142 exit(1); … … 142 144 g_ptr_array_add(pParseInfo->pCurInterface->pOverrideArray, (gpointer) pOMethod); 143 145 } 146 147 148 /* 149 Parse override. Note that the identifier is the current symbol. 150 151 OM:= IDENT ':' IDL_SYMBOL_OVERRIDE2 ';' 152 */ 153 void parseOverrideMethodFromIdentifier(void) 154 { 155 GTokenValue value; 156 POVERMETHOD pOMethod=g_malloc0(sizeof(OVERMETHOD)); 157 PINTERFACE pif; 158 159 /* Keep the current identifier. We need to check for existance later if we find 160 we are in an override statement. */ 161 value=gScanner->value; 162 pOMethod->chrName=g_strdup(value.v_identifier); 163 164 if(!matchNext(':')) 165 { 166 getNextToken(); /* Make sure error references the correct token */ 167 g_scanner_unexp_token(gScanner, 168 ':', 169 NULL, 170 NULL, 171 NULL, 172 "", 173 TRUE); /* is_error */ 174 exit(1); 175 } 176 177 /* Check for 'override' */ 178 if(!matchNext(G_TOKEN_SYMBOL)) 179 { 180 getNextToken(); /* Make sure error references the correct token */ 181 g_scanner_unexp_token(gScanner, 182 G_TOKEN_SYMBOL, 183 NULL, 184 NULL, 185 NULL, 186 "'override' keyword expected.", 187 TRUE); /* is_error */ 188 exit(1); 189 } 190 else 191 { 192 /* Check if symbol is 'override' */ 193 PSYMBOL pCurSymbol; 194 195 value=gScanner->value; 196 pCurSymbol=value.v_symbol; 197 198 if(pCurSymbol->uiSymbolToken != IDL_SYMBOL_OVERRIDE2) 199 { 200 g_scanner_unexp_token(gScanner, 201 G_TOKEN_SYMBOL, 202 NULL, 203 NULL, 204 NULL, 205 "'override' keyword expected after ':'.", 206 TRUE); /* is_error */ 207 exit(1); 208 } 209 } 210 211 /* Now check if the method was introduced by some parent */ 212 if((pif=findInterfaceForMethod(pParseInfo->pCurInterface, pOMethod->chrName))==NULL) 213 { 214 g_printf("%s:%d: error: Method '%s' was not introduced by some parent interface.\n", 215 pParseInfo->chrCurrentSourceFile, g_scanner_cur_line(gScanner)-pParseInfo->uiLineCorrection, 216 pOMethod->chrName); 217 exit(1); 218 } 219 220 221 pOMethod->chrIntroducingIFace=pif->chrName; /* No copy of string here. Nobody should free the 222 interface info under our feet. */ 223 224 /* Check for trailing ';' */ 225 if(!matchNext(';')) 226 { 227 getNextToken(); /* Make sure error references the correct token */ 228 g_scanner_unexp_token(gScanner, 229 ';', 230 NULL, 231 NULL, 232 NULL, 233 "Error in override statement. Trailing ';' is missing.", 234 TRUE); /* is_error */ 235 exit(1); 236 } 237 g_ptr_array_add(pParseInfo->pCurInterface->pOverrideArray, (gpointer) pOMethod); 238 }
Note:
See TracChangeset
for help on using the changeset viewer.