Returns a parsed lstring by stripping out and instances of
    the escaped delimiter. Sometimes the raw lstring has whitespace
    and a double quote at the beginning or end. If present, these
    are removed.
346366
def __lstring(self,lstr):
    
    lstr = self.llsrx.sub('',lstr.encode('ascii'))
    lstr = self.rlsrx.sub('',lstr)
    lstr = self.xmltostr.xlat(lstr)
    lstr = self.dlmrx.sub(',',lstr)
    return lstr
812796
def from_string(cls, s):
        
        def _qstrip(s):
            return s[1:-1]  # remove assumed quote characters
        tokens = []
        for match in _yy_re.finditer(s):
            d = match.groupdict()
            lnk, pos = None, []
            if d['lnkfrom'] is not None:
                lnk = Lnk.charspan(d['lnkfrom'], d['lnkto'])
            if d['pos'] is not None:
                ps = d['pos'].strip().split()
                pos = list(zip(map(_qstrip, ps[::2]), map(float, ps[1::2])))
            tokens.append(
                YyToken(
                    int(d['id']),
                    int(d['start']),
                    int(d['end']),
                    lnk,
                    list(map(int, d['paths'].strip().split())),
                    _qstrip(d['form']),
                    None if d['surface'] is None else _qstrip(d['surface']),
                    int(d['ipos']),
                    list(map(_qstrip, d['lrules'].strip().split())),
                    pos
                )
            )
        return cls(tokens)
190730
public static final String escapeString(final String delimiter,
            final String input) {
        final String escaped = escapeString(input);
        if (escaped.isEmpty()) {
            return escaped;
        }
        return delimiter + escaped;
    }
306285
def get_string(self):
    
    return self.left.chr+':'+str(self.left.end)+'-'+self.right.chr+':'+str(self.right.start)
434381
private static String escapeXml (String nonEscapedXmlStr) {
        StringBuilder escapedXML = new StringBuilder();
        for (int i = 0; i < nonEscapedXmlStr.length(); i++) {
            char c = nonEscapedXmlStr.charAt(i);
            switch (c) {
                case '<':
                    escapedXML.append("&lt;");
                    break;
                case '>':
                    escapedXML.append("&gt;");
                    break;
                case '\"':
                    escapedXML.append("&quot;");
                    break;
                case '&':
                    escapedXML.append("&amp;");
                    break;
                case '\'':
                    escapedXML.append("&apos;");
                    break;
                default:
                    if (c > 0x7e) {
                        escapedXML.append("&#" + ((int) c) + ";");
                    } else {
                        escapedXML.append(c);
                    }
            }
        }
        return escapedXML.toString();
    }
244843
public static String escapeValue(String s) {
        if (s.isEmpty()) {
            return s;
        }
        if (!s.contains(",") &&
            !s.contains("\\") &&
            !Character.isWhitespace(s.charAt(0)) &&
            !Character.isWhitespace(s.charAt(s.length() - 1))) {
            return s;
        }

        StringBuilder b = new StringBuilder(s.length() * 2);
        int begin = 0;
        int end = s.length();

        // Escape all whitespace at the front of the string.
        for (; begin < end && Character.isWhitespace(s.charAt(begin)); begin++) {
            b.append('\\').append(s.charAt(begin));
        }

        // Skip all whitespace at the end of the string.
        while (end > begin && Character.isWhitespace(s.charAt(end - 1))) {
            end--;
        }

        for (int i = begin; i < end; i++) {
            char c = s.charAt(i);
            if (c == '\\' || c == ',') {
                b.append(s, begin, i).append('\\');
                begin = i;
            }
        }

        b.append(s, begin, end);

        // Escape all whitespace at the end of the string.
        for (int i = end; i < s.length(); i++) {
            b.append('\\').append(s.charAt(i));
        }

        return b.toString();
    }
61381
def raw(self):
        
        escape_dict = {'\a': r'\a',
                       '\b': r'\b',
                       '\c': r'\c',
                       '\f': r'\f',
                       '\n': r'\n',
                       '\r': r'\r',
                       '\t': r'\t',
                       '\v': r'\v',
                       #'\x':r'\x',#cannot do \x - otherwise exception
                       '\'': r'\'',
                       '\"': r'\"',
                       #'\0':r'\0', #doesnt work
                       '\1': r'\1',
                       '\2': r'\2',
                       '\3': r'\3',
                       '\4': r'\4',
                       '\5': r'\5',
                       '\6': r'\6',
                       #'\7':r'\7',#same as \a is ASCI
                       }
    
        new_string = ''
        for char in self:
            try:
                new_string += escape_dict[char]
            except KeyError:
                new_string += char
        return new_string
264805
def escape(cls, string):
        

        return ''.join([cls._escapes[c] if cls._needescape(c) else c
                        for c in string.encode('utf8')])
733186
def dedent_block_string_value(raw_string: str) -> str:
    
    lines = raw_string.splitlines()

    common_indent = None
    for line in lines[1:]:
        indent = leading_whitespace(line)
        if indent < len(line) and (common_indent is None or indent < common_indent):
            common_indent = indent
        if common_indent == 0:
            break

    if common_indent:
        lines[1:] = [line[common_indent:] for line in lines[1:]]

    while lines and not lines[0].strip():
        lines = lines[1:]

    while lines and not lines[-1].strip():
        lines = lines[:-1]

    return "\n".join(lines)
537887
def _raw(s):
    """"""

    if isinstance(s, list):
        s = "\n".join(_raw(item) for item in s)

    if s == EOF:
        return "EOF"

    s = repr(s)  # Get raw representation of string
    s = s[1:-1]  # Strip away quotation marks
    if len(s) > 15:
        s = s[:15] + "..."  # Truncate if too long
    return s
307351
def tokenize_non_expanded_string( start_delimiter )
      delimiter_depth = 0
      matched_delimiter = is_matched_delimiter?( start_delimiter )
      end_delimiter = find_matching_delimiter( start_delimiter )

      advance # Pass the opening delimiter

      until((cchar == end_delimiter && delimiter_depth == 0) || @i >= @length)

        if matched_delimiter
          delimiter_depth += 1 if cchar == start_delimiter
          delimiter_depth -= 1 if cchar == end_delimiter
        end

        if cchar == '\\'
          advance(2) # Pass the escaped character
        else
          advance
        end
      end
      advance # Pass the closing quote

      if @state == :regex
        advance if ['i', 'm'].include?( cchar )
      end

      @expr_state = :end
      capture_token( @state )
    end
645607
def pretty_string(s, embedded, current_line, uni_lit=False,
                  min_trip_str=20, max_line=100):
    

    default = repr(s)

    # Punt on abnormal strings
    if (isinstance(s, special_unicode) or not isinstance(s, basestring)):
        return default
    if uni_lit and isinstance(s, bytes):
        return 'b' + default

    len_s = len(default)

    if current_line.strip():
        len_current = len(current_line)
        second_line_start = s.find('\n') + 1
        if embedded > 1 and not second_line_start:
            return default

        if len_s < min_trip_str:
            return default

        line_indent = len_current - len(current_line.lstrip())

        # Could be on a line by itself...
        if embedded and not second_line_start:
            return default

        total_len = len_current + len_s
        if total_len < max_line and not _properly_indented(s, line_indent):
            return default

    fancy = string_triplequote_repr(s)

    # Sometimes this doesn't work.  One reason is that
    # the AST has no understanding of whether \r\n was
    # entered that way in the string or was a cr/lf in the
    # file.  So we punt just so we can round-trip properly.

    try:
        if eval(fancy) == s and '\r' not in fancy:
            return fancy
    except:
        pass
    return default
446040
private static String readQuotedString(Buffer buffer) throws EOFException {
    if (buffer.readByte() != '\"') throw new IllegalArgumentException();
    Buffer result = new Buffer();
    while (true) {
      long i = buffer.indexOfElement(QUOTED_STRING_DELIMITERS);
      if (i == -1L) return null; // Unterminated quoted string.

      if (buffer.getByte(i) == '"') {
        result.write(buffer, i);
        // Consume '"'.
        buffer.readByte();
        return result.readUtf8();
      }

      if (buffer.size() == i + 1L) return null; // Dangling escape.
      result.write(buffer, i);
      // Consume '\'.
      buffer.readByte();
      result.write(buffer, 1L); // The escaped character.
    }
  }
42146
def parse_string(self):
        """"""
        word = ''

        if self.prior_delim:
            delim = self.prior_delim
            self.prior_delim = None
        else:
            delim = self.char
            word += self.char
            self.update_chars()

        while True:
            if self.char == delim:
                # Check for escaped delimiters
                self.update_chars()
                if self.char == delim:
                    word += 2 * delim
                    self.update_chars()
                else:
                    word += delim
                    break
            elif self.char == '\n':
                self.prior_delim = delim
                break
            else:
                word += self.char
                self.update_chars()

        return word
1194475
def escape_string(self, value):
        
        if isinstance(value, EscapedString):
            return value.formatted(self._escaper)
        return self._escaper(value)
1108329
private void parse() throws ParserException {
		//skip white spaces
		skipWhitespace();
		try{
			_parse();
		}catch(Exception e){
			System.out.println("\t" + this.getClass().getSimpleName() + "->" + this.toString());
			if(!(e instanceof ParserException)){
				throw new ParserException("Error parsing", e);
			}else{
				throw (ParserException)e;
			}
		}
		skipWhitespace();
	}
87502
String readEscaped() throws IOException {
		StringBuilder s = new StringBuilder();
		int quote = reader.read();
		if (quote != QUOTE_CHAR)
			throw new IllegalStateException();
		do {
			int c = reader.read();
			if (c == -1) {
				throw new IllegalStateException("Non closing quote");
			} else if (c == QUOTE_CHAR) {
				int c2 = reader.read();
				if (c2 == QUOTE_CHAR) {
					s.append((char) c);
				} else {
					reader.unread(c2);
					return s.toString();
				}
			} else {
				s.append((char) c);
			}
		} while (true);
	}