fool2fish/dragon-book-exercise-answers

2.6 节中对块注释的分析是否有bug

cheniison opened this issue · 0 comments

      // block comment
      char prevPeek = ' ';
      for(;;prevPeek = peek, peek = (char)stream.read()){
        if(prevPeek == '*' && peek == '/'){
          break;
        }
      }

当被分析的字符串为
/*/
时,它可以被正确地解析成块注释。
应该在循环之前加上一条
peek = (char)stream.read();