! * @brief scan a comment * @return whether comment could be scanned successfully */
| 8214 | * @return whether comment could be scanned successfully |
| 8215 | */ |
| 8216 | bool scan_comment() |
| 8217 | { |
| 8218 | switch (get()) |
| 8219 | { |
| 8220 | // single-line comments skip input until a newline or EOF is read |
| 8221 | case '/': |
| 8222 | { |
| 8223 | while (true) |
| 8224 | { |
| 8225 | switch (get()) |
| 8226 | { |
| 8227 | case '\n': |
| 8228 | case '\r': |
| 8229 | case char_traits<char_type>::eof(): |
| 8230 | case '\0': |
| 8231 | return true; |
| 8232 | |
| 8233 | default: |
| 8234 | break; |
| 8235 | } |
| 8236 | } |
| 8237 | } |
| 8238 | |
| 8239 | // multi-line comments skip input until */ is read |
| 8240 | case '*': |
| 8241 | { |
| 8242 | while (true) |
| 8243 | { |
| 8244 | switch (get()) |
| 8245 | { |
| 8246 | case char_traits<char_type>::eof(): |
| 8247 | case '\0': |
| 8248 | { |
| 8249 | error_message = "invalid comment; missing closing '*/'"; |
| 8250 | return false; |
| 8251 | } |
| 8252 | |
| 8253 | case '*': |
| 8254 | { |
| 8255 | switch (get()) |
| 8256 | { |
| 8257 | case '/': |
| 8258 | return true; |
| 8259 | |
| 8260 | default: |
| 8261 | { |
| 8262 | unget(); |
| 8263 | continue; |
| 8264 | } |
| 8265 | } |
| 8266 | } |
| 8267 | |
| 8268 | default: |
| 8269 | continue; |
| 8270 | } |
| 8271 | } |
| 8272 | } |
| 8273 |