| 276 | // ---------------------------------------------------------------------------------------- |
| 277 | |
| 278 | bool looks_like_function_declaration ( |
| 279 | const std::vector<std::pair<int,string> >& declaration |
| 280 | ) |
| 281 | { |
| 282 | |
| 283 | // Check if declaration contains IDENTIFIER ( ) somewhere in it. |
| 284 | bool seen_first_part = false; |
| 285 | bool seen_operator = false; |
| 286 | int local_paren_count = 0; |
| 287 | for (unsigned long i = 1; i < declaration.size(); ++i) |
| 288 | { |
| 289 | if (declaration[i].first == tok_type::KEYWORD && |
| 290 | declaration[i].second == "operator") |
| 291 | { |
| 292 | seen_operator = true; |
| 293 | } |
| 294 | |
| 295 | if (declaration[i].first == tok_type::OTHER && |
| 296 | declaration[i].second == "(" && |
| 297 | (declaration[i-1].first == tok_type::IDENTIFIER || seen_operator)) |
| 298 | { |
| 299 | seen_first_part = true; |
| 300 | } |
| 301 | |
| 302 | if (declaration[i].first == tok_type::OTHER) |
| 303 | { |
| 304 | if ( declaration[i].second == "(") |
| 305 | ++local_paren_count; |
| 306 | else if ( declaration[i].second == ")") |
| 307 | --local_paren_count; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | if (seen_first_part && local_paren_count == 0) |
| 312 | return true; |
| 313 | else |
| 314 | return false; |
| 315 | } |
| 316 | |
| 317 | // ---------------------------------------------------------------------------------------- |
| 318 | |