Changeset 261 for trunk/idl-compiler/parser_c
- Timestamp:
- Mar 24, 2007, 12:51:37 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/idl-compiler/parser_c/interface_parser.c
r259 r261 34 34 #include <os2.h> 35 35 #include <stdlib.h> 36 #include <string.h> 36 37 37 38 #include <glib.h> … … 65 66 | OV // Overriden method 66 67 */ 67 void parseI FaceBody(void)68 void parseIBody(void) 68 69 { 69 70 /* Current token is '{' */ … … 97 98 98 99 /* 100 Parse the interface name. 101 Note that the current token is the 'interface' keyword. 102 99 103 I:= IDL_SYMBOL_INTERFACE G_TOKEN_INDENTIFIER 100 104 */ … … 114 118 /* Save interface info */ 115 119 GTokenValue value=gScanner->value; 116 pCurInterface=createInterfaceStruct();117 120 pCurInterface->chrName=g_strdup(value.v_identifier); 118 121 } 119 122 120 123 /* 124 Current token is '{'. 125 126 IB2:= '{' IB '}' 127 | '{' IB '}' ';' 128 129 */ 130 static void parseIFaceBody(void) 131 { 132 parseIBody(); 133 if(!matchNext('}')) 134 { 135 g_scanner_unexp_token(gScanner, 136 '}', 137 NULL, 138 NULL, 139 NULL, 140 "No closing of 'interface' section.", 141 TRUE); /* is_error */ 142 exit(1); 143 } 144 /* Remove a terminating ';' from the input if present. */ 145 matchNext(';'); 146 } 147 148 /* 149 Parse an interface which is subclassed. This includes checking if the parent 150 interface is already defined. 151 152 IS:= G_TOKEN_INDENTIFIER IB2 153 */ 154 static void parseSubclassedIFace() 155 { 156 157 /* Parent interface */ 158 if(!matchNext(G_TOKEN_IDENTIFIER)) 159 { 160 g_scanner_unexp_token(gScanner, 161 G_TOKEN_IDENTIFIER, 162 NULL, 163 NULL, 164 NULL, 165 "Parent interface name is missing.", 166 TRUE); /* is_error */ 167 exit(1); 168 } 169 GTokenValue value=gScanner->value; 170 pCurInterface->chrParent=g_strdup(value.v_identifier); 171 172 /* Check if the parent interface is known. */ 173 if(!findInterfaceFromName(pCurInterface->chrParent)) 174 { 175 g_scanner_unexp_token(gScanner, 176 G_TOKEN_IDENTIFIER, 177 NULL, 178 NULL, 179 NULL, 180 "Parent interface in definition is unknown.", 181 TRUE); /* is_error */ 182 exit(1); 183 184 } 185 186 if(!matchNext('{')) 187 { 188 g_scanner_unexp_token(gScanner, 189 '{', 190 NULL, 191 NULL, 192 NULL, 193 "No opening brace in interface definition.", 194 TRUE); /* is_error */ 195 exit(1); 196 197 } 198 parseIFaceBody(); 199 } 200 201 /* 121 202 Parse an interface declaration. The current token is the 'interface' keyword. 203 204 interface:= I ';' // Forward declaration 205 | I IB2 206 | I ':' IS // Subclassed interface 207 208 This translates into: 122 209 123 210 interface:= I ';' // Forward declaration 124 211 | I '{' IB '}' 125 | I ':' G_TOKEN_INDENTIFIER '{' ID '}' 126 127 212 | I ':' G_TOKEN_INDENTIFIER '{' IB '}' 128 213 */ 129 214 void parseInterface(GTokenType token) 130 215 { 216 pCurInterface=createInterfaceStruct(); 217 218 /* Get the interface name */ 131 219 parseIFace(token); 132 getNextToken(); 133 switch(curToken) 134 { 135 case ';': 136 if(pCurInterface) 137 { 138 pCurInterface->fIsForwardDeclaration=TRUE; 139 g_ptr_array_add(pInterfaceArray, (gpointer) pCurInterface); 140 pCurInterface=NULL; 141 } 142 break; 143 case ':': 144 g_message("Line %d: Defining subclasses interfaces not supported yet", g_scanner_cur_line(gScanner)); 145 exit(0); 146 case '{': 220 221 if(matchNext(';')) 222 { 223 pCurInterface->fIsForwardDeclaration=TRUE; 224 g_ptr_array_add(pInterfaceArray, (gpointer) pCurInterface); 225 226 } 227 else if(matchNext(':')) 228 { 229 parseSubclassedIFace(); 230 g_ptr_array_add(pInterfaceArray, (gpointer) pCurInterface); 231 } 232 else if(matchNext('{')) 233 { 147 234 parseIFaceBody(); 148 235 g_ptr_array_add(pInterfaceArray, (gpointer) pCurInterface); 149 break; 150 default: 236 } 237 else 238 { 151 239 g_message("Line %d: Error in interface declaration", g_scanner_cur_line(gScanner)); 152 240 exit(0); 153 break;154 155 } 241 } 242 } 243
Note:
See TracChangeset
for help on using the changeset viewer.