! * @brief scan a comment * @return whether comment could be scanned successfully */
| 6781 | * @return whether comment could be scanned successfully |
| 6782 | */ |
| 6783 | bool scan_comment() |
| 6784 | { |
| 6785 | switch (get()) |
| 6786 | { |
| 6787 | // single-line comments skip input until a newline or EOF is read |
| 6788 | case '/': |
| 6789 | { |
| 6790 | while (true) |
| 6791 | { |
| 6792 | switch (get()) |
| 6793 | { |
| 6794 | case '\n': |
| 6795 | case '\r': |
| 6796 | case std::char_traits<char_type>::eof(): |
| 6797 | case '\0': |
| 6798 | return true; |
| 6799 | |
| 6800 | default: |
| 6801 | break; |
| 6802 | } |
| 6803 | } |
| 6804 | } |
| 6805 | |
| 6806 | // multi-line comments skip input until */ is read |
| 6807 | case '*': |
| 6808 | { |
| 6809 | while (true) |
| 6810 | { |
| 6811 | switch (get()) |
| 6812 | { |
| 6813 | case std::char_traits<char_type>::eof(): |
| 6814 | case '\0': |
| 6815 | { |
| 6816 | error_message = "invalid comment; missing closing '*/'"; |
| 6817 | return false; |
| 6818 | } |
| 6819 | |
| 6820 | case '*': |
| 6821 | { |
| 6822 | switch (get()) |
| 6823 | { |
| 6824 | case '/': |
| 6825 | return true; |
| 6826 | |
| 6827 | default: |
| 6828 | { |
| 6829 | unget(); |
| 6830 | continue; |
| 6831 | } |
| 6832 | } |
| 6833 | } |
| 6834 | |
| 6835 | default: |
| 6836 | continue; |
| 6837 | } |
| 6838 | } |
| 6839 | } |
| 6840 |