| 43 | } |
| 44 | |
| 45 | void Parser::parse() |
| 46 | { |
| 47 | interface = NULL; |
| 48 | |
| 49 | while (true) |
| 50 | { |
| 51 | bool exception = false; |
| 52 | lexer->getToken(token); |
| 53 | |
| 54 | if (token.type == Token::TYPE_EOF) |
| 55 | break; |
| 56 | else if (token.type == TOKEN('[')) |
| 57 | { |
| 58 | getToken(token, Token::TYPE_EXCEPTION); // This is the only attribute we allow now. |
| 59 | exception = true; |
| 60 | getToken(token, TOKEN(']')); |
| 61 | } |
| 62 | else |
| 63 | lexer->pushToken(token); |
| 64 | |
| 65 | lexer->getToken(token); |
| 66 | |
| 67 | switch (token.type) |
| 68 | { |
| 69 | case Token::TYPE_INTERFACE: |
| 70 | parseInterface(exception); |
| 71 | break; |
| 72 | |
| 73 | case Token::TYPE_STRUCT: |
| 74 | if (exception) |
| 75 | error(token, "Cannot use attribute exception in struct."); |
| 76 | parseStruct(); |
| 77 | break; |
| 78 | |
| 79 | case Token::TYPE_TYPEDEF: |
| 80 | if (exception) |
| 81 | error(token, "Cannot use attribute exception in typedef."); |
| 82 | parseTypedef(); |
| 83 | break; |
| 84 | |
| 85 | case Token::TYPE_BOOLEAN: |
| 86 | if (exception) |
| 87 | error(token, "Cannot use attribute exception in boolean."); |
| 88 | parseBoolean(); |
| 89 | break; |
| 90 | |
| 91 | default: |
| 92 | syntaxError(token); |
| 93 | break; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | // Check types, assign statusName to methods. |
| 98 | |
| 99 | for (vector<Interface*>::iterator i = interfaces.begin(); i != interfaces.end(); ++i) |
| 100 | { |
| 101 | Interface* interface = *i; |
| 102 | |