Simplified helpers referenced by the grammar.
| 55 | |
| 56 | // Simplified helpers referenced by the grammar. |
| 57 | std::string program_name(std::string filename) { |
| 58 | filename.erase(std::remove(filename.begin(), filename.end(), '\\'), filename.end()); |
| 59 | std::string::size_type slash = filename.rfind('/'); |
| 60 | if (slash != std::string::npos) { |
| 61 | filename = filename.substr(slash + 1); |
| 62 | } |
| 63 | std::string::size_type dot = filename.rfind('.'); |
| 64 | if (dot != std::string::npos) { |
| 65 | filename = filename.substr(0, dot); |
| 66 | } |
| 67 | return filename; |
| 68 | } |
| 69 | |
| 70 | std::string directory_name(std::string filename) { |
| 71 | std::replace(filename.begin(), filename.end(), '\\', '/'); |