title: Handling different escaping sequences?
body: <p>I'm using ANTLR with Presto grammar in order to parse SQL queries.
  This is the original string definition I've used to parse queries:</p>
  <pre><code>STRING
      : '\'' ( '\\' .
             | ~[\\']       // match anything other than \ and '
             | '\'\''       // match ''
             )*
        '\''
      ;
  </code></pre>
  <p>This worked ok for most queries until I saw queries with different escaping rules. For example:</p>
  <pre><code>select 
  table1(replace(replace(some_col,'\\'',''),'\&quot;' ,'')) as features 
  from table1
  </code></pre>
  <p>So I've modified my String definition and now it looks like:</p>
  <pre><code>STRING
      : '\'' ( '\\' .
             | '\\\\'  .  {HelperUtils.isNeedSpecialEscaping(this)}?       // match \ followed by any char
             | ~[\\']       // match anything other than \ and '
             | '\'\''       // match ''
             )*
        '\''
      ;
  </code></pre>
  <p>However, this won't work for the query mentioned above as I'm getting</p>
  <pre><code>'\\'',''),'
  </code></pre>
  <p>as a single string.
  The predicate returns True for the following query.
  Any idea how can I handle this query as well?</p>
  <p>Thanks,
  Nir.</p>