Reads a comment from the input. Writes nothing to the output.
| 191 | |
| 192 | // Reads a comment from the input. Writes nothing to the output. |
| 193 | void skipComment() { |
| 194 | char c; |
| 195 | get(); // consume initial '/' |
| 196 | switch (get()) { |
| 197 | case '/': |
| 198 | do { |
| 199 | c = peek(); |
| 200 | if (c) |
| 201 | get(); |
| 202 | } while (c != 0 && !isnewline(c)); |
| 203 | break; |
| 204 | case '*': { |
| 205 | bool star; |
| 206 | c = 0; |
| 207 | do { |
| 208 | star = (c == '*'); |
| 209 | c = get(); |
| 210 | } while (!(star && c=='/')); |
| 211 | break; |
| 212 | } |
| 213 | default: |
| 214 | fail("Syntax error after '/'"); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | // Returns the next character from the input without consuming it, or 0 at EOF. |
| 219 | char peek() { |