title: Automatically parsing PHP to separate PHP code from HTML
body: <p>I'm working on a large PHP code base; I'd like to separate the PHP code from the HTML and JavaScript.  (I need to do several automatic search-and-replaces on the PHP code, and different ones on the HTML, and different on the JS).  Is there a good parser engine that could separate out the PHP for me? I could do this using regular expressions, but they're not perfect.  I could build something in ANTLR, perhaps, but a good already existing solution would be best.</p>
  
  <p>I should make clear: I don't want or need a full PHP parser.  Just need to know if a given token is:
  - PHP code
  - PHP single quote string
  - PHP double quote string
  - PHP Comment
  - Not PHP, but rather HTML/JavaScript</p>