title: How can I determine that text is part of a string literal when writing a syntax highlighter
body: <p>I am currently writing a library what will take a NSString and output an NSAttributedString that has been formatted for the specified language. I am planning on iterating through parts of the string using NSRange, but I have run into a few roadblocks. First, how can I make sure that I am not formatting code that is actually string literal. If you have any suggestions or other projects that I should look at, please let me know!</p>
  
  <pre><code>- (NSAttributedString *)formatString:(NSString *)string forLanguage:(STXLanguage)language {
      NSMutableArray *wordsInCode = [NSMutableArray array];
      NSMutableAttributedString *formattedString = [NSMutableAttributedString new];
      NSInteger *locationOfCurrentRange = 0;
      for (NSInteger a = 0; a &lt; string.length; a ++) {
          NSRange currentRange = NSMakeRange(locationOfCurrentRange, a);
      }
      for (NSInteger a = 0; a &lt; wordsInCode.count; a ++) {
          NSAttributedString *stringInWordsInCode = wordsInCode[a];
          [formattedString appendAttributedString:stringInWordsInCode];
      }
      return formattedString;
  }
  </code></pre>