Click here to Skip to main content
14,486,406 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: Second call, Mr. Cthulhu Pin
Mark_Wallace31-Dec-19 21:54
MemberMark_Wallace31-Dec-19 21:54 
GeneralI'm finally ready for an article. I'm exhausted Pin
honey the codewitch31-Dec-19 7:21
mvahoney the codewitch31-Dec-19 7:21 
GeneralRe: I'm finally ready for an article. I'm exhausted Pin
Southmountain31-Dec-19 8:09
MemberSouthmountain31-Dec-19 8:09 
GeneralRe: I'm finally ready for an article. I'm exhausted Pin
honey the codewitch31-Dec-19 8:13
mvahoney the codewitch31-Dec-19 8:13 
GeneralRe: I'm finally ready for an article. I'm exhausted Pin
Greg Utas31-Dec-19 10:19
professionalGreg Utas31-Dec-19 10:19 
GeneralRe: I'm finally ready for an article. I'm exhausted Pin
honey the codewitch31-Dec-19 10:23
mvahoney the codewitch31-Dec-19 10:23 
GeneralRe: I'm finally ready for an article. I'm exhausted Pin
honey the codewitch31-Dec-19 12:24
mvahoney the codewitch31-Dec-19 12:24 
GeneralRe: I'm finally ready for an article. I'm exhausted Pin
Greg Utas31-Dec-19 13:38
professionalGreg Utas31-Dec-19 13:38 
I'd have to adapt your strategy because my code is totally hand-rolled. This function would probably have to assemble comments and save them in an adjunct vector of strings. It's invoked from many places and I'm loath to spend time speculatively constructing and passing around strings.
size_t Lexer::NextPos(size_t pos) const
{
   //  Find the next character to be parsed.
   //
   while(pos < size_)
   {
      auto c = source_->at(pos);

      switch(c)
      {
      case SPACE:
      case CRLF:
      case TAB:
         //
         //  Skip these.
         //
         ++pos;
         break;

      case '/':
         //
         //  See if this begins a comment (// or /*).
         //
         if(++pos >= size_) return string::npos;

         switch(source_->at(pos))
         {
         case '/':
            //
            //  This is a // comment.  Continue on the next line.
            //
            pos = source_->find(CRLF, pos);
            if(pos == string::npos) return pos;
            ++pos;
            break;

         case '*':
            //
            //  This is a /* comment.  Continue where it ends.
            //
            if(++pos >= size_) return string::npos;
            pos = source_->find(COMMENT_END_STR, pos);
            if(pos == string::npos) return string::npos;
            pos += 2;
            break;

         default:
            //
            //  The / did not introduce a comment, so it is the next
            //  character of interest.
            //
            return --pos;
         }
         break;

      case BACKSLASH:
         //
         //  See if this is a continuation of the current line.
         //
         if(++pos >= size_) return string::npos;
         if(source_->at(pos) != CRLF) return pos - 1;
         ++pos;
         break;

      default:
         return pos;
      }
   }

   return string::npos;
}


modified 4-Jan-20 10:04am.

GeneralRe: I'm finally ready for an article. I'm exhausted Pin
honey the codewitch31-Dec-19 17:21
mvahoney the codewitch31-Dec-19 17:21 
GeneralRe: I'm finally ready for an article. I'm exhausted Pin
Greg Utas1-Jan-20 0:39
professionalGreg Utas1-Jan-20 0:39 
GeneralRe: I'm finally ready for an article. I'm exhausted Pin
honey the codewitch1-Jan-20 5:54
mvahoney the codewitch1-Jan-20 5:54 
GeneralRe: I'm finally ready for an article. I'm exhausted Pin
Greg Utas1-Jan-20 6:26
professionalGreg Utas1-Jan-20 6:26 
QuestionRe: I'm finally ready for an article. I'm exhausted Pin
honey the codewitch1-Jan-20 13:45
mvahoney the codewitch1-Jan-20 13:45 
AnswerRe: I'm finally ready for an article. I'm exhausted Pin
Greg Utas1-Jan-20 15:25
professionalGreg Utas1-Jan-20 15:25 
GeneralRe: I'm finally ready for an article. I'm exhausted Pin
honey the codewitch1-Jan-20 15:27
mvahoney the codewitch1-Jan-20 15:27 
Generalat least it's sunny there Pin
honey the codewitch31-Dec-19 5:39
mvahoney the codewitch31-Dec-19 5:39 
GeneralRe: at least it's sunny there Pin
Ron Anders31-Dec-19 5:52
MemberRon Anders31-Dec-19 5:52 
GeneralRe: at least it's sunny there Pin
Cp-Coder31-Dec-19 6:24
MemberCp-Coder31-Dec-19 6:24 
GeneralRe: at least it's sunny there Pin
Ron Anders31-Dec-19 6:29
MemberRon Anders31-Dec-19 6:29 
GeneralRe: at least it's sunny there Pin
Cp-Coder31-Dec-19 6:35
MemberCp-Coder31-Dec-19 6:35 
GeneralRe: at least it's sunny there Pin
stoneyowl231-Dec-19 9:45
Memberstoneyowl231-Dec-19 9:45 
GeneralRe: at least it's sunny there Pin
Marc Clifton31-Dec-19 5:52
mvaMarc Clifton31-Dec-19 5:52 
GeneralAnd another one is gone. But this time, you probably have no idea who he is: Syd Mead RIP. Pin
OriginalGriff31-Dec-19 4:29
mveOriginalGriff31-Dec-19 4:29 
GeneralRe: And another one is gone. But this time, you probably have no idea who he is: Syd Mead RIP. Pin
RickZeeland31-Dec-19 4:34
mveRickZeeland31-Dec-19 4:34 
GeneralWho writes the subtitles Pin
bleahy4831-Dec-19 4:20
Memberbleahy4831-Dec-19 4:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.