llvm.org GIT mirror llvm / 0f04f3b
YAML: Extract the code that skips a comment into a separate method, NFC. This commit extracts the code that skips over a YAML comment from the 'scanToNextToken' method into a separate 'skipComment' method. This refactoring is motivated by a patch that implements parsing of YAML block scalars (http://reviews.llvm.org/D9503), as the method that parses a block scalar reuses the 'skipComment' method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236663 91177308-0d34-0410-b5e6-96231b3b80d8 Alex Lorenz 4 years ago
1 changed file(s) with 19 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
415415 bool rollIndent( int ToColumn
416416 , Token::TokenKind Kind
417417 , TokenQueueT::iterator InsertPoint);
418
419 /// @brief Skip a single-line comment when the comment starts at the current
420 /// position of the scanner.
421 void skipComment();
418422
419423 /// @brief Skip whitespace and comments until the start of the next token.
420424 void scanToNextToken();
961965 return true;
962966 }
963967
968 void Scanner::skipComment() {
969 if (*Current != '#')
970 return;
971 while (true) {
972 // This may skip more than one byte, thus Column is only incremented
973 // for code points.
974 StringRef::iterator I = skip_nb_char(Current);
975 if (I == Current)
976 break;
977 Current = I;
978 ++Column;
979 }
980 }
981
964982 void Scanner::scanToNextToken() {
965983 while (true) {
966984 while (*Current == ' ' || *Current == '\t') {
967985 skip(1);
968986 }
969987
970 // Skip comment.
971 if (*Current == '#') {
972 while (true) {
973 // This may skip more than one byte, thus Column is only incremented
974 // for code points.
975 StringRef::iterator i = skip_nb_char(Current);
976 if (i == Current)
977 break;
978 Current = i;
979 ++Column;
980 }
981 }
988 skipComment();
982989
983990 // Skip EOL.
984991 StringRef::iterator i = skip_b_break(Current);