question: public IElementType captureString ( ) { CharSequence buffer = getBuffer ( ) ; int currentPosition = getTokenEnd ( ) ; setTokenStart ( currentPosition ) ; int bufferEnd = getBufferEnd ( ) ; char openQuote = buffer . charAt ( currentPosition ) ; char closeQuote = RegexBlock . getQuoteCloseChar ( openQuote ) ; boolean quotesDiffer = openQuote != closeQuote ; boolean isEscaped = false ; int quotesDepth = 0 ; currentPosition ++ ; while ( currentPosition < bufferEnd ) { char currentChar = buffer . charAt ( currentPosition ) ; if ( ! isEscaped && quotesDepth == 0 && currentChar == closeQuote ) { break ; } if ( ! isEscaped && quotesDiffer ) { if ( currentChar == openQuote ) { quotesDepth ++ ; } else if ( currentChar == closeQuote ) { quotesDepth -- ; } } isEscaped = ! isEscaped && currentChar == '\\' ; currentPosition ++ ; } if ( currentPosition < bufferEnd ) { currentPosition ++ ; } setTokenEnd ( currentPosition ) ; PerlStringLexer stringLexer = getStringLexer ( ) ; popState ( ) ; preparsedTokensList . addAll ( lexCurrentToken ( stringLexer ) ) ; return getPreParsedToken ( ) ; }
target:  Captures string token from current position according to the current lexical state