| 127 | } |
| 128 | |
| 129 | void Parser::parseInterface(bool exception) |
| 130 | { |
| 131 | interface = new Interface(); |
| 132 | interfaces.push_back(interface); |
| 133 | |
| 134 | interface->name = getToken(token, Token::TYPE_IDENTIFIER).text; |
| 135 | typesByName.insert(pair<string, BaseType*>(interface->name, interface)); |
| 136 | |
| 137 | if (exception) |
| 138 | exceptionInterface = interface; |
| 139 | |
| 140 | if (lexer->getToken(token).type == TOKEN(':')) |
| 141 | { |
| 142 | string superName = getToken(token, Token::TYPE_IDENTIFIER).text; |
| 143 | map<string, BaseType*>::iterator it = typesByName.find(superName); |
| 144 | |
| 145 | if (it == typesByName.end() || it->second->type != BaseType::TYPE_INTERFACE) |
| 146 | error(token, string("Super interface '") + superName + "' not found."); |
| 147 | |
| 148 | interface->super = static_cast<Interface*>(it->second); |
| 149 | interface->version = interface->super->version + 1; |
| 150 | } |
| 151 | else |
| 152 | lexer->pushToken(token); |
| 153 | |
| 154 | getToken(token, TOKEN('{')); |
| 155 | |
| 156 | while (lexer->getToken(token).type != TOKEN('}')) |
| 157 | { |
| 158 | if (token.type == Token::TYPE_VERSION) |
| 159 | { |
| 160 | getToken(token, TOKEN(':')); |
| 161 | ++interface->version; |
| 162 | } |
| 163 | else |
| 164 | lexer->pushToken(token); |
| 165 | |
| 166 | parseItem(); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | void Parser::parseStruct() |
| 171 | { |