skipQuoted returns the index of the closing quote of the string/identifier literal opened at i (s[i] is the opening quote), or len(s)-1 if unterminated.
(s string, i int)
| 824 | // skipQuoted returns the index of the closing quote of the string/identifier |
| 825 | // literal opened at i (s[i] is the opening quote), or len(s)-1 if unterminated. |
| 826 | func skipQuoted(s string, i int) int { |
| 827 | quote := s[i] |
| 828 | for j := i + 1; j < len(s); { |
| 829 | switch { |
| 830 | case s[j] == '\\' && quote != '`': |
| 831 | j += 2 // backslash escape ('...'/"..." only) |
| 832 | case s[j] == quote && j+1 < len(s) && s[j+1] == quote: |
| 833 | j += 2 // doubled-quote escape ('' "" ``) |
| 834 | case s[j] == quote: |
| 835 | return j |
| 836 | default: |
| 837 | j++ |
| 838 | } |
| 839 | } |
| 840 | return len(s) - 1 |
| 841 | } |
| 842 | |
| 843 | // skipBlockComment returns the index of the closing "/" of the /* */ comment |
| 844 | // opened at i, or len(s)-1 if unterminated. |